diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-01-26 15:44:12 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-01-26 16:56:41 +0000 |
commit | 862dbd4d73714e5f654401ce072d8d9bc0d03a7b (patch) | |
tree | c87961ee656b766ca1599b91c56f15bf15fe46dd /morphlib/builder.py | |
parent | ba7f8f8421998f52233d5a2eab0214f40638ef7a (diff) | |
download | morph-862dbd4d73714e5f654401ce072d8d9bc0d03a7b.tar.gz |
Add a "build-single" command to build a blob without its dependencies.
...while at the same time making sure that all dependencies are marked
for staging prior to building the blob itself.
Diffstat (limited to 'morphlib/builder.py')
-rw-r--r-- | morphlib/builder.py | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py index 038ec564..53127223 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -546,8 +546,8 @@ class Builder(object): for parent in blob.parents: for item, filename in built_items: - self.msg('Marking %s to be staged for %s' - % (item, parent)) + self.msg('Marking %s to be staged for %s' % + (item, parent)) parent_builder = builders[parent] parent_builder.stage_items += built_items @@ -558,6 +558,39 @@ class Builder(object): return ret + def build_single(self, blob, blobs, build_order): + self.indent_more() + + # first pass: create builders for all blobs + builders = {} + for group in build_order: + for blob in group: + builder = self.create_blob_builder(blob) + builders[blob] = builder + + # second pass: walk the build order blob by blob, mark blobs + # to be staged for their parents, but do not build them + ret = [] + for group in build_order: + for blob in group: + built_items = builders[blob].builds() + for parent in blob.parents: + stage_items = [] + for name, filename in built_items.items(): + self.msg('Marking %s to be staged for %s' % + (name, parent)) + stage_items.append((name, filename)) + + parent_builder = builders[parent] + parent_builder.stage_items.extend(stage_items) + + # build the single blob now + ret.append(builders[blob].build()) + + self.indent_less() + + return ret + def create_blob_builder(self, blob): if isinstance(blob, morphlib.blobs.Stratum): builder = StratumBuilder(blob) |