7 $0 -o difference.zip -f from.zip -t to.zip
8 $0 -f from.zip -t to.zip
17 ziptool="7za a -tzip -mx=9"
19 while [ $# -gt 0 ]; do
36 excludes="$excludes $1"
49 [ -n "$from" ] || usage
56 echo >&2 "$type: $source"
64 echo >&2 " * Sorry, can't handle deletion of $source."
69 tempdir=`mktemp -d -t zipdiff.XXXXXX`
73 fromlist="$(zipinfo -1 "$from" | grep -v /\$)"
74 tolist="$(zipinfo -1 "$to" | grep -v /\$)"
78 echo "$fromlist" | while IFS= read -r line; do
79 case "$newline$tolist$newline" in
80 *$newline$line$newline*)
85 for P in $excludes; do
88 found excluded "$line"
95 if ! $isexcluded; then
101 echo "$tolist" | while IFS= read -r line; do
102 case "$newline$fromlist$newline" in
103 *$newline$line$newline*)
107 for P in $excludes; do
110 found excluded "$line"
117 if ! $isexcluded; then
118 unzip -p "$from" "$line" > "$tempdir/v1"
119 unzip -p "$to" "$line" > "$tempdir/v2"
120 if ! diff --brief "$tempdir/v1" "$tempdir/v2" >/dev/null 2>&1; then
121 found changed "$line"
131 for P in $excludes; do
134 found excluded "$line"
141 if ! $isexcluded; then
156 if [ -n "$result" ]; then
157 echo "$result" | while IFS= read -r line; do
158 echo >&2 "extracting $line..."
160 mkdir -p "$tempdir/${dline%/*}"
161 unzip -p "$to" "$line" > "$tempdir/$line" # this may create an empty file - don't care, DP handles this as deletion