---
morphlib/builder2.py | 54 ++++++++++++++++++++
.../plugins/syslinux-disk-systembuilder_plugin.py | 54 +-------------------
morphlib/plugins/tarball-systembuilder_plugin.py | 54 +-------------------
3 files changed, 56 insertions(+), 106 deletions(-)
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index 5362dd3..dd3c530 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -476,6 +476,60 @@ class SystemKindBuilder(BuilderBase): # pragma: no cover
'''
+ def unpack_strata(self, path):
+ '''Unpack strata into a directory.'''
+
+ self.app.status(msg='Unpacking strata to %(path)s',
+ path=path, chatty=True)
+ with self.build_watch('unpack-strata'):
+ # download the stratum artifacts if necessary
+ download_depends(self.artifact.dependencies,
+ self.local_artifact_cache,
+ self.remote_artifact_cache,
+ ('meta',))
+
+ # download the chunk artifacts if necessary
+ for stratum_artifact in self.artifact.dependencies:
+ f = self.local_artifact_cache.get(stratum_artifact)
+ chunks = [ArtifactCacheReference(a) for a in json.load(f)]
+ download_depends(chunks,
+ self.local_artifact_cache,
+ self.remote_artifact_cache)
+ f.close()
+
+ # check whether the strata overlap
+ overlaps = get_overlaps(self.artifact, self.artifact.dependencies,
+ self.local_artifact_cache)
+ if len(overlaps) > 0:
+ self.app.status(msg='Overlaps in system artifact '
+ '%(artifact_name)s detected',
+ artifact_name=self.artifact.name,
+ error=True)
+ log_overlaps(overlaps)
+ write_overlap_metadata(self.artifact, overlaps,
+ self.local_artifact_cache)
+
+ # unpack it from the local artifact cache
+ for stratum_artifact in self.artifact.dependencies:
+ f = self.local_artifact_cache.get(stratum_artifact)
+ for chunk in (ArtifactCacheReference(a) for a in json.load(f)):
+ self.app.status(msg='Unpacking chunk %(basename)s',
+ basename=chunk.basename(), chatty=True)
+ chunk_handle = self.local_artifact_cache.get(chunk)
+ morphlib.bins.unpack_binary_from_file(chunk_handle, path)
+ chunk_handle.close()
+ f.close()
+ meta = self.local_artifact_cache.get_artifact_metadata(
+ stratum_artifact, 'meta')
+ dst = morphlib.savefile.SaveFile(
+ os.path.join(path, 'baserock',
+ '%s.meta' % stratum_artifact.name),
'w')
+ shutil.copyfileobj(meta, dst)
+ dst.close()
+ meta.close()
+
+ ldconfig(self.app.runcmd, path)
+
class SystemKindBuilderFactory(object): # pragma: no cover
diff --git a/morphlib/plugins/syslinux-disk-systembuilder_plugin.py
b/morphlib/plugins/syslinux-disk-systembuilder_plugin.py
index 7d46d61..41a9500 100644
--- a/morphlib/plugins/syslinux-disk-systembuilder_plugin.py
+++ b/morphlib/plugins/syslinux-disk-systembuilder_plugin.py
@@ -58,7 +58,7 @@ class SyslinuxDiskBuilder(SystemKindBuilder): # pragma: no cover
self._mount(partition, mount_point)
factory_path = os.path.join(mount_point, 'factory')
self._create_subvolume(factory_path)
- self._unpack_strata(factory_path)
+ self.unpack_strata(factory_path)
self._create_fstab(factory_path)
self._create_extlinux_config(factory_path)
self._create_subvolume_snapshot(
@@ -139,58 +139,6 @@ class SyslinuxDiskBuilder(SystemKindBuilder): # pragma: no cover
with self.build_watch('create-factory-subvolume'):
self.app.runcmd(['btrfs', 'subvolume', 'create',
path])
- def _unpack_strata(self, path):
- self.app.status(msg='Unpacking strata to %(path)s',
- path=path, chatty=True)
- with self.build_watch('unpack-strata'):
- # download the stratum artifacts if necessary
- download_depends(self.artifact.dependencies,
- self.local_artifact_cache,
- self.remote_artifact_cache,
- ('meta',))
-
- # download the chunk artifacts if necessary
- for stratum_artifact in self.artifact.dependencies:
- f = self.local_artifact_cache.get(stratum_artifact)
- chunks = [ArtifactCacheReference(a) for a in json.load(f)]
- download_depends(chunks,
- self.local_artifact_cache,
- self.remote_artifact_cache)
- f.close()
-
- # check whether the strata overlap
- overlaps = get_overlaps(self.artifact, self.artifact.dependencies,
- self.local_artifact_cache)
- if len(overlaps) > 0:
- self.app.status(msg='Overlaps in system artifact '
- '%(artifact_name)s detected',
- artifact_name=self.artifact.name,
- error=True)
- log_overlaps(overlaps)
- write_overlap_metadata(self.artifact, overlaps,
- self.local_artifact_cache)
-
- # unpack it from the local artifact cache
- for stratum_artifact in self.artifact.dependencies:
- f = self.local_artifact_cache.get(stratum_artifact)
- for chunk in (ArtifactCacheReference(a) for a in json.load(f)):
- self.app.status(msg='Unpacking chunk %(basename)s',
- basename=chunk.basename(), chatty=True)
- chunk_handle = self.local_artifact_cache.get(chunk)
- morphlib.bins.unpack_binary_from_file(chunk_handle, path)
- chunk_handle.close()
- f.close()
- meta = self.local_artifact_cache.get_artifact_metadata(
- stratum_artifact, 'meta')
- dst = morphlib.savefile.SaveFile(
- os.path.join(path, 'baserock',
- '%s.meta' % stratum_artifact.name),
'w')
- shutil.copyfileobj(meta, dst)
- dst.close()
- meta.close()
-
- ldconfig(self.app.runcmd, path)
-
def _create_fstab(self, path):
self.app.status(msg='Creating fstab in %(path)s',
path=path, chatty=True)
diff --git a/morphlib/plugins/tarball-systembuilder_plugin.py
b/morphlib/plugins/tarball-systembuilder_plugin.py
index 5e5e26d..5582eec 100644
--- a/morphlib/plugins/tarball-systembuilder_plugin.py
+++ b/morphlib/plugins/tarball-systembuilder_plugin.py
@@ -49,7 +49,7 @@ class RootfsTarballBuilder(SystemKindBuilder): # pragma: no cover
try:
mount_point = self.staging_area.destdir(self.artifact.source)
factory_path = mount_point
- self._unpack_strata(factory_path)
+ self.unpack_strata(factory_path)
self._create_fstab(factory_path)
if arch in ('x86', 'x86_64'):
self._create_extlinux_config(factory_path)
@@ -73,58 +73,6 @@ class RootfsTarballBuilder(SystemKindBuilder): # pragma: no cover
self.save_build_times()
return [self.artifact]
- def _unpack_strata(self, path):
- self.app.status(msg='Unpacking strata to %(path)s',
- path=path, chatty=True)
- with self.build_watch('unpack-strata'):
- # download the stratum artifacts if necessary
- download_depends(self.artifact.dependencies,
- self.local_artifact_cache,
- self.remote_artifact_cache,
- ('meta',))
-
- # download the chunk artifacts if necessary
- for stratum_artifact in self.artifact.dependencies:
- f = self.local_artifact_cache.get(stratum_artifact)
- chunks = [ArtifactCacheReference(a) for a in json.load(f)]
- download_depends(chunks,
- self.local_artifact_cache,
- self.remote_artifact_cache)
- f.close()
-
- # check whether the strata overlap
- overlaps = get_overlaps(self.artifact, self.artifact.dependencies,
- self.local_artifact_cache)
- if len(overlaps) > 0:
- self.app.status(msg='Overlaps in system artifact '
- '%(artifact_name)s detected',
- artifact_name=self.artifact.name,
- error=True)
- log_overlaps(overlaps)
- write_overlap_metadata(self.artifact, overlaps,
- self.local_artifact_cache)
-
- # unpack it from the local artifact cache
- for stratum_artifact in self.artifact.dependencies:
- f = self.local_artifact_cache.get(stratum_artifact)
- for chunk in (ArtifactCacheReference(a) for a in json.load(f)):
- self.app.status(msg='Unpacking chunk %(basename)s',
- basename=chunk.basename(), chatty=True)
- chunk_handle = self.local_artifact_cache.get(chunk)
- morphlib.bins.unpack_binary_from_file(chunk_handle, path)
- chunk_handle.close()
- f.close()
- meta = self.local_artifact_cache.get_artifact_metadata(
- stratum_artifact, 'meta')
- dst = morphlib.savefile.SaveFile(
- os.path.join(path, 'baserock',
- '%s.meta' % stratum_artifact.name),
'w')
- shutil.copyfileobj(meta, dst)
- dst.close()
- meta.close()
-
- ldconfig(self.app.runcmd, path)
-
def _create_fstab(self, path):
self.app.status(msg='Creating fstab in %(path)s',
path=path, chatty=True)
--
1.7.2.5