Bug 964744 - Refactor mozboot packages into the constructor, r=gps
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 28 Jan 2014 18:27:43 -0500
changeset 181676 6e77ceef4ebd9549bd586554e3e5bcf3258d02d2
parent 181675 7393aa7b33adf1d79c220781f7551500fed56380
child 181677 23a89fe652c123519497549e4762bde9b8985233
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs964744
milestone29.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 964744 - Refactor mozboot packages into the constructor, r=gps
python/mozboot/mozboot/base.py
python/mozboot/mozboot/bootstrap.py
python/mozboot/mozboot/centos.py
python/mozboot/mozboot/debian.py
python/mozboot/mozboot/fedora.py
python/mozboot/mozboot/freebsd.py
python/mozboot/mozboot/openbsd.py
--- a/python/mozboot/mozboot/base.py
+++ b/python/mozboot/mozboot/base.py
@@ -131,16 +131,27 @@ class BaseBootstrapper(object):
         self.run_as_root(command)
 
     def apt_install(self, *packages):
         command = ['apt-get', 'install']
         command.extend(packages)
 
         self.run_as_root(command)
 
+    def apt_update(self):
+        command = ['apt-get', 'update']
+
+        self.run_as_root(command)
+
+    def apt_add_architecture(self, arch):
+        command = ['dpkg', '--add-architecture']
+        command.extemd(arch)
+
+        self.run_as_root(command)
+
     def check_output(self, *args, **kwargs):
         """Run subprocess.check_output even if Python doesn't provide it."""
         fn = getattr(subprocess, 'check_output', BaseBootstrapper._check_output)
 
         return fn(*args, **kwargs)
 
     @staticmethod
     def _check_output(*args, **kwargs):
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
@@ -28,17 +28,19 @@ Or, if you prefer Git:
 
     git clone https://git.mozilla.org/integration/gecko-dev.git
 '''
 
 
 class Bootstrapper(object):
     """Main class that performs system bootstrap."""
 
-    def bootstrap(self):
+    def __init__(self, finished=FINISHED):
+        self.instance = None
+        self.finished = finished
         cls = None
         args = {}
 
         if sys.platform.startswith('linux'):
             distro, version, dist_id = platform.linux_distribution()
 
             if distro == 'CentOS':
                 cls = CentOSBootstrapper
@@ -80,14 +82,17 @@ class Bootstrapper(object):
         elif sys.platform.startswith('freebsd'):
             cls = FreeBSDBootstrapper
             args['version'] = platform.release()
 
         if cls is None:
             raise NotImplementedError('Bootstrap support is not yet available '
                                       'for your OS.')
 
-        instance = cls(**args)
-        instance.install_system_packages()
-        instance.ensure_mercurial_modern()
-        instance.ensure_python_modern()
+        self.instance = cls(**args)
+
 
-        print(FINISHED)
+    def bootstrap(self):
+        self.instance.install_system_packages()
+        self.instance.ensure_mercurial_modern()
+        self.instance.ensure_python_modern()
+
+        print(self.finished)
--- a/python/mozboot/mozboot/centos.py
+++ b/python/mozboot/mozboot/centos.py
@@ -9,39 +9,45 @@ from mozboot.base import BaseBootstrappe
 
 class CentOSBootstrapper(BaseBootstrapper):
     def __init__(self, version, dist_id):
         BaseBootstrapper.__init__(self)
 
         self.version = version
         self.dist_id = dist_id
 
-    def install_system_packages(self):
-        kern = platform.uname()
-
-        self.yum_groupinstall(
+        self.group_packages = [
             'Development Tools',
             'Development Libraries',
-            'GNOME Software Development')
-        self.yum_install(
+            'GNOME Software Development',
+        ]
+
+        self.packages = [
             'alsa-lib-devel',
             'autoconf213',
             'curl-devel',
             'dbus-glib-devel',
             'glibc-static',
             'gstreamer-devel',
             'gstreamer-plugins-base-devel',
             'gtk2-devel',
             'libstdc++-static',
             'libXt-devel',
             'mercurial',
             'mesa-libGL-devel',
             'pulseaudio-libs-devel',
             'wireless-tools-devel',
-            'yasm')
+            'yasm',
+        ]
+
+    def install_system_packages(self):
+        kern = platform.uname()
+
+        self.yum_groupinstall(*self.group_packages)
+        self.yum_install(*self.packages)
 
         yasm = 'http://pkgs.repoforge.org/yasm/yasm-1.1.0-1.el6.rf.i686.rpm'
         if 'x86_64' in kern[2]:
             yasm = 'http://pkgs.repoforge.org/yasm/yasm-1.1.0-1.el6.rf.x86_64.rpm'
 
         self.run_as_root(['rpm', '-ivh', yasm])
 
     def upgrade_mercurial(self, current):
--- a/python/mozboot/mozboot/debian.py
+++ b/python/mozboot/mozboot/debian.py
@@ -37,14 +37,15 @@ class DebianBootstrapper(BaseBootstrappe
     DISTRO_PACKAGES = []
 
     def __init__(self, version, dist_id):
         BaseBootstrapper.__init__(self)
 
         self.version = version
         self.dist_id = dist_id
 
+        self.packages = self.COMMON_PACKAGES + self.DISTRO_PACKAGES
+
     def install_system_packages(self):
-        packages = self.COMMON_PACKAGES + self.DISTRO_PACKAGES
-        self.apt_install(*packages)
+        self.apt_install(*self.packages)
 
     def _update_package_manager(self):
         self.run_as_root(['apt-get', 'update'])
--- a/python/mozboot/mozboot/fedora.py
+++ b/python/mozboot/mozboot/fedora.py
@@ -8,31 +8,36 @@ from mozboot.base import BaseBootstrappe
 
 class FedoraBootstrapper(BaseBootstrapper):
     def __init__(self, version, dist_id):
         BaseBootstrapper.__init__(self)
 
         self.version = version
         self.dist_id = dist_id
 
-    def install_system_packages(self):
-        self.yum_groupinstall(
+        self.group_packages = [
             'Development Tools',
             'Development Libraries',
-            'GNOME Software Development')
+            'GNOME Software Development',
+        ]
 
-        self.yum_install(
+        self.packages = [
             'alsa-lib-devel',
             'autoconf213',
             'gcc-c++',
             'glibc-static',
             'gstreamer-devel',
             'gstreamer-plugins-base-devel',
             'libstdc++-static',
             'libXt-devel',
             'mercurial',
             'mesa-libGL-devel',
             'pulseaudio-libs-devel',
             'wireless-tools-devel',
-            'yasm')
+            'yasm',
+        ]
+
+    def install_system_packages(self):
+        self.yum_groupinstall(*self.group_packages)
+        self.yum_install(*self.packages)
 
     def upgrade_mercurial(self, current):
         self.yum_update('mercurial')
--- a/python/mozboot/mozboot/freebsd.py
+++ b/python/mozboot/mozboot/freebsd.py
@@ -10,39 +10,43 @@ import sys
 
 from mozboot.base import BaseBootstrapper
 
 class FreeBSDBootstrapper(BaseBootstrapper):
     def __init__(self, version):
         BaseBootstrapper.__init__(self)
         self.version = int(version.split('.')[0])
 
+        self.packages = [
+            ('autoconf-2.13', 'autoconf213'),
+            ('dbus-glib',),
+            ('gmake',),
+            ('gstreamer-plugins',),
+            ('gtk-2', 'gtk20'),
+            ('libGL',),
+            ('libIDL',),
+            ('libv4l',),
+            ('mercurial',),
+            ('pulseaudio',),
+            ('yasm',),
+            ('zip',),
+        ]
+
+        # using clang since 9.0
+        if self.version < 9:
+            self.packages.append(('gcc',))
+
+
     def pkg_install(self, *packages):
         if self.which('pkg'):
             command = ['pkg', 'install', '-x']
             command.extend([i[0] for i in packages])
         else:
             command = ['pkg_add', '-Fr']
             command.extend([i[-1] for i in packages])
 
         self.run_as_root(command)
 
     def install_system_packages(self):
-        # using clang since 9.0
-        if self.version < 9:
-            self.pkg_install(('gcc',))
-
-        self.pkg_install(
-            ('autoconf-2.13', 'autoconf213'),
-            ('dbus-glib',),
-            ('gmake',),
-            ('gstreamer-plugins',),
-            ('gtk-2', 'gtk20'),
-            ('libGL',),
-            ('libIDL',),
-            ('libv4l',),
-            ('mercurial',),
-            ('pulseaudio',),
-            ('yasm',),
-            ('zip',))
+        self.pkg_install(*self.packages)
 
     def upgrade_mercurial(self, current):
         self.pkg_install('mercurial')
--- a/python/mozboot/mozboot/openbsd.py
+++ b/python/mozboot/mozboot/openbsd.py
@@ -5,25 +5,28 @@
 import os
 
 from mozboot.base import BaseBootstrapper
 
 class OpenBSDBootstrapper(BaseBootstrapper):
     def __init__(self, version):
         BaseBootstrapper.__init__(self)
 
-    def install_system_packages(self):
-        # we use -z because there's no other way to say "any autoconf-2.13"
-        self.run_as_root(['pkg_add', '-z',
+        self.packages = [
             'mercurial',
             'llvm',
             'autoconf-2.13',
             'yasm',
             'gtk+2',
             'dbus-glib',
             'gstreamer-plugins-base',
             'pulseaudio',
             'libIDL',
             'gmake',
             'gtar',
             'wget',
             'unzip',
-            'zip'])
+            'zip',
+        ]
+
+    def install_system_packages(self):
+        # we use -z because there's no other way to say "any autoconf-2.13"
+        self.run_as_root(['pkg_add', '-z'] + self.packages)