]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/zipdiff
Fix macOS SDL2 framework permissions
[xonotic/xonotic.git] / misc / tools / zipdiff
index b51a467a3ffacd6eb4fe67e5826ed9a0c29efe19..661d9a2d677b3fcf3c583f5ae4b924b36405497c 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+set -e
+
 usage()
 {
        cat <<EOF
@@ -14,6 +16,15 @@ output=
 from=
 to=
 excludes=
+ziptool="mkzip"
+
+mkzip()
+{
+       archive=$1; shift
+       zipflags=-1ry
+       zip $zipflags "$archive" "$@" || true
+       advzip -z -4 "$archive"
+}
 
 while [ $# -gt 0 ]; do
        o=$1
@@ -35,6 +46,10 @@ while [ $# -gt 0 ]; do
                        excludes="$excludes $1"
                        shift
                        ;;
+               -z)
+                       ziptool=$1
+                       shift
+                       ;;
                *)
                        usage
                        ;;
@@ -44,6 +59,10 @@ done
 [ -n "$from" ] || usage
 [ -n "$to" ] || usage
 
+case "$output" in '') ;; /*) ;; *) output=`pwd`/$output ;; esac
+case "$from" in /*) ;; *) from=`pwd`/$from ;; esac
+case "$to" in /*) ;; *) to=`pwd`/$to ;; esac
+
 found()
 {
        type=$1
@@ -148,23 +167,17 @@ case "$output" in
                ;;
        *)
                rm -f "$output"
-               echo "$result" | while IFS= read -r line; do
-                       echo >&2 "extracting $line..."
-                       dline=./$line
-                       mkdir -p "$tempdir/${dline%/*}"
-                       unzip -p "$to" "$line" > "$tempdir/$line" # this may create an empty file - don't care, DP handles this as deletion
-               done
-               case "$output" in
-                       /*)
-                               ;;
-                       *)
-                               output=`pwd`/$output
-                               ;;
-               esac
-               cd "$tempdir"
-               #zip -9r "$output" .
-               7za a -tzip -mx=9 "$output" .
-               cd ..
+               if [ -n "$result" ]; then
+                       cd "$tempdir"
+                       echo "$result" | while IFS= read -r line; do
+                               echo >&2 "extracting $line..."
+                               dline=./$line
+                               mkdir -p "$tempdir/${dline%/*}"
+                               unzip "$to" "$line"
+                       done
+                       $ziptool "$output" *
+                       cd ..
+               fi
                ;;
 esac