Bug 1529082 - Add bundletool to Android's bootstrap r=jmaher

This tool is used to install AAB packages to devices.

AAB is the new package format for Android Apps and will supersede APK.

Differential Revision: https://phabricator.services.mozilla.com/D127318
This commit is contained in:
Agi Sferro 2021-11-02 18:56:25 +00:00
Родитель 088243109c
Коммит 9e1b1f9456
3 изменённых файлов: 24 добавлений и 2 удалений

Просмотреть файл

@ -21,6 +21,8 @@ NDK_VERSION = "r21d"
CMDLINE_TOOLS_VERSION_STRING = "4.0"
CMDLINE_TOOLS_VERSION = "7302050"
BUNDLETOOL_VERSION = "1.8.0"
# We expect the emulator AVD definitions to be platform agnostic
LINUX_X86_64_ANDROID_AVD = "linux64-android-avd-x86_64-repack"
LINUX_ARM_ANDROID_AVD = "linux64-android-avd-arm-repack"
@ -96,6 +98,20 @@ class GetNdkVersionError(Exception):
pass
def install_bundletool(url, path):
"""
Fetch bundletool to the desired directory.
"""
old_path = os.getcwd()
try:
os.chdir(path)
subprocess.check_call(
["wget", "--continue", url, "--output-document", "bundletool.jar"]
)
finally:
os.chdir(old_path)
def install_mobile_android_sdk_or_ndk(url, path):
"""
Fetch an Android SDK or NDK from |url| and unpack it into
@ -286,6 +302,9 @@ def ensure_android(
os_tag, CMDLINE_TOOLS_VERSION
)
ndk_url = android_ndk_url(os_name)
bundletool_url = "https://github.com/google/bundletool/releases/download/{v}/bundletool-all-{v}.jar".format( # NOQA: E501
v=BUNDLETOOL_VERSION
)
ensure_android_sdk_and_ndk(
mozbuild_path,
@ -294,6 +313,7 @@ def ensure_android(
sdk_url=sdk_url,
ndk_path=ndk_path,
ndk_url=ndk_url,
bundletool_url=bundletool_url,
artifact_mode=artifact_mode,
ndk_only=ndk_only,
emulator_only=emulator_only,
@ -341,6 +361,7 @@ def ensure_android_sdk_and_ndk(
sdk_url,
ndk_path,
ndk_url,
bundletool_url,
artifact_mode,
ndk_only,
emulator_only,
@ -395,6 +416,7 @@ def ensure_android_sdk_and_ndk(
os.path.join(cmdline_tools_path, "cmdline-tools"),
os.path.join(cmdline_tools_path, CMDLINE_TOOLS_VERSION_STRING),
)
install_bundletool(bundletool_url, mozbuild_path)
def get_packages_to_install(packages_file_content, avd_manifest):

Просмотреть файл

@ -18,6 +18,6 @@ mkdir /builds/worker/.mozbuild/android-sdk-linux/system-images
mkdir /builds/worker/.mozbuild/android-sdk-linux/platforms
find /builds/worker/.mozbuild/android-sdk-linux/emulator/qemu -type f -not -name "*x86*" -print -delete
tar cavf $UPLOAD_DIR/android-emulator-linux.tar.zst -C /builds/worker/.mozbuild android-sdk-linux
tar cavf $UPLOAD_DIR/android-emulator-linux.tar.zst -C /builds/worker/.mozbuild android-sdk-linux bundletool.jar
ls -al $UPLOAD_DIR

Просмотреть файл

@ -12,6 +12,6 @@ mkdir -p $HOME/artifacts $UPLOAD_DIR
cd $GECKO_PATH
./mach python python/mozboot/mozboot/android.py --artifact-mode --no-interactive --list-packages
tar cavf $UPLOAD_DIR/android-sdk-linux.tar.zst -C /builds/worker/.mozbuild android-sdk-linux
tar cavf $UPLOAD_DIR/android-sdk-linux.tar.zst -C /builds/worker/.mozbuild android-sdk-linux bundletool.jar
ls -al $UPLOAD_DIR