Bug 1114718 - Add mobile/android builds to Arch Linux bootstrapper. r?gps draft
authorNick Alexander <nalexander@mozilla.com>
Mon, 19 Oct 2015 16:36:00 -0700
changeset 301839 7c6bc2c2aefcc9c65af368471e845a43c81247e8
parent 301578 d1a89632277fbaaf470c90a35573776048988f2d
child 510288 6138d70d283dd96556e9170a5436aa61bd8ea30a
push id6515
push usernalexander@mozilla.com
push dateMon, 19 Oct 2015 23:36:16 +0000
reviewersgps
bugs1114718
milestone44.0a1
Bug 1114718 - Add mobile/android builds to Arch Linux bootstrapper. r?gps
python/mozboot/mozboot/archlinux.py
--- a/python/mozboot/mozboot/archlinux.py
+++ b/python/mozboot/mozboot/archlinux.py
@@ -54,34 +54,85 @@ class ArchlinuxBootstrapper(BaseBootstra
         'xorg-server-xvfb',
         'yasm',
         'zip',
         'gst-libav',
         'gst-plugins-good',
         'networkmanager',
     ]
 
-    AUR_PACKAGES = [
-        'https://aur.archlinux.org/cgit/aur.git/snapshot/uuid.tar.gz'
+    BROWSER_AUR_PACKAGES = [
+        'https://aur.archlinux.org/cgit/aur.git/snapshot/uuid.tar.gz',
+    ]
+
+    MOBILE_ANDROID_COMMON_PACKAGES = [
+        'zlib',  # mobile/android requires system zlib.
+        'jdk7-openjdk',
+        'wget',  # For downloading the Android SDK and NDK.
+        'multilib/lib32-libstdc++5', # See comment about 32 bit binaries and multilib below.
+        'multilib/lib32-ncurses',
+        'multilib/lib32-readline',
+        'multilib/lib32-zlib',
     ]
 
     def __init__(self, version, dist_id, **kwargs):
         print 'Using an experimental bootstrapper for Archlinux.'
         BaseBootstrapper.__init__(self, **kwargs)
 
     def install_system_packages(self):
         self.pacman_install(*self.SYSTEM_PACKAGES)
-        self.aur_install(*self.AUR_PACKAGES)
 
     def install_browser_packages(self):
+        self.aur_install(*self.AUR_BROWSER_PACKAGES)
         self.pacman_install(*self.BROWSER_PACKAGES)
 
     def install_mobile_android_packages(self):
-        raise NotImplementedError('Bootstrap support for mobile-android is '
-                                  'not yet available for Archlinux')
+        import android
+
+        # Multi-part process:
+        # 1. System packages.
+        # 2. Android SDK and NDK.
+        # 3. Android packages.
+
+        # 1. This is hard to believe, but the Android SDK binaries are 32-bit
+        # and that conflicts with 64-bit Arch installations out of the box.  The
+        # solution is to add the multilibs repository; unfortunately, this
+        # requires manual intervention.
+        try:
+            self.pacman_install(*self.MOBILE_ANDROID_COMMON_PACKAGES)
+        except e:
+            print('Failed to install all packages.  The Android developer '
+                  'toolchain requires 32 bit binaries be enabled (see '
+                  'https://wiki.archlinux.org/index.php/Android).  You may need to '
+                  'manually enable the multilib repository following the instructions '
+                  'at https://wiki.archlinux.org/index.php/Multilib.')
+            raise e
+
+        # 2. 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-linux, android-ndk-r10e}.
+        mozbuild_path = os.environ.get('MOZBUILD_STATE_PATH', os.path.expanduser(os.path.join('~', '.mozbuild')))
+        self.sdk_path = os.environ.get('ANDROID_SDK_HOME', os.path.join(mozbuild_path, 'android-sdk-linux'))
+        self.ndk_path = os.environ.get('ANDROID_NDK_HOME', os.path.join(mozbuild_path, 'android-ndk-r10e'))
+        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-linux.tgz'
+        is_64bits = sys.maxsize > 2**32
+        if is_64bits:
+            self.ndk_url = 'https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin'
+        else:
+            self.ndk_url = 'https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86.bin'
+        android.ensure_android_sdk_and_ndk(path=mozbuild_path,
+                                           sdk_path=self.sdk_path, sdk_url=self.sdk_url,
+                                           ndk_path=self.ndk_path, ndk_url=self.ndk_url)
+        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
+        android.ensure_android_packages(android_tool=android_tool)
+    
+    def suggest_mobile_android_mozconfig(self):
+        import android
+        android.suggest_mozconfig(sdk_path=self.sdk_path,
+                                  ndk_path=self.ndk_path)
 
     def _update_package_manager(self):
         self.pacman_update
 
     def upgrade_mercurial(self, current):
         self.pacman_install('mercurial')
 
     def upgrade_python(self, current):