Pier Angelo Vendrame pushed to branch main at The Tor Project / Applications / tor-browser-build
Commits: 47f3949c by Beatriz Rizental at 2025-01-13T16:21:37+01:00 Bug 41342 - Build test artifacts for Android
- - - - -
4 changed files:
- projects/browser/build.android - projects/geckoview/build_ac_fenix - projects/geckoview/config - projects/geckoview/gradle-dependencies-list.txt
Changes:
===================================== projects/browser/build.android ===================================== @@ -4,19 +4,13 @@
tar -xf $rootdir/[% c('input_files_by_name/fenix') %]
-assets_dir=assets -ext_dir=$assets_dir/extensions -qa_apk=[% dest_dir %]/[% c('filename') %]/[% c("var/project-name") %]-qa-[% c("var/osname") %]-[% c("version") %].apk -apk=$rootdir/geckoview/*-[% c("var/abi") %]-*.apk - -# tor-browser-build#40920 -sorted_baseline_apk=$(basename $apk .apk)_sorted_baseline.apk -$rootdir/sort-baseline.py --apk $apk $sorted_baseline_apk -mv $sorted_baseline_apk $apk - # Bundle our extension(s). +# # NoScript will be copied over to the profile folder # as a "regular" browser extension receiving regular AMO updates. +assets_dir=assets +ext_dir=$assets_dir/extensions + noscript_path="$ext_dir/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
mkdir -p /var/tmp/build/$ext_dir [% dest_dir _ '/' _ c('filename') %] @@ -34,43 +28,93 @@ popd [%IF c("var/tor-browser") -%] tar -xaf "$rootdir/[% c("input_files_by_name/tor-expert-bundle") %]/tor-expert-bundle.tar.gz" tor/pluggable_transports/pt_config.json [% END -%] -unzip -j "$apk" assets/omni.ja -mkdir omni -pushd omni -unzip ../omni.ja -[%IF c("var/tor-browser") -%] - cp -a ../tor/pluggable_transports/pt_config.json chrome/toolkit/content/global/pt_config.json -[% END -%] -[% c('zip', { + +# This function generates a signed APK from a given APK file. +# +# Arguments: +# $1 - The final APK file name. +# $2 - The input APK file. +# $3 - [Optional] The patch file for the unsigned APK. +# +# Steps: +# 1. Sort the baseline APK. +# 2. Extract the omni.ja file from the APK and modify its contents. +# 3. Repack the APK with the modified omni.ja file. +# 4. Align the APK using zipalign. +# 5. Sign the APK using apksigner. +# 6. [Optional] Generate a patch file for the unsigned APK using bsdiff. +function generate_apk { + local final_apk=$1 + local apk=$2 + + # tor-browser-build#40920 + sorted_baseline_apk=$(basename $apk .apk)_sorted_baseline.apk + $rootdir/sort-baseline.py --apk $apk $sorted_baseline_apk + mv $sorted_baseline_apk $apk + + unzip -j "$apk" assets/omni.ja + mkdir omni + pushd omni + unzip ../omni.ja + [%IF c("var/tor-browser") -%] + cp -an ../tor/pluggable_transports/pt_config.json chrome/toolkit/content/global/pt_config.json + [% END -%] + [% c('zip', { zip_src => [ '.' ], zip_args => '-0 ../assets/omni.ja', }) %] -popd + popd
-mkdir apk -pushd apk -7zz x "$apk" -cp -R ../assets ./ -find -type f -exec touch -m -t '[% USE date; date.format(pc("geckoview", "timestamp"), format = "%Y%m%d%H%M") %]' {} ; -find -type f ! -name resources.arsc -printf '%P\n' | sort > ../files.txt -7zz a -tzip -mx9 -mtc- -spf ../repacked.apk @../files.txt -# resources.arsc must not be compressed as per the APK specifications -7zz a -tzip -mm=Copy -mtc- ../repacked.apk resources.arsc -popd + mkdir apk + pushd apk + 7zz x "$apk" + cp -Rn ../assets ./ + find -type f -exec touch -m -t '[% USE date; date.format(pc("geckoview", "timestamp"), format = "%Y%m%d%H%M") %]' {} ; + find -type f ! -name resources.arsc -printf '%P\n' | sort > ../files.txt + 7zz a -tzip -mx9 -mtc- -spf ../repacked.apk @../files.txt + # resources.arsc must not be compressed as per the APK specifications + 7zz a -tzip -mm=Copy -mtc- ../repacked.apk resources.arsc + popd + + aligned_apk=$(basename $apk .apk)_aligned.apk + zipalign -vp 4 repacked.apk $aligned_apk
-aligned_apk=$(basename $apk .apk)_aligned.apk -zipalign -vp 4 repacked.apk $aligned_apk + # Sign a QA build. This .apk is not a debug version and doesn't contain a debug + # flag in the manifest. + apksigner sign --verbose --min-sdk-version [% c("var/android_min_api") %] --ks $rootdir/android-qa.keystore --out $final_apk --in $aligned_apk --ks-key-alias androidqakey --key-pass pass:android --ks-pass pass:android + + local unsign_patch=$3 + if [ -n "$unsign_patch" ]; then + bsdiff $final_apk $aligned_apk $unsign_patch + fi + + # Clean up + rm -rf omni + rm omni.ja + rm -rf apk + rm repacked.apk + rm $aligned_apk +} + +# Generate the QA APK and unsign patch. +qa_apk=[% dest_dir %]/[% c('filename') %]/[% c("var/project-name") %]-qa-[% c("var/osname") %]-[% c("version") %].apk +qa_unsign_patch="[% dest_dir %]/[% c('filename') %]/[% c('var/project-name') %]-qa-unsign-[% c('var/osname') %]-[% c('version') %].bspatch" +apk=$rootdir/geckoview/*-[% c("var/abi") %]-*.apk +generate_apk $qa_apk $apk $qa_unsign_patch
-# Sign a QA build. This .apk is not a debug version and doesn't contain a debug -# flag in the manifest. -apksigner sign --verbose --min-sdk-version [% c("var/android_min_api") %] --ks $rootdir/android-qa.keystore --out $qa_apk --in $aligned_apk --ks-key-alias androidqakey --key-pass pass:android --ks-pass pass:android +# Generate the non-optimized APK used for testing and its unsign patch. +noopt_apk=[% dest_dir %]/[% c('filename') %]/[% c("var/project-name") %]-noopt-[% c("var/osname") %]-[% c("version") %].apk +noopt_final_apk=$rootdir/geckoview/tests/*-[% c("var/abi") %]-*.apk +generate_apk $noopt_apk $noopt_final_apk
-unsign_patch="[% dest_dir %]/[% c('filename') %]/[% c('var/project-name') %]-qa-unsign-[% c('var/osname') %]-[% c('version') %].bspatch" -bsdiff $qa_apk $aligned_apk $unsign_patch +# Copy and sign the Android test APK. +test_apk=[% dest_dir %]/[% c('filename') %]/[% c("var/project-name") %]-[% c("version") %]-androidTest.apk +cp $rootdir/geckoview/tests/*-androidTest.apk $test_apk +apksigner sign --verbose --min-sdk-version [% c("var/android_min_api") %] --ks $rootdir/android-qa.keystore --out $test_apk --in $test_apk --ks-key-alias androidqakey --key-pass pass:android --ks-pass pass:android
[%IF c("var/tor-browser") -%] - tor_expert_bundle_src="[% c('input_files_by_name/tor-expert-bundle') %]" - # strip off trailing "$buildid.tar.gz" - tor_expert_bundle_dest=${tor_expert_bundle_src:0:-7}.tar.gz - cp "$rootdir/[% c("input_files_by_name/tor-expert-bundle") %]/tor-expert-bundle.tar.gz" [% dest_dir %]/[% c('filename') %]/$tor_expert_bundle_dest + tor_expert_bundle_src="[% c('input_files_by_name/tor-expert-bundle') %]" + # strip off trailing "$buildid.tar.gz" + tor_expert_bundle_dest=${tor_expert_bundle_src:0:-7}.tar.gz + cp "$rootdir/[% c("input_files_by_name/tor-expert-bundle") %]/tor-expert-bundle.tar.gz" [% dest_dir %]/[% c('filename') %]/$tor_expert_bundle_dest [% END -%]
===================================== projects/geckoview/build_ac_fenix ===================================== @@ -45,12 +45,24 @@ echo 'ext.gleanBuildDate = "0"' >> app/build.gradle variant='[% c("var/variant") %]' version_name="[% c('var/torbrowser_version') %] ([% c('var/geckoview_version') %])"
+echo "Building $variant Fenix APK" gradle $GRADLE_FLAGS -PversionName="$version_name" "assemble$variant"
echo "Build finished, copying the APK(s) to the destination directory $(date)" - mkdir $distdir/[% project %] cp app/build/outputs/apk/fenix/$variant/*.apk $distdir/[% project %]
+echo "Building non optimized $variant Fenix APK for testing" +gradle $GRADLE_FLAGS -PversionName="$version_name" -PdisableOptimization "assemble$variant" + +echo "Building Fenix instrumentation tests" +gradle $GRADLE_FLAGS -PversionName="$version_name" -PtestBuildType="$variant" -PdisableOptimization assembleAndroidTest + +echo "Test build finished, copying the APKs to the destination directory $(date)" + +mkdir $distdir/[% project %]/tests +cp app/build/outputs/apk/fenix/$variant/*.apk $distdir/[% project %]/tests +cp app/build/outputs/apk/androidTest/fenix/$variant/*.apk $distdir/[% project %]/tests + popd
===================================== projects/geckoview/config ===================================== @@ -36,7 +36,7 @@ var: - openjdk-17-jdk-headless # this should be updated when the list of gradle dependencies is changed # see doc/how-to-create-gradle-dependencies-list.txt - gradle_dependencies_version: 15 + gradle_dependencies_version: 16 gradle_version: 8.8 glean_parser: 14.0.1 variant: beta
===================================== projects/geckoview/gradle-dependencies-list.txt ===================================== @@ -2929,3 +2929,44 @@ e4ff4338999e1c6c9c724719f5d4aa7dd61bf6f545d5256a27a9d375df9f2330 | https://maven a9fb0b39a8360beef7bdc8f3953d4d78f3d85304fc80adac3c8eaf530d758050 | https://maven.google.com/androidx/lifecycle/lifecycle-viewmodel/2.6.2/lifecy... f34831b6c71cd844e1d35d1be49d5e79447c5ab856346531b1e8676fda7374b1 | https://maven.google.com/androidx/lifecycle/lifecycle-common/2.6.2/lifecycle... 57304cdac4da289a6ecdd0738e16b1d8858f1ef8e9fabe2d65a963719fd81dba | https://maven.google.com/androidx/lifecycle/lifecycle-common/2.6.2/lifecycle... +caa72885d1ce7979c1d6c59a8b255c6097b770780d4d4da95d56979a348646cd | https://maven.google.com/androidx/activity/activity-compose/1.7.0/activity-c... +85e1fe770ed673ecb8552eaadc23b96d8db0a14a10eaa7789518496e5d99362c | https://maven.google.com/androidx/arch/core/core-testing/2.2.0/core-testing-... +89536d9f0763e268fc9504fffeada04d483b36fe46f8c6eff5ee64642e36539f | https://maven.google.com/androidx/arch/core/core-testing/2.2.0/core-testing-... +9a4a6e4c9ed089619306f21853a82e7ceeefd38fa69534f2b45a931b2ec827ae | https://maven.google.com/androidx/compose/ui/ui-test-manifest/1.6.7/ui-test-... +dd61a9738e9eea4691bd7ade9e2cb8acb4f0cb73e048d8611edaa118d032235a | https://maven.google.com/androidx/compose/ui/ui-test-manifest/1.6.7/ui-test-... +ea66d01428a8c8f26a0ee2259a96d7763dd0d3aef5321730790f8e9cfbe28360 | https://maven.google.com/androidx/room/room-testing/2.6.1/room-testing-2.6.1... +b39a4b9e96b9e5d51b06e4438b182d9ef0f1f91f9338abe1fd0aa45946929968 | https://maven.google.com/androidx/room/room-testing/2.6.1/room-testing-2.6.1... +9e672028617979dab465678efdd1650b53c929634c399b1f5fef28252483684d | https://maven.google.com/androidx/test/espresso/espresso-core/3.5.0/espresso... +34b0493f4e002f205d961e562add0c0c31bb0acc657e89d89d4b188ac13f242c | https://maven.google.com/androidx/test/espresso/espresso-core/3.5.0/espresso... +109eec25d79146122fcdaea91d27ab6e437ccd1aec54eb8e4ac23b23f4011deb | https://maven.google.com/androidx/test/espresso/espresso-idling-resource/3.5... +84fb8e2f5eda937771bee28582f5d2cfa61b0e9438d02041ca61b81e3dac3c87 | https://maven.google.com/androidx/test/espresso/espresso-idling-resource/3.5... +b3c5aabd545b6c260528c8f4e7c98f73628614ea3d5df3a7a44af2136fd8720b | https://maven.google.com/androidx/test/runner/1.5.0/runner-1.5.0.aar +909882bb86a8618f307d439ead4545cf74f54d3dc6088c232e1bab4f9a97f6cc | https://maven.google.com/androidx/test/runner/1.5.0/runner-1.5.0.pom +914d8c83aa16455d431b5b3af306cef0eb0a0bfd6550d097e39ad475435bf56c | https://maven.google.com/androidx/tracing/tracing-ktx/1.1.0/tracing-ktx-1.1.... +2f2ee5c58561d72cabe9207c43669fe92d6c1386f8c1c2624489e6ab367b121e | https://maven.google.com/androidx/tracing/tracing-perfetto-handshake/1.0.0/t... +5b78e2c618fc10b3d14decc01df76158f15954ad746aacf0607766721da081f6 | https://maven.google.com/androidx/tracing/tracing/1.1.0/tracing-1.1.0.aar +f1db502b5d539d94dfb6c659deb76872b1e9d8266d7aa4083868a29c33c22917 | https://maven.google.com/androidx/tracing/tracing/1.1.0/tracing-1.1.0.pom +38c45cdaf993a7df6697703ca6ee00acbe376d3dade8d44daac3e33f039ca516 | https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotation/... +1faf214c94723ab9fbadfedd9af88ddc325faf669e68eab04688c3afcf59c037 | https://repo1.maven.org/maven2/com/google/guava/guava/28.2-android/guava-28.... +b29c1c21e52ed6238cd3fed39d880a17ecf2360118604548cea8821be6801e1c | https://repo1.maven.org/maven2/com/jakewharton/android/repackaged/dalvik-dx/... +7ed7862122ecff00f9c582a61a83397f549f92f347825eca8bb7ad94aef7e92d | https://repo1.maven.org/maven2/com/linkedin/dexmaker/dexmaker/2.28.3/dexmake... +90bb885e3f0a3546e4670ea2b66f291319dff0c6878e8aaead0abf3268934b5a | https://repo1.maven.org/maven2/com/squareup/leakcanary/leakcanary-android-in... +a901efac8b81a6f9fe6c970708e353bd4bd1da03b929dfac01a7617b2d4fea31 | https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp-urlconnection/4.1... +11d134b245e9cacc474514d2d66b5b8618f8039a1465cdc55bbc0b34e0008b7a | https://repo1.maven.org/maven2/org/checkerframework/checker-compat-qual/2.5.... +164fe9728cf95a2cdea93e257d0dc3d5e29f29256b3cca900a8e619bc94d5b1f | https://repo1.maven.org/maven2/org/checkerframework/checker-qual/2.5.5/check... +eaf537d98e033d0f0451cd1b8cc74e02d7b55ec882da63c88060d806ba89c348 | https://repo1.maven.org/maven2/org/conscrypt/conscrypt-openjdk-uber/2.5.2/co... +8a835f5176355083668aff0ed6eef5b3eb030e10e89679ed3eeb703fd2d5b900 | https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.9.10/ko... +1f9b6f110f498bb5796cbe2cdd36a83ae242619c816821db23ed088a30347b4a | https://repo1.maven.org/maven2/org/jsoup/jsoup/1.12.2/jsoup-1.12.2.jar +1808ee87e0f718cd6e25f3b75afc17956ac8a3edc48c7e9bab9f19f9a79e3801 | https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-api/5.8.2/jun... +753b7726cdd158bb34cedb94c161e2291896f47832a1e9eda53d970020a8184e | https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-engine/5.8.2/... +d1c22d6fe5483568c08c8913f34abd2303490c3480ce6c18a2ea31c65e44102a | https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-params/5.8.2/... +4f5c1cc6432244cd16e36aa0e02b74bce34a81ff95a13d63d50951ec4ce3f4bd | https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter/5.8.2/junit-j... +d2e015fca7130e79af2f4608dc54415e4b10b592d77333decb4b1a274c185050 | https://repo1.maven.org/maven2/org/junit/platform/junit-platform-commons/1.8... +0b7d000f8c3e8e5f7d6b819649936e7b9938314e87c8f983805218ea57567e59 | https://repo1.maven.org/maven2/org/junit/platform/junit-platform-engine/1.8.... +28028d70cc27d61442948fcb3d249d9df5b37c47aa0b82490a3d049094ff411f | https://repo1.maven.org/maven2/org/mockito/mockito-core/2.25.0/mockito-core-... +5a841dd993e6fd310f08e62df4bdc3eddd9a25245a87650fac99fbff01607d3e | https://repo1.maven.org/maven2/org/mockito/mockito-core/2.25.0/mockito-core-... +3825feca2a3c176400b063dec7c6b0643e2b5256bbbfd4e0a7c11e0dd0983baa | https://repo1.maven.org/maven2/org/objenesis/objenesis-parent/2.6/objenesis-... +5e168368fbc250af3c79aa5fef0c3467a2d64e5a7bd74005f25d8399aeb0708d | https://repo1.maven.org/maven2/org/objenesis/objenesis/2.6/objenesis-2.6.jar +4c1307909dc62df1bd91f075503f8bdef5ae445e13353f1752af9448bea1d3f1 | https://repo1.maven.org/maven2/org/objenesis/objenesis/2.6/objenesis-2.6.pom +58812de60898d976fb81ef3b62da05c6604c18fd4a249f5044282479fc286af2 | https://repo1.maven.org/maven2/org/opentest4j/opentest4j/1.2.0/opentest4j-1.... +5be3bd2a9d6cee0ea930fb3a92c4585c87524b2ae7871f381e8f5647736836dc | https://repo1.maven.org/maven2/org/robolectric/nativeruntime-dist-compat/1.0...
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/47...
tbb-commits@lists.torproject.org