From 799ef3380df9f9ce146dea60c3020ee26751948a Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 30 Oct 2016 19:32:36 +0800 Subject: [PATCH] Update build script --- .gitignore | 2 +- build.sh | 47 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index ede55e996..b69749855 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ zip_static/common/magic_mask.sh zip_static/META-INF/com/google/android/update-binary # Leave all busybox! -!busybox \ No newline at end of file +!busybox diff --git a/build.sh b/build.sh index 82f357c72..7d9662250 100755 --- a/build.sh +++ b/build.sh @@ -1,16 +1,16 @@ #!/bin/bash usage() { - echo "$0 --all " + echo "$0 all " echo -e "\tBuild binaries, zip, and sign Magisk" echo -e "\tThis is equlivant to first --build, then --zip" - echo "$0 --clean" + echo "$0 clean" echo -e "\tCleanup compiled / generated files" - echo "$0 --build" + echo "$0 build" echo -e "\tBuild the binaries with ndk" - echo "$0 --zip " + echo "$0 zip " echo -e "\tZip and sign Magisk" - echo "$0 --uninstaller" + echo "$0 uninstaller" echo -e "\tZip and sign the uninstaller" exit 1 } @@ -56,14 +56,18 @@ build_bin() { } zip_package() { + if [ ! -f "zip_static/arm/bootimgtools" ]; then + echo "! Missing binaries!!" + echo "! Please run \"$0 build\" before zipping" + exit 1 + fi echo "************************" echo "* Adding version info" - echo "* \"Magisk v$1\"" echo "************************" sed "s/MAGISK_VERSION_STUB/Magisk v$1 Boot Image Patcher/g" scripts/flash_script.sh > zip_static/META-INF/com/google/android/update-binary sed "s/MAGISK_VERSION_STUB/setprop magisk.version $1/g" scripts/magic_mask.sh > zip_static/common/magic_mask.sh echo "************************" - echo "* Zipping the package" + echo "* Zipping Magisk v$1" echo "************************" cd zip_static find . -type f -exec chmod 644 {} \; @@ -74,6 +78,25 @@ zip_package() { sign_zip "Magisk-v$1.zip" } +zip_uninstaller() { + if [ ! -f "uninstaller/arm/bootimgtools" ]; then + echo "! Missing binaries!!" + echo "! Please run \"$0 build\" before zipping" + exit 1 + fi + echo "************************" + echo "* Zipping uninstaller" + echo "************************" + cd uninstaller + find . -type f -exec chmod 644 {} \; + find . -type d -exec chmod 755 {} \; + TIMESTAMP=$(date "+%Y%m%d") + rm -rf "../Magisk-uninstaller-$TIMESTAMP.zip" + zip "../Magisk-uninstaller-$TIMESTAMP.zip" -r . + cd ../ + sign_zip "Magisk-uninstaller-$TIMESTAMP.zip" +} + sign_zip() { if [ ! -f "zipsigntools/zipadjust" ]; then echo "************************" @@ -103,22 +126,22 @@ DIR="$(cd "$(dirname "$0")"; pwd)" cd "$DIR" case $1 in - "--all" ) + "all" ) [ -z "$2" ] && echo -e "! Missing version number\n" && usage build_bin zip_package $2 ;; - "--clean" ) + "clean" ) cleanup ;; - "--build" ) + "build" ) build_bin ;; - "--zip" ) + "zip" ) [ -z "$2" ] && echo -e "! Missing version number\n" && usage zip_package $2 ;; - "--uninstaller" ) + "uninstaller" ) zip_uninstaller ;; * )