]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/xzipdiff
diff two xonotic release-like builds (untested)
[xonotic/xonotic.git] / misc / tools / xzipdiff
1 #!/bin/sh
2
3 from=$1
4 to=$2
5 output=$3
6 case "$from" in /*) ;; *) from=`pwd`/$from ;; esac
7 case "$to" in /*) ;; *) to=`pwd`/$to ;; esac
8 case "$output" in /*) ;; *) output=`pwd`/$output ;; esac
9
10 excludes="
11         data/xonotic-*-data.pk3
12         data/xonotic-*-maps.pk3
13         data/xonotic-*-music.pk3
14         data/xonotic-*-nexcompat.pk3
15 "
16
17 makepatchname()
18 {
19         wildcard=$1
20         fromname=$2
21         toname=$3
22         prefix=${wildcard##*\*}
23         suffix=${wildcard%\**}
24         fromversion=${fromname#$prefix}
25         fromversion=${fromversion%$suffix}
26         toversion=${fromname#$prefix}
27         toversion=${fromversion%$suffix}
28         echo "$prefix$fromversion"patch"$toversion$suffix"
29 }
30
31 zipdiff -f "$from" -t "$to" -o "$output" -x "$excludes"
32
33 tempdir=`mktemp -d -t zipdiff.XXXXXX`
34 cd "$tempdir"
35
36 for x in $excludes; do
37         mkdir a b c
38         (cd a && unzip "$from" "$x")
39         fromname=`find a/ -type f`; fromname=${fromname#a/}
40         (cd b && unzip "$to" "$x")
41         toname=`find b/ -type f`; toname=${toname#b/}
42         patchname=`makepatchname "$x" "$fromname" "$toname"`
43         patchdir="c/$patchname"; patchdir=${patchdir%/*}
44         mkdir -p "$patchdir"
45         zipdiff -f a/"$fromname" -t b/"$toname" -o c/"$patchname"
46         if [ -f c/"$patchname" ]; then
47                 (cd c && zip -0r "$output" "$patchname")
48         fi
49         rm -rf a b c
50 done
51
52 rm -rf "$tempdir"