diff options
author | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-09-01 10:15:36 +0000 |
---|---|---|
committer | Baserock Gerrit <gerrit@baserock.org> | 2015-09-22 16:53:46 +0000 |
commit | 50247e57320de74e88049101e1ad47fb8e78b5a3 (patch) | |
tree | ec3f0fcedf9b9ef2a7ed1c49ed96d9bf994279a0 /morphlib/builder.py | |
parent | 81ebe71089d802061c2c3cb03bfd548388d04cb8 (diff) | |
download | morph-50247e57320de74e88049101e1ad47fb8e78b5a3.tar.gz |
Simplify StagingArea class
Pass the Source to the staging area constructor so that we don't need to
pass it as a parameter when we call some StagingArea methods. Also move
the creation of the build and destdir directories to the constructor so
that we can get rid of the chroot_open() and chroot_close() methods.
Also, provide API to retrieve the relative locations for buildir and
destdir.
Change-Id: I6e8085392e19ff3d8df807f260acf90eec9e0901
Diffstat (limited to 'morphlib/builder.py')
-rw-r--r-- | morphlib/builder.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py index 58667159..bc674548 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -271,8 +271,8 @@ class ChunkBuilder(BuilderBase): def build_and_cache(self): # pragma: no cover with self.build_watch('overall-build'): - builddir, destdir = self.staging_area.chroot_open( - self.source, self.setup_mounts) + builddir = self.staging_area.real_builddir() + destdir = self.staging_area.real_destdir() stdout = (self.app.output if self.app.settings['build-log-on-stdout'] else None) @@ -285,14 +285,13 @@ class ChunkBuilder(BuilderBase): try: self.get_sources(builddir) - self.run_commands(builddir, destdir, temppath, stdout) + self.run_commands(temppath, stdout) self.create_devices(destdir) os.rename(temppath, logpath) except BaseException as e: logging.error('Caught exception: %s' % str(e)) logging.info('Cleaning up staging area') - self.staging_area.chroot_close() if os.path.isfile(temppath): with open(temppath) as f: for line in f: @@ -304,21 +303,20 @@ class ChunkBuilder(BuilderBase): logging.error("Couldn't find build log at %s", temppath) raise - self.staging_area.chroot_close() built_artifacts = self.assemble_chunk_artifacts(destdir) self.save_build_times() return built_artifacts - def run_commands(self, builddir, destdir, - logfilepath, stdout=None): # pragma: no cover + def run_commands(self, logfilepath, stdout=None): # pragma: no cover m = self.source.morphology bs = morphlib.buildsystem.lookup_build_system(m['build-system']) - relative_builddir = self.staging_area.relative(builddir) - relative_destdir = self.staging_area.relative(destdir) - ccache_dir = self.staging_area.ccache_dir(self.source) + relative_builddir = self.staging_area.relative_builddir() + relative_destdir = self.staging_area.relative_destdir() + ccache_dir = self.staging_area.ccache_dir() + extra_env = { 'DESTDIR': relative_destdir } steps = [ @@ -552,7 +550,7 @@ class SystemBuilder(BuilderBase): # pragma: no cover handle = self.local_artifact_cache.put(artifact) try: - fs_root = self.staging_area.destdir(self.source) + fs_root = self.staging_area.real_destdir() self.unpack_strata(fs_root) self.write_metadata(fs_root, a_name) self.run_system_integration_commands(fs_root) |