bsdiff-4.3$ make
cc -O3 -lbz2 bsdiff.c -o bsdiff
/tmp/cc3OAqLk.o: In function `main':
bsdiff.c:(.text.startup+0x2b3): undefined reference to `BZ2_bzWriteOpen'
bsdiff.c:(.text.startup+0x968): undefined reference to `BZ2_bzWrite'
bsdiff.c:(.text.startup+0x9b0): undefined reference to `BZ2_bzWrite'
bsdiff.c:(.text.startup+0xa0c): undefined reference to `BZ2_bzWrite'
bsdiff.c:(.text.startup+0xa6b): undefined reference to `BZ2_bzWriteClose'
bsdiff.c:(.text.startup+0xabe): undefined reference to `BZ2_bzWriteOpen'
bsdiff.c:(.text.startup+0xae9): undefined reference to `BZ2_bzWrite'
bsdiff.c:(.text.startup+0xb0f): undefined reference to `BZ2_bzWriteClose'
bsdiff.c:(.text.startup+0xb61): undefined reference to `BZ2_bzWriteOpen'
bsdiff.c:(.text.startup+0xb8c): undefined reference to `BZ2_bzWrite'
bsdiff.c:(.text.startup+0xbb2): undefined reference to `BZ2_bzWriteClose'
collect2: ld 返回 1
make: *** [bsdiff] 错误 1
/dev/android4.4/external/bsdiff$ mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4
TARGET_PRODUCT=aosp_flo
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=krait
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.2.0-59-generic-x86_64-with-Ubuntu-12.04-precise
HOST_BUILD_TYPE=release
BUILD_ID=KRT16O
OUT_DIR=out
============================================
make:进入目录'/android4.4'
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/camera_click.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/camera_click.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/camera_focus.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/camera_focus.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/Effect_Tick.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/Effect_Tick.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/KeypressDelete.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/KeypressDelete.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/KeypressReturn.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/KeypressReturn.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/KeypressSpacebar.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/KeypressSpacebar.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/KeypressStandard.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/KeypressStandard.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/Lock.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/Lock.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/LowBattery.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/LowBattery.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/Unlock.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/Unlock.ogg”的旧命令
build/core/Makefile:32: 警告:覆盖关于目标“out/target/product/flo/system/media/audio/ui/VideoRecord.ogg”的命令
build/core/Makefile:32: 警告:忽略关于目标“out/target/product/flo/system/media/audio/ui/VideoRecord.ogg”的旧命令
No private recovery resources for TARGET_DEVICE flo
Import includes file: out/host/linux-x86/obj/EXECUTABLES/bspatch_intermediates/import_includes
host C: bspatch <= external/bsdiff/bspatch.c
Export includes file: external/bsdiff/Android.mk -- out/host/linux-x86/obj/EXECUTABLES/bspatch_intermediates/export_includes
host Executable: bspatch (out/host/linux-x86/obj/EXECUTABLES/bspatch_intermediates/bspatch)
Install: out/host/linux-x86/bin/bspatch
make:离开目录“/android4.4”
OK,编译成功了,那么去对应的目录发现,在out/host/linux-x86/bin/目录下,已经有编译好的bsdiff,bspatch了,还有很多其它的工具,但是我们暂且不看。
然后我用一个应用的两个版本的APK测试一下了!补一句,如果你在window下测试的话,其实更方便,这个网址,http://blog.csdn.net/hmg25/article/details/8100896,里面有windows的测试工具和命令。
命令如下(中间的总是新版本的APK,最后总是差分patch):
- bsdiff iReader1.6.2.0(v35).apk iReader1.8.0.1(v40).apk ireader.patch
- bspatch iReader1.6.2.0(v35).apk new.apk ireader.patch
比如:
A:代表1.0版本
B:代表2.0版本
C:代表差分包
D:用A,C生成的新版本,其实就是B
1.用bsdiff生成差分patch(C):发现确实包小了很多
2.用bspatch:用老版本apk(A),刚刚生成的patch(C),生成新版本的apk(D),发现新版本的APK(D)和最原始的APK(B)的大小是一样的
3.用md5sum 和sha1sum校验了一下新生成的APK(D),与最原始的版本(B)相比,发现2个值都分别相等
最后补充一下,校验md5sum, sha1sum 有什么用呢?md5sum 和 sha1sum 二者多用于计算某个文件的hash值,其实我也没搞懂,参考一下:
http://blog.sina.com.cn/s/blog_609dd4970101011f.html
http://www.pvsky.com/blog/20121003/457.html
太强大了,牛逼~
其实不只用于APK的更新,其它的比如:zip等的更新都可以用这个,因为是二进制的差分么。
附带2个bsdiff, bspatch工具,如果你没有android源码的话,确实这2个工具很难找,我在ubuntu linxu64位下编译的:见这个网址:
http://download.csdn.net/detail/song_shi_chao/7035557