build.android 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. ext_dir=assets/distribution/extensions
  4. qa_apk=[% dest_dir %]/[% c('filename') %]/tor-browser-[% c("version") %]-[% c("var/osname") %]-multi-qa.apk
  5. apk=$rootdir/[% c('input_files_by_name/firefox') %]/tor-browser-unsigned-unaligned.apk
  6. mkdir -p /var/tmp/build/$ext_dir [% dest_dir _ '/' _ c('filename') %]
  7. cd /var/tmp/build
  8. mv $rootdir/[% c('input_files_by_name/https-everywhere') %] $ext_dir/https-everywhere-eff@eff.org.xpi
  9. mv $rootdir/[% c('input_files_by_name/noscript') %] $ext_dir/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi
  10. [% c('zip', {
  11. zip_src => [ '$ext_dir' ],
  12. zip_args => '$apk',
  13. }) %]
  14. unzip $apk lib/*
  15. zip -d $apk lib/\*
  16. [% IF c("var/android-x86") %]
  17. [% c('zip', {
  18. zip_src => [ 'lib/x86/*' ],
  19. zip_args => '$apk',
  20. }) %]
  21. [% ELSIF c("var/android-x86_64") %]
  22. [% c('zip', {
  23. zip_src => [ 'lib/x86_64/*' ],
  24. zip_args => '$apk',
  25. }) %]
  26. [% ELSIF c("var/android-armv7") %]
  27. [% c('zip', {
  28. zip_src => [ 'lib/armeabi-v7a/*' ],
  29. zip_args => '$apk',
  30. }) %]
  31. [% ELSIF c("var/android-aarch64") %]
  32. [% c('zip', {
  33. zip_src => [ 'lib/arm64-v8a/*' ],
  34. zip_args => '$apk',
  35. }) %]
  36. [% END %]
  37. rm -fR lib
  38. # Bug 31564: Android Gradle Plugin has a reproducibility bug. Decompile and recompile to fix ordering of resources.arsc files
  39. apktool=$rootdir/[% c('input_files_by_name/apktool') %]
  40. java -jar $apktool d --no-src -o decompiled $apk
  41. java -jar $apktool b -o $apk decompiled
  42. # Fix timestamps and remove extra field info from zip entries
  43. unzip $apk -d tmp
  44. rm $apk
  45. cd tmp
  46. [% c('zip', {
  47. zip_src => [ '.' ],
  48. zip_args => '-n ja $apk',
  49. }) %]
  50. # Sign a QA build. This apk is not a debug version and doesn't contain a debug flag in the manifest
  51. java -jar /usr/lib/android-sdk/build-tools/debian/apksigner.jar sign --verbose --min-sdk-version [% c("var/android_min_api") %] --ks $rootdir/android-qa.keystore --out $qa_apk --in $apk --ks-key-alias androidqakey --key-pass pass:android --ks-pass pass:android