summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-01 13:04:20 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-01 13:04:20 +0000
commit2d82bc7382628c7adf382dd2f82193fd43725c5b (patch)
tree46a6dea5e4ced4fe1b5788ef6985b4ab4462532c
parent31facb65e836be5edfa2f1dba70df1f823e3a079 (diff)
downloadimport-2d82bc7382628c7adf382dd2f82193fd43725c5b.tar.gz
Fix potential issue where two packages of different kinds share a name
This isn't a perfect fix. If this situation occurs the tool will generate an invalid stratum and the user will need to rename one of the chunks. But this is a better than what would have happened before: one of the chunks would have been silently ignored.
-rw-r--r--baserockimport/mainloop.py31
-rw-r--r--baserockimport/package.py6
2 files changed, 19 insertions, 18 deletions
diff --git a/baserockimport/mainloop.py b/baserockimport/mainloop.py
index 32dbf24..36a7016 100644
--- a/baserockimport/mainloop.py
+++ b/baserockimport/mainloop.py
@@ -260,19 +260,19 @@ class ImportLoop(object):
version, is_build_dep,
to_process, processed, errors):
failed_dep_package = find(
- errors, lambda i: i.match(name, version))
+ errors, lambda i: i.match(kind, name, version))
if failed_dep_package:
logging.debug(
"Ignoring %s as it failed earlier.", failed_dep_package)
return
dep_package = find(
- processed, lambda i: i.match(name, version))
+ processed, lambda i: i.match(kind, name, version))
if dep_package is None:
# Not yet processed
queue_item = find(
- to_process, lambda i: i.match(name, version))
+ to_process, lambda i: i.match(kind, name, version))
if queue_item is None:
queue_item = baserockimport.package.Package(
kind, name, version)
@@ -568,21 +568,20 @@ class ImportLoop(object):
else:
raise cliapp.AppException('No morphology for %s' % package)
- def format_build_dep(name, version):
- dep_package = find(graph, lambda p: p.match(name, version))
+ def format_build_dep(kind, name, version):
+ dep_package = find(
+ graph, lambda p: p.match(kind, name, version))
return '%s-%s' % (name, dep_package.version_in_use)
- def get_build_deps(morphology):
- deps = dict()
- for kind in self.importers:
- field = 'x-build-dependencies-%s' % kind
- deps.update(morphology.get(field, []))
- return deps
-
- build_depends = [
- format_build_dep(name, version) for name, version in
- get_build_deps(m).iteritems()
- ]
+ def get_build_deps(morphology, kind):
+ field = 'x-build-dependencies-%s' % kind
+ return morphology.get(field, {})
+
+ build_depends = []
+ for kind in self.importers:
+ for name, version in get_build_deps(m, kind).iteritems():
+ build_depends.extend(
+ format_build_dep(kind, name, version))
entry = {
'name': m['name'],
diff --git a/baserockimport/package.py b/baserockimport/package.py
index 6095b30..1739292 100644
--- a/baserockimport/package.py
+++ b/baserockimport/package.py
@@ -48,8 +48,10 @@ class Package(object):
def add_required_by(self, item):
self.required_by.append('%s-%s' % (item.name, item.version))
- def match(self, name, version):
- return (self.name==name and self.version==version)
+ def match(self, kind, name, version):
+ return (self.kind == kind and
+ self.name == name and
+ self.version == version)
# FIXME: these accessors are useless, but I want there to be some way
# of making it clear that some of the state of the Package object is