From 4e0e769e9060a5ff31cb0ae6eed7b7f3d908ee30 Mon Sep 17 00:00:00 2001 From: renaud gaudin Date: Sun, 7 Jun 2015 22:48:53 +0200 Subject: [PATCH] minor fixes --- create-signed-android-release.sh | 20 ++++++++++++++++---- gen-custom-android-build.py | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/create-signed-android-release.sh b/create-signed-android-release.sh index c38eee85d..9ef27c30c 100755 --- a/create-signed-android-release.sh +++ b/create-signed-android-release.sh @@ -21,10 +21,22 @@ function die { exit 1 } +if [ "x$2" = "x" ]; + then + PACKAGE=`python -c "from xml.dom.minidom import parse; d=parse('AndroidManifest.xml'); print([e.getAttribute('package').strip() for e in d.getElementsByTagName('manifest')][-1])"` +else + PACKAGE=$2 +fi + +if [ "x$3" = "x" ]; + then + APP_VERSION=`python -c "from xml.dom.minidom import parse; d=parse('AndroidManifest.xml'); print([e.getAttribute('android:versionName').strip() for e in d.getElementsByTagName('manifest')][-1])"` +else + APP_VERSION=$3 +fi + # default values are guessed from repo (AndroidManifest and res/values/branding) APP_NAME=`python -c "from xml.dom.minidom import parse; d=parse('res/values/branding.xml'); print([e.childNodes[0].data.strip() for e in d.getElementsByTagName('string') if e.getAttribute('name') == 'app_name'][-1])"` -PACKAGE=`python -c "from xml.dom.minidom import parse; d=parse('AndroidManifest.xml'); print([e.getAttribute('package').strip() for e in d.getElementsByTagName('manifest')][-1])"` -APP_VERSION=`python -c "from xml.dom.minidom import parse; d=parse('AndroidManifest.xml'); print([e.getAttribute('android:versionName').strip() for e in d.getElementsByTagName('manifest')][-1])"` TARGET_VERSION=`grep "compileSdkVersion" build.gradle | awk '{print $2}'` BUILD_VERSION=`grep "buildToolsVersion" build.gradle | awk '{print $2}' | sed 's/"//g'` @@ -47,7 +59,7 @@ fi jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore $CERTIFICATE build/outputs/apk/${PACKAGE}-release-unsigned.apk kiwix || die "Error signing the package." jarsigner -verify build/outputs/apk/${PACKAGE}-release-unsigned.apk || die "The package is not properly signed." -../src/dependencies/android-sdk/build-tools/${BUILD_VERSION}/zipalign -f -v 4 build/outputs/apk/${PACKAGE}-release-unsigned.apk "${APP_NAME}-${APP_VERSION}.apk" || die "Could not zipalign the signed package. Please check." +../src/dependencies/android-sdk/build-tools/${BUILD_VERSION}/zipalign -f -v 4 build/outputs/apk/${PACKAGE}-release-unsigned.apk build/outputs/apk/${PACKAGE}-${APP_VERSION}.apk || die "Could not zipalign the signed package. Please check." echo "[SUCCESS] Your signed release package is ready:" -ls -lh "${APP_NAME}-${APP_VERSION}.apk" +ls -lh build/outputs/apk/${PACKAGE}-${APP_VERSION}.apk diff --git a/gen-custom-android-build.py b/gen-custom-android-build.py index b386e2a59..df447bfcd 100755 --- a/gen-custom-android-build.py +++ b/gen-custom-android-build.py @@ -497,8 +497,8 @@ ARGS_MATRIX = OrderedDict([ ('gradle', step_update_gradle), ('build', step_build_apk), ('move', step_move_apk_to_destination), - ('clean', step_remove_android_placeholder), ('list', step_list_output_apk), + ('clean', step_remove_android_placeholder), ])