From fb8d4cea7b6f5466546a29f0a9b964c1a83c810f Mon Sep 17 00:00:00 2001 From: Kelson Date: Tue, 1 Aug 2017 23:00:46 +0200 Subject: [PATCH 1/3] Small perl script to build custom app manually --- build_custom_app.pl | 92 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 build_custom_app.pl diff --git a/build_custom_app.pl b/build_custom_app.pl new file mode 100755 index 0000000..59b2ae5 --- /dev/null +++ b/build_custom_app.pl @@ -0,0 +1,92 @@ +#!/usr/bin/perl + +use utf8; +use strict; +use warnings; +use Getopt::Long; + +# get the params +my $zim_url; +my $custom_app; +my $keystore; +my $api_key; +my $cmd; + +# Get console line arguments +GetOptions('zim_url=s' => \$zim_url, + 'custom_app=s' => \$custom_app, + 'keystore=s' => \$keystore, + 'api_key=s' => \$api_key + ); + +# Print usage() if necessary +if (!$zim_url || !$custom_app || !$keystore || !$api_key) { + print "usage: ./build_custom_app.pl --keystore=kiwix-android.keystore --api_key=google.json --zim_url=\"https://download.kiwix.org/zim/wikipedia_en_medicine_novid.zim\" --custom_app=wikimed\n"; + exit; +} + +# Download ZIM file +#$cmd = "wget \"$zim_url\" -O content.zim"; `$cmd`; + +# Get ZIM file size +$cmd = "stat -c %s content.zim"; +my $zim_size = `$cmd` =~ s/\n//gr ; +$ENV{ZIM_SIZE} = $zim_size; + +# Compute version code base +$cmd = "date +%y%j"; +my $version_code_base = `$cmd` =~ s/\n//gr . "0"; + +# Compute content version code +my $content_version_code = "0" . $version_code_base; +$ENV{CONTENT_VERSION_CODE} = $content_version_code; + +# Compute custom app date +$cmd = "date +%Y-%m"; +my $date = `$cmd` =~ s/\n//gr; +$ENV{VERSION_NAME} = $date; + +# Compile apps +$ENV{VERSION_CODE} = "0" . $version_code_base; +$cmd = "./kiwix-build.py --target-platform android_arm --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; + +$ENV{VERSION_CODE} = "1" . $version_code_base; +$cmd = "./kiwix-build.py --target-platform android_arm64 --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; + +$ENV{VERSION_CODE} = "2" . $version_code_base; +$cmd = "./kiwix-build.py --target-platform android_x86 --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; + +$ENV{VERSION_CODE} = "3" . $version_code_base; +$cmd = "./kiwix-build.py --target-platform android_x86_64 --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; + +$ENV{VERSION_CODE} = "4" . $version_code_base; +$cmd = "./kiwix-build.py --target-platform android_mips --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; + +$ENV{VERSION_CODE} = "5" . $version_code_base; +$cmd = "./kiwix-build.py --target-platform android_mips64 --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; + +# Sign apps +$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-0${version_code_base}-release-signed.apk BUILD_android_arm/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; +system $cmd; + +$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-1${version_code_base}-release-signed.apk BUILD_android_arm64/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; +system $cmd; + +$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-2${version_code_base}-release-signed.apk BUILD_android_x86/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; +system $cmd; + +$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-3${version_code_base}-release-signed.apk BUILD_android_x86_64/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; +system $cmd; + +$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-4${version_code_base}-release-signed.apk BUILD_android_mips/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; +system $cmd; + +$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-5${version_code_base}-release-signed.apk BUILD_android_mips64/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; +system $cmd; + +# Upload + +$cmd = "./build_custom_app.py --step publish --custom-app ${custom_app} --google-api-key ${api_key} --zim-path content.zim --apks-dir signed_apks --content-version-code ${content_version_code}"; +system $cmd; + +exit; From 76362a6caf9553eda9fe74a9de7dfc8802e37b3a Mon Sep 17 00:00:00 2001 From: Kelson Date: Wed, 2 Aug 2017 19:34:01 +0200 Subject: [PATCH 2/3] Fix VERSION_CODE and CONTENT_VERSION_CODE --- build_custom_app.pl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build_custom_app.pl b/build_custom_app.pl index 59b2ae5..8d63863 100755 --- a/build_custom_app.pl +++ b/build_custom_app.pl @@ -25,8 +25,11 @@ if (!$zim_url || !$custom_app || !$keystore || !$api_key) { exit; } +# Clean signed ap +$cmd = "rm ./signed_apks/*apk"; `$cmd`; + # Download ZIM file -#$cmd = "wget \"$zim_url\" -O content.zim"; `$cmd`; +$cmd = "wget \"$zim_url\" -O content.zim"; `$cmd`; # Get ZIM file size $cmd = "stat -c %s content.zim"; @@ -38,7 +41,7 @@ $cmd = "date +%y%j"; my $version_code_base = `$cmd` =~ s/\n//gr . "0"; # Compute content version code -my $content_version_code = "0" . $version_code_base; +my $content_version_code = $version_code_base; $ENV{CONTENT_VERSION_CODE} = $content_version_code; # Compute custom app date @@ -47,7 +50,7 @@ my $date = `$cmd` =~ s/\n//gr; $ENV{VERSION_NAME} = $date; # Compile apps -$ENV{VERSION_CODE} = "0" . $version_code_base; +$ENV{VERSION_CODE} = $version_code_base; $cmd = "./kiwix-build.py --target-platform android_arm --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; $ENV{VERSION_CODE} = "1" . $version_code_base; @@ -66,7 +69,7 @@ $ENV{VERSION_CODE} = "5" . $version_code_base; $cmd = "./kiwix-build.py --target-platform android_mips64 --android-custom-app $custom_app --zim-file-size $zim_size kiwix-android-custom"; system $cmd; # Sign apps -$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-0${version_code_base}-release-signed.apk BUILD_android_arm/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; +$cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-${version_code_base}-release-signed.apk BUILD_android_arm/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; system $cmd; $cmd = "./TOOLCHAINS/android-sdk-r25.2.3/build-tools/25.0.2/apksigner sign -ks \"${keystore}\" --out signed_apks/app-1${version_code_base}-release-signed.apk BUILD_android_arm64/kiwix-android-custom_${custom_app}/app/build/outputs/apk/app-${custom_app}-release-unsigned.apk"; From ba48334e48eae65a1fc6587433316fab129363f8 Mon Sep 17 00:00:00 2001 From: Kelson Date: Wed, 2 Aug 2017 22:25:57 +0200 Subject: [PATCH 3/3] Add option --version --- build_custom_app.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build_custom_app.pl b/build_custom_app.pl index 8d63863..5985652 100755 --- a/build_custom_app.pl +++ b/build_custom_app.pl @@ -10,18 +10,20 @@ my $zim_url; my $custom_app; my $keystore; my $api_key; +my $version = "0"; my $cmd; # Get console line arguments GetOptions('zim_url=s' => \$zim_url, - 'custom_app=s' => \$custom_app, + 'custom_app=s' => \$custom_app, 'keystore=s' => \$keystore, - 'api_key=s' => \$api_key + 'api_key=s' => \$api_key, + 'version=s' => \$version ); # Print usage() if necessary if (!$zim_url || !$custom_app || !$keystore || !$api_key) { - print "usage: ./build_custom_app.pl --keystore=kiwix-android.keystore --api_key=google.json --zim_url=\"https://download.kiwix.org/zim/wikipedia_en_medicine_novid.zim\" --custom_app=wikimed\n"; + print "usage: ./build_custom_app.pl --keystore=kiwix-android.keystore --api_key=google.json --zim_url=\"https://download.kiwix.org/zim/wikipedia_en_medicine_novid.zim\" --custom_app=wikimed [--version=1]\n"; exit; } @@ -38,7 +40,7 @@ $ENV{ZIM_SIZE} = $zim_size; # Compute version code base $cmd = "date +%y%j"; -my $version_code_base = `$cmd` =~ s/\n//gr . "0"; +my $version_code_base = `$cmd` =~ s/\n//gr . $version; # Compute content version code my $content_version_code = $version_code_base; @@ -46,7 +48,7 @@ $ENV{CONTENT_VERSION_CODE} = $content_version_code; # Compute custom app date $cmd = "date +%Y-%m"; -my $date = `$cmd` =~ s/\n//gr; +my $date = `$cmd` =~ s/\n//gr; $ENV{VERSION_NAME} = $date; # Compile apps