summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--morphlib/buildcommand.py26
-rw-r--r--morphlib/stagingarea.py20
-rw-r--r--morphlib/stagingarea_tests.py9
3 files changed, 16 insertions, 39 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index 4200dc0e..c7c650d3 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -224,8 +224,7 @@ class BuildCommand(object):
self.install_chunk_artifacts(staging_area,
deps, artifact)
morphlib.builder2.ldconfig(self.app.runcmd,
- staging_area.tempdir)
-
+ staging_area.dirname)
self.build_and_cache(staging_area, artifact)
self.remove_staging_area(staging_area)
self.app.status(msg='%(kind)s %(name)s is cached at %(cachepath)s',
@@ -315,32 +314,19 @@ class BuildCommand(object):
def create_staging_area(self, artifact):
'''Create the staging area for building a single artifact.'''
- 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,
- staging_root,
- staging_temp)
+ staging_dir = tempfile.mkdtemp(dir=self.app.settings['tempdir'])
+ staging_area = morphlib.stagingarea.StagingArea(self.app, staging_dir)
return staging_area
def remove_staging_area(self, staging_area):
'''Remove the staging area.'''
- if staging_area.dirname != '/':
- self.app.status(msg='Removing staging area')
- staging_area.remove()
- temp_path = staging_area.tempdir
- if temp_path != '/' and os.path.exists(temp_path):
- self.app.status(msg='Removing temporary staging directory')
- shutil.rmtree(temp_path)
+ self.app.status(msg='Removing staging area')
+ staging_area.remove()
def install_fillers(self, staging_area):
- '''Install staging fillers into the staging area.
-
- This must not be called in bootstrap mode.
-
- '''
+ '''Install staging fillers into the staging area.'''
logging.debug('Pre-populating staging area %s' % staging_area.dirname)
logging.debug('Fillers: %s' %
diff --git a/morphlib/stagingarea.py b/morphlib/stagingarea.py
index ae9e7e39..24d4ebf9 100644
--- a/morphlib/stagingarea.py
+++ b/morphlib/stagingarea.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012,2013 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
@@ -27,21 +27,17 @@ class StagingArea(object):
'''Represent the staging area for building software.
- The build dependencies of what will be built will be installed in the
- staging area. The staging area may be a dedicated part of the
- filesystem, used with chroot, or it can be the actual root of the
- filesystem, which is needed when bootstrap building Baserock. The
- caller chooses this by providing the root directory of the staging
- area when the object is created. The directory must already exist.
-
- The staging area can also install build artifacts.
+ The staging area is a temporary directory. In normal operation the build
+ dependencies of the artifact being built are installed into the staging
+ area and then 'chroot' is used to isolate the build processes from the host
+ system. Chunks built in 'test' or 'build-essential' mode have an empty
+ staging area and are allowed to use the tools of the host.
'''
- def __init__(self, app, dirname, tempdir):
+ def __init__(self, app, dirname):
self._app = app
self.dirname = dirname
- self.tempdir = tempdir
self.builddirname = None
self.destdirname = None
self.mounted = None
@@ -52,7 +48,7 @@ class StagingArea(object):
os.mkdir(dirname)
def _dir_for_source(self, source, suffix):
- dirname = os.path.join(self.tempdir,
+ dirname = os.path.join(self.dirname,
'%s.%s' % (source.morphology['name'], suffix))
self._mkdir(dirname)
return dirname
diff --git a/morphlib/stagingarea_tests.py b/morphlib/stagingarea_tests.py
index 313226d2..5c547f6e 100644
--- a/morphlib/stagingarea_tests.py
+++ b/morphlib/stagingarea_tests.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012,2013 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
@@ -57,8 +57,7 @@ class StagingAreaTests(unittest.TestCase):
self.staging = os.path.join(self.tempdir, 'staging')
self.created_dirs = []
self.sa = morphlib.stagingarea.StagingArea(
- FakeApplication(self.cachedir, self.tempdir),
- self.staging, self.staging)
+ FakeApplication(self.cachedir, self.tempdir), self.staging)
def tearDown(self):
shutil.rmtree(self.tempdir)
@@ -89,10 +88,6 @@ class StagingAreaTests(unittest.TestCase):
def test_remembers_specified_directory(self):
self.assertEqual(self.sa.dirname, self.staging)
- def test_accepts_root_directory(self):
- sa = morphlib.stagingarea.StagingArea(object(), '/', '/tmp')
- self.assertEqual(sa.dirname, '/')
-
def test_creates_build_directory(self):
source = FakeSource()
self.sa._mkdir = self.fake_mkdir