From 35178357f0ba7eafdeebfc621d70ba69f2cd270a Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 24 Oct 2014 16:28:30 +0000 Subject: build: Allow passing in the name of the original ref to create_source_pool() This means that we can force the building of a specific commit without losing the original branch name in the metadata of the resulting system. --- morphlib/app.py | 12 +++++++++--- morphlib/buildcommand.py | 10 ++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/morphlib/app.py b/morphlib/app.py index 9ab102b3..c3c9c970 100644 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -290,7 +290,8 @@ class Morph(cliapp.Application): morphlib.util.sanitise_morphology_path(args[2])) args = args[3:] - def create_source_pool(self, lrc, rrc, repo, ref, filename): + def create_source_pool(self, lrc, rrc, repo, ref, filename, + original_ref=None): pool = morphlib.sourcepool.SourcePool() def add_to_pool(reponame, ref, filename, absref, tree, morphology): @@ -302,7 +303,8 @@ class Morph(cliapp.Application): self.traverse_morphs(repo, ref, [filename], lrc, rrc, update=not self.settings['no-git-update'], - visit=add_to_pool) + visit=add_to_pool, + definitions_original_ref=original_ref) return pool def resolve_ref(self, lrc, rrc, reponame, ref, update=True): @@ -346,7 +348,8 @@ class Morph(cliapp.Application): def traverse_morphs(self, definitions_repo, definitions_ref, system_filenames, lrc, rrc, update=True, - visit=lambda rn, rf, fn, arf, m: None): + visit=lambda rn, rf, fn, arf, m: None, + definitions_original_ref=None): morph_factory = morphlib.morphologyfactory.MorphologyFactory(lrc, rrc, self) definitions_queue = collections.deque(system_filenames) @@ -359,6 +362,9 @@ class Morph(cliapp.Application): definitions_absref, definitions_tree = self.resolve_ref( lrc, rrc, definitions_repo, definitions_ref, update) + if definitions_original_ref: + definitions_ref = definitions_original_ref + while definitions_queue: filename = definitions_queue.popleft() diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py index 650ee13a..544d88d8 100644 --- a/morphlib/buildcommand.py +++ b/morphlib/buildcommand.py @@ -50,7 +50,7 @@ class BuildCommand(object): self.lac, self.rac = self.new_artifact_caches() self.lrc, self.rrc = self.new_repo_caches() - def build(self, repo_name, ref, filename): + def build(self, repo_name, ref, filename, original_ref=None): '''Build a given system morphology.''' self.app.status( @@ -58,7 +58,8 @@ class BuildCommand(object): repo_name=repo_name, ref=ref, filename=filename) self.app.status(msg='Deciding on task order') - srcpool = self.create_source_pool(repo_name, ref, filename) + srcpool = self.create_source_pool( + repo_name, ref, filename, original_ref) self.validate_sources(srcpool) root_artifact = self.resolve_artifacts(srcpool) self.build_in_order(root_artifact) @@ -84,7 +85,7 @@ class BuildCommand(object): return morphlib.buildenvironment.BuildEnvironment(self.app.settings, arch) - def create_source_pool(self, repo_name, ref, filename): + def create_source_pool(self, repo_name, ref, filename, original_ref=None): '''Find the source objects required for building a the given artifact The SourcePool will contain every stratum and chunk dependency of the @@ -94,7 +95,8 @@ class BuildCommand(object): ''' self.app.status(msg='Creating source pool', chatty=True) srcpool = self.app.create_source_pool( - self.lrc, self.rrc, repo_name, ref, filename) + self.lrc, self.rrc, repo_name, ref, filename, + original_ref=original_ref) return srcpool -- cgit v1.2.1