Bug 1384199 - Fix path issue in Android bootstrap. r=rillian
authorNick Alexander <nalexander@mozilla.com>
Wed, 19 Jul 2017 15:24:47 -0700
changeset 422028 9658d6703c27b47126b6b0202b2e5ca2253c2c21
parent 422027 e551168b781873981757fd7428b40e72ea84881b
child 422029 bcfce9e21f29b6e719740ee13d4c0388d5fac2ab
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs1384199, 1344244
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1384199 - Fix path issue in Android bootstrap. r=rillian This was a regression introduced in Bug 1344244. Google changed the layout of their packages. It used to be that the Android SDK archive had a top-level 'android-sdk-$OS_NAME' directory; that's no longer the case. It would be cleaner to unpack to 'android-sdk' without the OS name, but that complicates the logic that detects existing installs. MozReview-Commit-ID: 4B2Rt1AM2ky
python/mozboot/mozboot/android.py
--- a/python/mozboot/mozboot/android.py
+++ b/python/mozboot/mozboot/android.py
@@ -148,59 +148,64 @@ def ensure_android(os_name, artifact_mod
     given URLs.  Ensure the required Android SDK packages are
     installed.
 
     `os_name` can be 'linux' or 'macosx'.
     '''
     # The user may have an external Android SDK (in which case we
     # save them a lengthy download), or they may have already
     # completed the download. We unpack to
-    # ~/.mozbuild/{android-sdk-$OS_NAME, android-ndk-r11c}.
+    # ~/.mozbuild/{android-sdk-$OS_NAME, android-ndk-$VER}.
     mozbuild_path, sdk_path, ndk_path = get_paths(os_name)
     os_tag = 'darwin' if os_name == 'macosx' else os_name
     sdk_url = 'https://dl.google.com/android/repository/sdk-tools-{}-3859397.zip'.format(os_tag)
     ndk_url = android_ndk_url(os_name)
 
-    ensure_android_sdk_and_ndk(path=os.path.join(mozbuild_path, 'android-sdk-{}'.format(os_name)),
+    ensure_android_sdk_and_ndk(mozbuild_path, os_name,
                                sdk_path=sdk_path, sdk_url=sdk_url,
                                ndk_path=ndk_path, ndk_url=ndk_url,
                                artifact_mode=artifact_mode)
 
     # We expect the |sdkmanager| tool to be at
     # ~/.mozbuild/android-sdk-$OS_NAME/tools/bin/sdkmanager.
     sdkmanager_tool = os.path.join(sdk_path, 'tools', 'bin', 'sdkmanager')
     ensure_android_packages(sdkmanager_tool=sdkmanager_tool)
 
 
-def ensure_android_sdk_and_ndk(path, sdk_path, sdk_url, ndk_path, ndk_url, artifact_mode):
+def ensure_android_sdk_and_ndk(mozbuild_path, os_name, sdk_path, sdk_url, ndk_path, ndk_url, artifact_mode):
     '''
     Ensure the Android SDK and NDK are found at the given paths.  If not, fetch
-    and unpack the SDK and/or NDK from the given URLs into |path|.
+    and unpack the SDK and/or NDK from the given URLs into |mozbuild_path/{android-sdk-$OS_NAME,android-ndk-$VER}|.
     '''
 
     # It's not particularly bad to overwrite the NDK toolchain, but it does take
     # a while to unpack, so let's avoid the disk activity if possible.  The SDK
     # may prompt about licensing, so we do this first.
     # Check for Android NDK only if we are not in artifact mode.
     if not artifact_mode:
         if os.path.isdir(ndk_path):
             print(ANDROID_NDK_EXISTS % ndk_path)
         else:
-            install_mobile_android_sdk_or_ndk(ndk_url, path)
+            # The NDK archive unpacks into a top-level android-ndk-$VER directory.
+            install_mobile_android_sdk_or_ndk(ndk_url, mozbuild_path)
 
     # We don't want to blindly overwrite, since we use the
     # |sdkmanager| tool to install additional parts of the Android
     # toolchain.  If we overwrite, we lose whatever Android packages
     # the user may have already installed.
     if os.path.isfile(os.path.join(sdk_path, 'tools', 'bin', 'sdkmanager')):
         print(ANDROID_SDK_EXISTS % sdk_path)
     elif os.path.isdir(sdk_path):
         raise NotImplementedError(ANDROID_SDK_TOO_OLD % sdk_path)
     else:
-        install_mobile_android_sdk_or_ndk(sdk_url, path)
+        # The SDK archive used to include a top-level
+        # android-sdk-$OS_NAME directory; it no longer does so.  We
+        # preserve the old convention to smooth detecting existing SDK
+        # installations.
+        install_mobile_android_sdk_or_ndk(sdk_url, os.path.join(mozbuild_path, 'android-sdk-{}'.format(os_name)))
 
 
 def ensure_android_packages(sdkmanager_tool, packages=None):
     '''
     Use the given sdkmanager tool (like 'sdkmanager') to install required
     Android packages.
     '''
 
@@ -217,17 +222,17 @@ def suggest_mozconfig(os_name, artifact_
     if artifact_mode:
         print(MOBILE_ANDROID_ARTIFACT_MODE_MOZCONFIG_TEMPLATE % (sdk_path))
     else:
         print(MOBILE_ANDROID_MOZCONFIG_TEMPLATE % (sdk_path, ndk_path))
 
 
 def android_ndk_url(os_name, ver='r11c'):
     # Produce a URL like
-    # 'https://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip
+    # 'https://dl.google.com/android/repository/android-ndk-$VER-linux-x86_64.zip
     base_url = 'https://dl.google.com/android/repository/android-ndk'
 
     if os_name == 'macosx':
         # |mach bootstrap| uses 'macosx', but Google uses 'darwin'.
         os_name = 'darwin'
 
     if sys.maxsize > 2**32:
         arch = 'x86_64'