Example #1
0
    def install_mobile_android_packages(self):
        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 Debian and Ubuntu installations out of
        # the box.  The solution is to add the i386 architecture.  See
        # "Troubleshooting Ubuntu" at
        # http://developer.android.com/sdk/installing/index.html?pkg=tools.
        self.run_as_root(['dpkg', '--add-architecture', 'i386'])
        # After adding a new arch, the list of packages has to be updated
        self.apt_update()
        self.apt_install(*self.mobile_android_packages)

        # 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'
        self.ndk_url = android_ndk_url('linux')

        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)

        # 3. We expect the |android| tool to at
        # ~/.mozbuild/android-sdk-linux/tools/android.
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool)
Example #2
0
    def ensure_homebrew_mobile_android_packages(self):
        import android

        # If we're run from a downloaded bootstrap.py, then android-ndk.rb is
        # fetched into a temporary directory.  This finds that directory.
        import inspect
        path_to_android = os.path.abspath(
            os.path.dirname(inspect.getfile(android)))

        # We don't need wget because we install the Android SDK and NDK from
        # packages.  If we used the android.py module, we'd need wget.
        packages = [
            ('android-sdk', 'android-sdk'),
            ('android-ndk', os.path.join(
                path_to_android,
                'android-ndk.rb')),  # This is a locally provided brew formula!
            ('ant', 'ant'),
            ('brew-cask',
             'caskroom/cask/brew-cask'),  # For installing Java later.
        ]
        self._ensure_homebrew_packages(packages)

        casks = [
            ('java', 'java'),
        ]
        installed = self._ensure_homebrew_casks(casks)
        if installed:
            print(JAVA_LICENSE_NOTICE
                  )  # We accepted a license agreement for the user.

        # We could probably fish this path from |brew info android-sdk|.
        android_tool = '/usr/local/opt/android-sdk/tools/android'
        android.ensure_android_packages(android_tool)
Example #3
0
    def install_fedora_mobile_android_packages(self, artifact_mode=False):
        import android

        # Install Android specific packages.
        self.dnf_install(*self.mobile_android_packages)

        # Fetch Android SDK and NDK.
        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-r11b'))
        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-linux.tgz'
        self.ndk_url = android.android_ndk_url('linux')

        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,
                                           artifact_mode=artifact_mode)

        # Most recent version of build-tools appears to be 23.0.1 on Fedora
        packages = [p for p in android.ANDROID_PACKAGES if not p.startswith('build-tools')]
        packages.append('build-tools-23.0.1')

        # 3. We expect the |android| tool to be at
        # ~/.mozbuild/android-sdk-linux/tools/android.
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool, packages=packages)
Example #4
0
    def ensure_homebrew_mobile_android_packages(self):
        import android

        # If we're run from a downloaded bootstrap.py, then android-ndk.rb is
        # fetched into a temporary directory.  This finds that directory.
        import inspect
        path_to_android = os.path.abspath(os.path.dirname(inspect.getfile(android)))

        # We don't need wget because we install the Android SDK and NDK from
        # packages.  If we used the android.py module, we'd need wget.
        packages = [
            ('android-sdk', 'android-sdk'),
            ('android-ndk', os.path.join(path_to_android, 'android-ndk.rb')),  # This is a locally provided brew formula!
            ('ant', 'ant'),
            ('brew-cask', 'caskroom/cask/brew-cask'),  # For installing Java later.
        ]
        self._ensure_homebrew_packages(packages)

        casks = [
            ('java', 'java'),
        ]
        installed = self._ensure_homebrew_casks(casks)
        if installed:
            print(JAVA_LICENSE_NOTICE)  # We accepted a license agreement for the user.

        # We could probably fish this path from |brew info android-sdk|.
        android_tool = '/usr/local/opt/android-sdk/tools/android'
        android.ensure_android_packages(android_tool)
