diff options
-rwxr-xr-x | morphlib/app.py | 56 | ||||
-rw-r--r-- | morphlib/buildcommand.py | 26 | ||||
-rw-r--r-- | morphlib/buildenvironment.py | 14 | ||||
-rw-r--r-- | morphlib/buildenvironment_tests.py | 32 | ||||
-rw-r--r-- | morphlib/builder2.py | 3 | ||||
-rw-r--r-- | morphlib/source.py | 2 | ||||
-rwxr-xr-x | tests.as-root/setup | 1 | ||||
-rwxr-xr-x | tests.branching/setup | 3 | ||||
-rwxr-xr-x | tests.deploy/setup | 1 | ||||
-rwxr-xr-x | tests.merging/setup | 3 | ||||
-rwxr-xr-x | tests/setup | 3 |
11 files changed, 53 insertions, 91 deletions
diff --git a/morphlib/app.py b/morphlib/app.py index 87710ee5..c8b9b911 100755 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -105,16 +105,7 @@ class Morph(cliapp.Application): default=None, group=group_advanced) - # Build Options group_build = 'Build Options' - self.settings.boolean(['bootstrap'], - 'build stuff in bootstrap mode; this is ' - 'DANGEROUS and will install stuff on your ' - 'system', - group=group_build) - self.settings.boolean(['keep-path'], - 'do not touch the PATH environment variable', - group=group_build) self.settings.integer(['max-jobs'], 'run at most N parallel jobs with make (default ' 'is to a value based on the number of CPUs ' @@ -135,20 +126,6 @@ class Morph(cliapp.Application): 'always push temporary build branches to the ' 'remote repository', group=group_build) - self.settings.boolean(['staging-chroot'], - 'build things in an isolated chroot ' - '(default: true)', - group=group_build) - self.settings.string_list(['staging-filler'], - 'use FILE as contents of build chroot', - metavar='FILE', - group=group_build) - self.settings.string(['target-cflags'], - 'inject additional CFLAGS into the environment ' - 'that is used to build chunks', - metavar='CFLAGS', - default='', - group=group_build) self.settings.string(['tempdir'], 'temporary directory to use for builds ' '(this is separate from just setting $TMPDIR ' @@ -159,13 +136,36 @@ class Morph(cliapp.Application): metavar='DIR', default=os.environ.get('TMPDIR'), group=group_build) + + # Would be better to have a separate tool to cross-bootstrap + # because it's completely outside normal Morph usage + group_bootstrap = 'Bootstrap Options' + self.settings.string(['target-cflags'], + 'inject additional CFLAGS into the environment ' + 'that is used to build chunks', + metavar='CFLAGS', + default='', + group=group_bootstrap) self.settings.string(['toolchain-target'], 'set the TOOLCHAIN_TARGET variable which is used ' 'in some chunks to determine which architecture ' 'to build tools for', metavar='TOOLCHAIN_TARGET', default=defaults['toolchain-target'], - group=group_build) + group=group_bootstrap) + + # These cannot be removed just yet because existing morph.conf files + # would fail to parse. + group_obsolete = 'Obsolete Options' + self.settings.boolean(['staging-chroot'], + 'build things in an isolated chroot ' + '(default: true)', + default=True, + group=group_obsolete) + self.settings.string_list(['staging-filler'], + 'use FILE as contents of build chroot', + metavar='FILE', + group=group_obsolete) def check_time(self): # Check that the current time is not far in the past. @@ -179,6 +179,14 @@ class Morph(cliapp.Application): def process_args(self, args): self.check_time() + # Handle obsolete options + if self.settings['staging-chroot'] is not True: + raise cliapp.AppException( + 'The "staging-chroot" option has been set to False. This ' + 'option is obsolete and should be left as the default (True).') + if self.settings['staging-filler'] is not None: + logging.warning('Use of a staging filler is deprecated.') + # Combine the aliases into repo-alias before passing on to normal # command processing. This means everything from here on down can # treat settings['repo-alias'] as the sole source of prefixes for git diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py index dfacd760..4200dc0e 100644 --- a/morphlib/buildcommand.py +++ b/morphlib/buildcommand.py @@ -219,18 +219,14 @@ class BuildCommand(object): deps = self.get_recursive_deps(artifact) self.cache_artifacts_locally(deps) staging_area = self.create_staging_area(artifact) - if self.app.settings['staging-chroot']: - if artifact.source.morphology.needs_staging_area: - self.install_fillers(staging_area) - self.install_chunk_artifacts(staging_area, - deps, artifact) - morphlib.builder2.ldconfig(self.app.runcmd, - staging_area.tempdir) + if artifact.source.morphology.needs_staging_area: + self.install_fillers(staging_area) + self.install_chunk_artifacts(staging_area, + deps, artifact) + morphlib.builder2.ldconfig(self.app.runcmd, + staging_area.tempdir) self.build_and_cache(staging_area, artifact) - if self.app.settings['bootstrap']: - self.install_chunk_artifacts(staging_area, - (artifact,)) self.remove_staging_area(staging_area) self.app.status(msg='%(kind)s %(name)s is cached at %(cachepath)s', kind=artifact.source.morphology['kind'], @@ -319,12 +315,8 @@ class BuildCommand(object): def create_staging_area(self, artifact): '''Create the staging area for building a single artifact.''' - if self.app.settings['staging-chroot']: - staging_root = tempfile.mkdtemp(dir=self.app.settings['tempdir']) - staging_temp = staging_root - else: - staging_root = '/' - staging_temp = tempfile.mkdtemp(dir=self.app.settings['tempdir']) + staging_root = tempfile.mkdtemp(dir=self.app.settings['tempdir']) + staging_temp = staging_root self.app.status(msg='Creating staging area') staging_area = morphlib.stagingarea.StagingArea(self.app, @@ -387,5 +379,5 @@ class BuildCommand(object): setup_mounts = self.app.settings['staging-chroot'] builder = morphlib.builder2.Builder( self.app, staging_area, self.lac, self.rac, self.lrc, - self.build_env, self.app.settings['max-jobs'], setup_mounts) + self.build_env, self.app.settings['max-jobs'], True) return builder.build_and_cache(artifact) diff --git a/morphlib/buildenvironment.py b/morphlib/buildenvironment.py index d9e3210f..57270414 100644 --- a/morphlib/buildenvironment.py +++ b/morphlib/buildenvironment.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,7 +44,6 @@ class BuildEnvironment(): # copy a set of white-listed variables from the original env copied_vars = dict.fromkeys([ - 'BOOTSTRAP_TOOLS', 'DISTCC_HOSTS', 'LD_PRELOAD', 'LD_LIBRARY_PATH', @@ -62,10 +61,6 @@ class BuildEnvironment(): if copied_vars[name] is not None: env[name] = copied_vars[name] - if settings['bootstrap'] or not settings['staging-chroot']: - if 'TMPDIR' in self._osenv: - env['TMPDIR'] = self._osenv['TMPDIR'] - env['TERM'] = self._override_term env['SHELL'] = self._override_shell env['USER'] = \ @@ -74,15 +69,12 @@ class BuildEnvironment(): env['LC_ALL'] = self._override_locale env['HOME'] = self._override_home - if settings['keep-path'] or settings['bootstrap']: - env['PATH'] = path - else: - env['PATH'] = self._default_path + env['PATH'] = self._default_path env['TOOLCHAIN_TARGET'] = settings['toolchain-target'] env['CFLAGS'] = settings['target-cflags'] env['PREFIX'] = settings['prefix'] - env['BOOTSTRAP'] = 'true' if settings['bootstrap'] else 'false' + env['BOOTSTRAP'] = 'false' if not settings['no-ccache']: env['PATH'] = ('%s:%s' % (self._ccache_path, env['PATH'])) # FIXME: we should set CCACHE_BASEDIR so any objects that refer to their diff --git a/morphlib/buildenvironment_tests.py b/morphlib/buildenvironment_tests.py index 61844c19..a55cd5ac 100644 --- a/morphlib/buildenvironment_tests.py +++ b/morphlib/buildenvironment_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,14 +24,11 @@ class BuildEnvironmentTests(unittest.TestCase): def setUp(self): self.settings = { - 'keep-path': False, - 'bootstrap': False, 'toolchain-target': '%s-baserock-linux-gnu' % morphlib.util.arch(), 'target-cflags': '', 'prefix': '/usr', 'no-ccache': True, - 'no-distcc': True, - 'staging-chroot': False, + 'no-distcc': True } self.fake_env = { 'PATH': '/fake_bin', @@ -48,39 +45,16 @@ class BuildEnvironmentTests(unittest.TestCase): self.assertEqual(buildenv.arch, 'noarch') def test_sets_default_path(self): - self.settings['keep-path'] = False - self.settings['bootstrap'] = False olddefaultpath = buildenvironment.BuildEnvironment._default_path buildenvironment.BuildEnvironment._default_path = self.default_path buildenv = buildenvironment.BuildEnvironment(self.settings) buildenvironment.BuildEnvironment._default_path = olddefaultpath self.assertTrue(self.default_path in buildenv.env['PATH']) - def test_uses_env_path_with_keep_path(self): - self.settings['keep-path'] = True - - old_osenv = buildenvironment.BuildEnvironment._osenv - buildenvironment.BuildEnvironment._osenv = self.fake_env - buildenv = buildenvironment.BuildEnvironment(self.settings) - buildenvironment.BuildEnvironment._osenv = old_osenv - - self.assertEqual(buildenv.env['PATH'], self.fake_env['PATH']) - - def test_uses_env_path_with_bootstrap(self): - self.settings['bootstrap'] = True - - old_osenv = buildenvironment.BuildEnvironment._osenv - buildenvironment.BuildEnvironment._osenv = self.fake_env - buildenv = buildenvironment.BuildEnvironment(self.settings) - buildenvironment.BuildEnvironment._osenv = old_osenv - - self.assertEqual(buildenv.env['PATH'], self.fake_env['PATH']) - def test_copies_whitelist_vars(self): env = self.fake_env safe = { 'DISTCC_HOSTS': 'example.com:example.co.uk', - 'TMPDIR': '/buildenv/tmp/dir', 'LD_PRELOAD': '/buildenv/lib/libbuildenv.so', 'LD_LIBRARY_PATH': '/buildenv/lib:/buildenv/lib64', 'FAKEROOTKEY': 'b011de73', @@ -120,8 +94,6 @@ class BuildEnvironmentTests(unittest.TestCase): self.settings['target-cflags']) self.assertEqual(buildenv.env['PREFIX'], self.settings['prefix']) - self.assertEqual(buildenv.env['BOOTSTRAP'], - 'true' if self.settings['bootstrap'] else 'false') def test_ccache_vars_set(self): self.settings['no-ccache'] = False diff --git a/morphlib/builder2.py b/morphlib/builder2.py index 73745d66..6f7836e3 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -54,6 +54,9 @@ def ldconfig(runcmd, rootdir): # pragma: no cover ''' + # FIXME: use the version in ROOTDIR, since even in + # bootstrap it will now always exist due to being part of build-essential + conf = os.path.join(rootdir, 'etc', 'ld.so.conf') if os.path.exists(conf): logging.debug('Running ldconfig for %s' % rootdir) diff --git a/morphlib/source.py b/morphlib/source.py index b536cbdf..99b0a993 100644 --- a/morphlib/source.py +++ b/morphlib/source.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests.as-root/setup b/tests.as-root/setup index 03a438e0..a85507e0 100755 --- a/tests.as-root/setup +++ b/tests.as-root/setup @@ -200,7 +200,6 @@ cat <<EOF > "$DATADIR/morph.conf" repo-alias = test=file://$DATADIR/#file://$DATADIR/ cachedir = $DATADIR/cache log = $DATADIR/morph.log -keep-path = true no-distcc = true quiet = true log = /tmp/morph.log diff --git a/tests.branching/setup b/tests.branching/setup index c0dfd969..1fa5b8e3 100755 --- a/tests.branching/setup +++ b/tests.branching/setup @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,7 +32,6 @@ cat <<EOF > "$DATADIR/morph.conf" repo-alias = test=file://$DATADIR/%s#file://$DATADIR/%s cachedir = $DATADIR/workspace/.morph/cache log = $DATADIR/morph.log -keep-path = true no-distcc = true quiet = true EOF diff --git a/tests.deploy/setup b/tests.deploy/setup index 1065849d..b0054fa5 100755 --- a/tests.deploy/setup +++ b/tests.deploy/setup @@ -196,7 +196,6 @@ cat <<EOF > "$DATADIR/morph.conf" repo-alias = test=file://$DATADIR/#file://$DATADIR/ cachedir = $DATADIR/cache log = $DATADIR/morph.log -keep-path = true no-distcc = true quiet = true log = /tmp/morph.log diff --git a/tests.merging/setup b/tests.merging/setup index c0dfd969..1fa5b8e3 100755 --- a/tests.merging/setup +++ b/tests.merging/setup @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,7 +32,6 @@ cat <<EOF > "$DATADIR/morph.conf" repo-alias = test=file://$DATADIR/%s#file://$DATADIR/%s cachedir = $DATADIR/workspace/.morph/cache log = $DATADIR/morph.log -keep-path = true no-distcc = true quiet = true EOF diff --git a/tests/setup b/tests/setup index 25472dc7..50fd5bd4 100755 --- a/tests/setup +++ b/tests/setup @@ -10,7 +10,7 @@ # The stratum repository contains a single branch, "master", with a # stratum and a system morphology that include the chunk above. # -# Copyright (C) 2011, 2012 Codethink Limited +# Copyright (C) 2011-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -128,7 +128,6 @@ cat <<EOF > "$DATADIR/morph.conf" repo-alias = test=file://$DATADIR/%s#file://$DATADIR/%s cachedir = $DATADIR/cache log = $DATADIR/morph.log -keep-path = true no-distcc = true quiet = true EOF |