63 lines
1.8 KiB
Bash
Executable File
63 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ $# -ne 2 ]; then
|
|
echo "Usage: $0 /path/to/Orbot-v15.0.1.apk /another/Orbot-v15.0.1.apk"
|
|
exit 1
|
|
fi
|
|
|
|
set -e
|
|
set -x
|
|
|
|
test -e "$1"
|
|
test -e "$2"
|
|
|
|
tmpdir=`mktemp -d /tmp/.compare-apks.XXXXXXXXXX`
|
|
apk1=$(basename $1)
|
|
apk2=$(basename $2)
|
|
sourcedir1=$(cd `dirname $1` && pwd)
|
|
sourcedir2=$(cd `dirname $2` && pwd)
|
|
apkname1=`echo $apk1 | sed 's,\.apk$,,'`
|
|
apkname2=`echo $apk2 | sed 's,\.apk$,,'`
|
|
dir1=$tmpdir/`echo $(dirname $1) | sed 's,[/ ],_,g'`-$apkname1
|
|
dir2=$tmpdir/`echo $(dirname $2) | sed 's,[/ ],_,g'`-$apkname2
|
|
|
|
mkdir -p $dir1/zip
|
|
cd $dir1/zip
|
|
unzip "$sourcedir1/$apk1"
|
|
cd ..
|
|
apktool d --no-res --no-src "$sourcedir1/$apk1"
|
|
mv "$apkname1" apktool
|
|
# strip the full path to the zip for the comparison
|
|
unzip -l "$sourcedir1/$apk1" | sed 's,^\(Archive:\s\s*\)/.*/,\1,' > $dir1/unzip-l.txt
|
|
unzip -lv "$sourcedir1/$apk1" | sed 's,^\(Archive:\s\s*\)/.*/,\1,' > $dir1/unzip-lv.txt
|
|
zipinfo -lv "$sourcedir1/$apk1" | sed 's,^\(Archive:\s\s*\)/.*/,\1,' > $dir1/zipinfo-lv.txt
|
|
xxd "$sourcedir1/$apk1" > $dir1/xxd
|
|
for f in $dir1/zip/assets/*/*; do
|
|
xxd $f > $dir1/xxd-$(basename $f)
|
|
done
|
|
|
|
mkdir -p $dir2/zip
|
|
cd $dir2/zip
|
|
unzip "$sourcedir2/$apk2"
|
|
cd ..
|
|
apktool d --no-res --no-src "$sourcedir2/$apk2"
|
|
mv "$apkname2" apktool
|
|
# strip the full path to the zip for the comparison
|
|
unzip -l "$sourcedir2/$apk2" | sed 's,^\(Archive:\s\s*\)/.*/,\1,' > $dir2/unzip-l.txt
|
|
unzip -lv "$sourcedir2/$apk2" | sed 's,^\(Archive:\s\s*\)/.*/,\1,' > $dir2/unzip-lv.txt
|
|
zipinfo -lv "$sourcedir2/$apk2" | sed 's,^\(Archive:\s\s*\)/.*/,\1,' > $dir2/zipinfo-lv.txt
|
|
xxd "$sourcedir2/$apk2" > $dir2/xxd
|
|
for f in $dir2/zip/assets/*/*; do
|
|
xxd $f > $dir2/xxd-$(basename $f)
|
|
done
|
|
|
|
if which meld > /dev/null; then
|
|
meld $dir1 $dir2
|
|
elif which opendiff > /dev/null; then
|
|
opendiff $dir1 $dir2
|
|
else
|
|
echo "ERROR: meld or opendiff required for the comparison!"
|
|
fi
|
|
|
|
rm -rf $dir1 $dir2
|