Bug 908637 - Add bootstrap support for FreeBSD. r=gps

This commit is contained in:
Jan Beich 2013-08-26 11:07:34 -04:00
parent 1c4d303bce
commit 2c99f0f441
4 changed files with 58 additions and 1 deletions

View File

@ -37,6 +37,7 @@ REPOSITORY_PATHS = [
'mozboot/centos.py',
'mozboot/debian.py',
'mozboot/fedora.py',
'mozboot/freebsd.py',
'mozboot/gentoo.py',
'mozboot/mint.py',
'mozboot/openbsd.py',

View File

@ -96,7 +96,10 @@ class BaseBootstrapper(object):
def run_as_root(self, command):
if os.geteuid() != 0:
command.insert(0, 'sudo')
if self.which('sudo'):
command.insert(0, 'sudo')
else:
command = ['su', 'root', '-c', ' '.join(command)]
print('Executing as root:', subprocess.list2cmdline(command))

View File

@ -11,6 +11,7 @@ import sys
from mozboot.centos import CentOSBootstrapper
from mozboot.debian import DebianBootstrapper
from mozboot.fedora import FedoraBootstrapper
from mozboot.freebsd import FreeBSDBootstrapper
from mozboot.gentoo import GentooBootstrapper
from mozboot.mint import MintBootstrapper
from mozboot.osx import OSXBootstrapper
@ -70,6 +71,10 @@ class Bootstrapper(object):
cls = OpenBSDBootstrapper
args['version'] = platform.uname()[2]
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.')

View File

@ -0,0 +1,48 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import print_function
import os
import subprocess
import sys
from mozboot.base import BaseBootstrapper
class FreeBSDBootstrapper(BaseBootstrapper):
def __init__(self, version):
BaseBootstrapper.__init__(self)
self.version = int(version.split('.')[0])
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',))
def upgrade_mercurial(self, current):
self.pkg_install('mercurial')