]> git.somenet.org - tools/vmdiff.git/blob - vmdiff.sh
published scripts under GPLv3
[tools/vmdiff.git] / vmdiff.sh
1 #!/bin/bash
2 #
3 # Copyright 2015 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
4 #
5 #    This program is free software: you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License as published by
7 #    the Free Software Foundation, version 3 of the License.
8 #
9 #    This program is distributed in the hope that it will be useful,
10 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #    GNU General Public License for more details.
13 #
14 #    You should have received a copy of the GNU General Public License
15 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 #
17 # Script to create diff from two selected snapshots.
18 #
19
20 if [ ! -d "untracked" ]; then
21   echo "cannot cd untracked. wtf? fail!"
22   exit 1
23 fi
24
25 cd untracked
26
27 if [ ! -d ".git" ]; then
28   echo "git repo not found. cannot continue."
29   exit 1
30 fi
31
32 rm -f vmdiff.*
33
34 echo "extracting file permission changes..."
35 git diff -U0 "$1".."$2" -- setPerms.sh > vmdiff.perms.changed.txt
36
37 echo "extracting changed file list..."
38 git diff --name-status "$1".."$2" -- root | sort > vmdiff.files.changed.txt
39
40 echo "extracting changed files..."
41 echo "setPerms.sh" > vmdiff.tar.files.txt
42 echo "vmdiff.perms.changed.txt" >> vmdiff.tar.files.txt
43 echo "vmdiff.files.changed.txt" >> vmdiff.tar.files.txt
44 echo "root" >> vmdiff.tar.files.txt
45 cat vmdiff.files.changed.txt | egrep -v "^D" | sed -e 's/^.\s\+//' >> vmdiff.tar.files.txt
46
47 git checkout "$2"
48 tar -cavf vmdiff.tar.gz -T vmdiff.tar.files.txt --no-recursion
49