]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/xzipdiff
Fix macOS SDL2 framework permissions
[xonotic/xonotic.git] / misc / tools / xzipdiff
1 #!/bin/sh
2
3 set -e
4
5 from=$1
6 to=$2
7 output=$3
8 case "$from" in /*) ;; *) from=`pwd`/$from ;; esac
9 case "$to" in /*) ;; *) to=`pwd`/$to ;; esac
10 case "$output" in /*) ;; *) output=`pwd`/$output ;; esac
11
12 excludes="
13         Xonotic/data/xonotic-*-data.pk3
14         Xonotic/data/xonotic-*-maps.pk3
15         Xonotic/data/xonotic-*-music.pk3
16         Xonotic/data/xonotic-*-nexcompat.pk3
17         Xonotic/data/xonotic-*-data-low.pk3
18         Xonotic/data/xonotic-*-maps-low.pk3
19         Xonotic/data/xonotic-*-music-low.pk3
20         Xonotic/data/font-nimbussansl-*.pk3
21         Xonotic/data/font-unifont-*.pk3
22         Xonotic/data/font-xolonium-*.pk3
23 "
24
25 makepatchname()
26 {
27         wildcard=$1
28         fromname=$2
29         toname=$3
30         prefix=${wildcard%%\**}
31         suffix=${wildcard#*\*}
32         fromversion=${fromname#$prefix}
33         fromversion=${fromversion%$suffix}
34         toversion=${toname#$prefix}
35         toversion=${toversion%$suffix}
36         echo "$prefix$fromversion"patch"$toversion$suffix"
37 }
38
39 zipdiff -f "$from" -t "$to" -o "$output" -x "$excludes"
40 # or maybe just include ALL not excluded files from $to in $output?
41
42 tempdir=`mktemp -d -t zipdiff.XXXXXX`
43 cd "$tempdir"
44
45 for x in $excludes; do
46         mkdir a b c
47         (cd a && unzip "$from" "$x")
48         fromname=`find a/ -type f`; fromname=${fromname#a/}
49         (cd b && unzip "$to" "$x")
50         toname=`find b/ -type f`; toname=${toname#b/}
51         patchname=`makepatchname "$x" "$fromname" "$toname"`
52         patchdir="c/$patchname"; patchdir=${patchdir%/*}
53         mkdir -p "$patchdir"
54         zipdiff -f a/"$fromname" -t b/"$toname" -o c/"$patchname"
55         if [ -f c/"$patchname" ]; then
56                 (cd c && zip -0r "$output" "$patchname")
57         fi
58         rm -rf a b c
59 done
60
61 rm -rf "$tempdir"