From b72cc9a9ea7537125bcd813473ee52dc39712719 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 25 Mar 2016 13:55:01 +0000 Subject: Fixes needed Change-Id: Ie527ff7228987afbfcce3c105d6d9192a366e65d --- morphlib/builder.py | 13 +++++++------ morphlib/sourceresolver.py | 28 +--------------------------- yarns/building.yarn | 10 ++++------ yarns/implementations.yarn | 4 ++-- 4 files changed, 14 insertions(+), 41 deletions(-) diff --git a/morphlib/builder.py b/morphlib/builder.py index e2abee9e..eb7fdfc1 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -60,18 +60,22 @@ def extract_sources(app, definitions_version, repo_cache, repo, sha1, return tuples return [] - def extract_repo_version_8(repo, ref, extra_sources, + def extract_repo_version_8(repo, sha1, extra_sources, rootdir, destdir): app.status(msg='Extracting %(source)s into %(path)s', source=repo.original_name, path=destdir) - repo.checkout(ref, destdir) + morphlib.gitdir.checkout_from_cached_repo(repo, sha1, destdir) morphlib.git.reset_workdir(app.runcmd, destdir) for extra_source in extra_sources: - subrepo = repo_cache.get_repo(extra_source['repo']) + subref = extra_source.get('ref') path = os.path.normpath(extra_source['path']) + if not subref: + subref = repo.get_submodule_commit(sha1, path) + subrepo = repo_cache.get_updated_repo(extra_source['repo'], + subref) checkout_dir = os.path.join(destdir, path) if os.path.exists(checkout_dir): if os.listdir(checkout_dir): @@ -82,9 +86,6 @@ def extract_sources(app, definitions_version, repo_cache, repo, sha1, rootdir, path))) else: os.makedirs(checkout_dir) - subref = extra_source.get('ref') - if not subref: - subref = repo.get_submodule_commit(ref, path) extract_repo_version_8(subrepo, subref, extra_source.get('extra-sources', []), diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py index a56b6594..0b6e1409 100644 --- a/morphlib/sourceresolver.py +++ b/morphlib/sourceresolver.py @@ -273,22 +273,7 @@ class SourceResolver(object): else: subref = extra_source.get('ref') if not subref: - if self.lrc.has_repo(reponame): - repo = self.lrc.get_repo(reponame) - if self.update and ( - repo.requires_update_for_ref(ref)): - self.status(msg='Updating cached git ' - 'repository %(reponame)s for ' - 'ref %(ref)s', - reponame=reponame, ref=ref) - repo.update() - else: - # TODO Add support to the cache server for - # retrieving the submodule commit from a path - self.status(msg='Updating cached git repository ' - '%(reponame)s for ref %(ref)s', - reponame=reponame, ref=ref) - repo = self.lrc.get_updated_repo(reponame, ref) + repo = self.repo_cache.get_updated_repo(reponame, ref) subref = repo.get_submodule_commit( ref, extra_source['path']) _, tree = self._resolve_ref(resolved_trees, @@ -540,17 +525,6 @@ def create_source_pool(repo_cache, repo, ref, filenames, def add_to_pool(reponame, ref, filename, absref, tree, morphology, predefined_split_rules, subtrees): - # If there are duplicate chunks which have the same 'name' and the - # same build instructions, we might cause a stack overflow in - # cachekeycomputer.py when trying to hash the build graph. The - # _find_duplicate_chunks() function doesn't handle this case, it - # is checking for duplicates with the same name but different build - # instructions. - if morphology['kind'] != 'stratum': - if pool.lookup(reponame, ref, filename): - raise morphlib.Error( - "There are multiple versions of component '%s'" % - morphology['name']) sources = morphlib.source.make_sources( reponame, ref, filename, absref, tree, morphology, diff --git a/yarns/building.yarn b/yarns/building.yarn index 3aea709f..fd4bdcb2 100644 --- a/yarns/building.yarn +++ b/yarns/building.yarn @@ -90,19 +90,17 @@ Morph Building Tests FINALLY the git server is shut down SCENARIO test recursive sources for a chunk - GIVEN a workspace - AND a git server + GIVEN a git server GIVEN a chunk with dependencies - WHEN the user checks out the system branch called master + WHEN the user clones definitions WHEN the user attempts to build the system systems/test-system.morph in branch master THEN morph succeeded FINALLY the git server is shut down SCENARIO test recursive sources with non-empty path - GIVEN a workspace - AND a git server + GIVEN a git server GIVEN a chunk with recursive sources with non-empty paths - WHEN the user checks out the system branch called master + WHEN the user clones definitions WHEN the user attempts to build the system systems/test-system.morph in branch master THEN morph failed FINALLY the git server is shut down diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn index 8ed5a5e9..d100febb 100644 --- a/yarns/implementations.yarn +++ b/yarns/implementations.yarn @@ -46,7 +46,7 @@ we'll create a repository to hold system and stratum morphologies, and another to hold a chunk. IMPLEMENTS GIVEN a chunk with recursive sources with non-empty paths - cd "$DATADIR/gits/morphs" + cd "$DATADIR/gits/definitions" echo "version: 8" > VERSION cat << EOF >> strata/core.morph - name: invalid-chunk @@ -93,7 +93,7 @@ another to hold a chunk. git add . git commit -m "Add submodule" - cd "$DATADIR/gits/morphs" + cd "$DATADIR/gits/definitions" echo "version: 8" > VERSION cat << EOF >> strata/core.morph - name: chunk-with-submodules -- cgit v1.2.1