Created
June 30, 2016 08:35
-
-
Save 2BAB/c91895550313025656a3a99b611d0fba to your computer and use it in GitHub Desktop.
easy-andfix.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
new_apk_path= | |
old_apk_link= | |
keystore_link= | |
keystore_password= | |
key_alias= | |
key_password= | |
usage() | |
{ | |
echo "Usage: easy-andfix.sh [-f new.apk's local path] [-t old.apk's http link] [-k .jks|.keystore] [-p keystorePassword] [-a keyAlias] [-e keyPassword]" | |
exit 1 | |
} | |
[ $# -eq 0 ] && usage | |
while getopts :f:t:k:p:a:e: OPTION | |
do | |
case $OPTION in | |
f) | |
new_apk_path=$OPTARG | |
;; | |
t) | |
old_apk_link=$OPTARG #$OPTARG为特殊变量,表示选项的具体参数 | |
;; | |
k) | |
keystore_link=$OPTARG | |
;; | |
p) | |
keystore_password=$OPTARG | |
;; | |
a) | |
key_alias=$OPTARG | |
;; | |
e) | |
key_password=$OPTARG | |
;; | |
\?) #如果出现错误,则解析为? | |
usage | |
;; | |
esac | |
done | |
apk_nun=`echo | find ./app/build/outputs/apk -name "*.apk" | wc -l` | |
if [ $apk_nun -gt 1 ] | |
then | |
echo "[Error]the new apk is more than one" | |
exit 1 | |
fi | |
new_apk=`echo | find $new_apk_path -name "*.apk"` | |
echo "download $old_apk_link" | |
curl -o old.apk $old_apk_link | |
echo "download $keystore_link" | |
curl -o keystore.jks $keystore_link | |
echo "download apkpatch from mirror" | |
git clone http://gitlab-sc.alibaba-inc.com/bingquan.zbq/apkpatch-mirror.git | |
echo "diff apk to create patch file" | |
sh ./apkpatch-mirror/apkpatch.sh -f $new_apk -t old.apk -o ./diff -k keystore.jks -p $keystore_password -a $key_alias -e $key_password | |
apatch=`echo | find ./diff -name "*.apatch"` | |
mv $apatch ./diff/apatch.jar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment