python/mozboot/mozboot/bootstrap.py

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3 # You can obtain one at http://mozilla.org/MPL/2.0/.
     5 # If we add unicode_literals, Python 2.6.1 (required for OS X 10.6) breaks.
     6 from __future__ import print_function
     8 import platform
     9 import sys
    11 from mozboot.centos import CentOSBootstrapper
    12 from mozboot.debian import DebianBootstrapper
    13 from mozboot.fedora import FedoraBootstrapper
    14 from mozboot.freebsd import FreeBSDBootstrapper
    15 from mozboot.gentoo import GentooBootstrapper
    16 from mozboot.osx import OSXBootstrapper
    17 from mozboot.openbsd import OpenBSDBootstrapper
    18 from mozboot.ubuntu import UbuntuBootstrapper
    21 FINISHED = '''
    22 Your system should be ready to build Firefox! If you have not already,
    23 obtain a copy of the source code by running:
    25     hg clone https://hg.mozilla.org/mozilla-central
    27 Or, if you prefer Git:
    29     git clone https://git.mozilla.org/integration/gecko-dev.git
    30 '''
    33 class Bootstrapper(object):
    34     """Main class that performs system bootstrap."""
    36     def __init__(self, finished=FINISHED):
    37         self.instance = None
    38         self.finished = finished
    39         cls = None
    40         args = {}
    42         if sys.platform.startswith('linux'):
    43             distro, version, dist_id = platform.linux_distribution()
    45             if distro == 'CentOS':
    46                 cls = CentOSBootstrapper
    47             elif distro in ('Debian', 'debian'):
    48                 cls = DebianBootstrapper
    49             elif distro == 'Fedora':
    50                 cls = FedoraBootstrapper
    51             elif distro == 'Gentoo Base System':
    52                 cls = GentooBootstrapper
    53             elif distro in ('Mint', 'LinuxMint'):
    54                 # Most Linux Mint editions are based on Ubuntu; one is based on
    55                 # Debian, and reports this in dist_id
    56                 if dist_id == 'debian':
    57                     cls = DebianBootstrapper
    58                 else:
    59                     cls = UbuntuBootstrapper
    60             elif distro == 'Ubuntu':
    61                 cls = UbuntuBootstrapper
    62             elif distro == 'Elementary':
    63                 cls = UbuntuBootstrapper
    64             else:
    65                 raise NotImplementedError('Bootstrap support for this Linux '
    66                                           'distro not yet available.')
    68             args['version'] = version
    69             args['dist_id'] = dist_id
    71         elif sys.platform.startswith('darwin'):
    72             # TODO Support Darwin platforms that aren't OS X.
    73             osx_version = platform.mac_ver()[0]
    75             cls = OSXBootstrapper
    76             args['version'] = osx_version
    78         elif sys.platform.startswith('openbsd'):
    79             cls = OpenBSDBootstrapper
    80             args['version'] = platform.uname()[2]
    82         elif sys.platform.startswith('freebsd'):
    83             cls = FreeBSDBootstrapper
    84             args['version'] = platform.release()
    86         if cls is None:
    87             raise NotImplementedError('Bootstrap support is not yet available '
    88                                       'for your OS.')
    90         self.instance = cls(**args)
    93     def bootstrap(self):
    94         self.instance.install_system_packages()
    95         self.instance.ensure_mercurial_modern()
    96         self.instance.ensure_python_modern()
    98         print(self.finished)

mercurial