Example #5
0
    def install_fedora_mobile_android_packages(self, artifact_mode=False):
        import android

        # Install Android specific packages.
        self.dnf_install(*self.mobile_android_packages)

        # Fetch Android SDK and NDK.
        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-r11c'))
        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-linux.tgz'
        self.ndk_url = android.android_ndk_url('linux')

        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,
                                           artifact_mode=artifact_mode)

        # Most recent version of build-tools appears to be 23.0.1 on Fedora
        packages = [p for p in android.ANDROID_PACKAGES if not p.startswith('build-tools')]
        packages.append('build-tools-23.0.1')

        # 3. We expect the |android| tool to be at
        # ~/.mozbuild/android-sdk-linux/tools/android.
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool, packages=packages)
Example #6
0
    def ensure_homebrew_mobile_android_packages(self):
        # Multi-part process:
        # 1. System packages.
        # 2. Android SDK and NDK.
        # 3. Android packages.

        import android

        # 1. System packages.
        packages = [
            ('ant', 'ant'),
            ('brew-cask',
             'caskroom/cask/brew-cask'),  # For installing Java later.
            ('wget', 'wget'),
        ]
        self._ensure_homebrew_packages(packages)

        casks = [
            ('java', 'java'),
        ]
        installed = self._ensure_homebrew_casks(casks)
        if installed:
            print(JAVA_LICENSE_NOTICE
                  )  # We accepted a license agreement for the user.

        # 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-macosx'))
        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-macosx.zip'
        is_64bits = sys.maxsize > 2**32
        if is_64bits:
            self.ndk_url = android.android_ndk_url('darwin')
        else:
            raise Exception(
                'You need a 64-bit version of Mac OS X to build Firefox for Android.'
            )

        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)

        # 3. We expect the |android| tool to at
        # ~/.mozbuild/android-sdk-macosx/tools/android.
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool)
Example #7
0
    def ensure_macports_mobile_android_packages(self, artifact_mode=False):
        # Multi-part process:
        # 1. System packages.
        # 2. Android SDK. Android NDK only if we are not in artifact mode.
        # 3. Android packages.

        import android

        # 1. System packages.
        packages = [
            'wget',
        ]
        self._ensure_macports_packages(packages)

        # Verify the presence of java and javac.
        if not self.which('java') or not self.which('javac'):
            raise Exception(
                'You need to have Java version 1.7 or later installed. Please visit http://www.java.com/en/download/mac_download.jsp to get the latest version.'
            )

        # 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-r11b}.
        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-macosx'))
        self.ndk_path = os.environ.get(
            'ANDROID_NDK_HOME', os.path.join(mozbuild_path,
                                             'android-ndk-r11b'))
        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-macosx.zip'
        is_64bits = sys.maxsize > 2**32
        if is_64bits:
            self.ndk_url = android.android_ndk_url('darwin')
        else:
            raise Exception(
                'You need a 64-bit version of Mac OS X to build Firefox for Android.'
            )

        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,
                                           artifact_mode=artifact_mode)

        # 3. We expect the |android| tool to at
        # ~/.mozbuild/android-sdk-macosx/tools/android.
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool)
Example #8
0
    def ensure_mobile_android_packages(self, artifact_mode=False):
        import android

        # Multi-part process:
        # 1. System packages.
        # 2. Android SDK. Android NDK only if we are not in artifact mode.
        # 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-r11b}.
        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-r11b'))
        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-linux.tgz'
        self.ndk_url = android.android_ndk_url('linux')

        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,
                                           artifact_mode=artifact_mode)
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool)
Example #9
0
    def install_mobile_android_packages(self):
        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 Debian and Ubuntu installations out of
        # the box.  The solution is to add the i386 architecture.  See
        # "Troubleshooting Ubuntu" at
        # http://developer.android.com/sdk/installing/index.html?pkg=tools.
        self.run_as_root(['dpkg', '--add-architecture', 'i386'])
        # After adding a new arch, the list of packages has to be updated
        self.apt_update()
        self.apt_install(*self.mobile_android_packages)

        # 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-r8e}.
        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-r8e'))
        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-r8e-linux-x86_64.tar.bz2'
        else:
            self.ndk_url = 'https://dl.google.com/android/ndk/android-ndk-r8e-linux-x86.tar.bz2'
        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)

        # 3. We expect the |android| tool to at
        # ~/.mozbuild/android-sdk-linux/tools/android.
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool)
Example #10
0
    def ensure_homebrew_mobile_android_packages(self, artifact_mode=False):
        # Multi-part process:
        # 1. System packages.
        # 2. Android SDK. Android NDK only if we are not in artifact mode.
        # 3. Android packages.

        import android

        # 1. System packages.
        packages = [
            ('brew-cask', 'caskroom/cask/brew-cask'),  # For installing Java later.
            ('wget', 'wget'),
        ]
        self._ensure_homebrew_packages(packages)

        casks = [
            ('java', 'java'),
        ]
        installed = self._ensure_homebrew_casks(casks)
        if installed:
            print(JAVA_LICENSE_NOTICE)  # We accepted a license agreement for the user.

        # 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-r11c}.
        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-macosx'))
        self.ndk_path = os.environ.get('ANDROID_NDK_HOME', os.path.join(mozbuild_path, 'android-ndk-r11c'))
        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-macosx.zip'
        is_64bits = sys.maxsize > 2**32
        if is_64bits:
            self.ndk_url = android.android_ndk_url('darwin')
        else:
            raise Exception('You need a 64-bit version of Mac OS X to build Firefox for Android.')

        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,
                                           artifact_mode=artifact_mode)

        # 3. We expect the |android| tool to at
        # ~/.mozbuild/android-sdk-macosx/tools/android.
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool)
Example #11
0
    def ensure_macports_mobile_android_packages(self, artifact_mode=False):
        # Multi-part process:
        # 1. System packages.
        # 2. Android SDK. Android NDK only if we are not in artifact mode.
        # 3. Android packages.

        import android

        # 1. System packages.
        packages = [
            'wget',
        ]
        self._ensure_macports_packages(packages)

        # Verify the presence of java and javac.
        if not self.which('java') or not self.which('javac'):
            raise Exception('You need to have Java version 1.7 or later installed. Please visit http://www.java.com/en/download/mac_download.jsp to get the latest version.')

        # 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-r11b}.
        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-macosx'))
        self.ndk_path = os.environ.get('ANDROID_NDK_HOME', os.path.join(mozbuild_path, 'android-ndk-r11b'))
        self.sdk_url = 'https://dl.google.com/android/android-sdk_r24.0.1-macosx.zip'
        is_64bits = sys.maxsize > 2**32
        if is_64bits:
            self.ndk_url = android.android_ndk_url('darwin')
        else:
            raise Exception('You need a 64-bit version of Mac OS X to build Firefox for Android.')

        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,
                                           artifact_mode=artifact_mode)

        # 3. We expect the |android| tool to at
        # ~/.mozbuild/android-sdk-macosx/tools/android.
        android_tool = os.path.join(self.sdk_path, 'tools', 'android')
        android.ensure_android_packages(android_tool=android_tool)
Example #12
0
    def install_mobile_android_packages(self):
        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)
Example #13
0
    def ensure_homebrew_mobile_android_packages(self):
        import android

        # We don't need wget because we install the Android SDK and NDK from
        # packages.  If we used the android.py module, we'd need wget.
        packages = [
            ('android-sdk', 'android-sdk'),
            ('android-ndk', 'android-ndk-r8e.rb'), # This is a locally provided brew formula!
            ('ant', 'ant'),
            ('brew-cask', 'caskroom/cask/brew-cask'), # For installing Java later.
        ]
        self._ensure_homebrew_packages(packages)

        casks = [
            ('java', 'java'),
        ]
        installed = self._ensure_homebrew_casks(casks)
        if installed:
            print(JAVA_LICENSE_NOTICE) # We accepted a license agreement for the user.

        # We could probably fish this path from |brew info android-sdk|.
        android_tool = '/usr/local/opt/android-sdk/tools/android'
        android.ensure_android_packages(android_tool)