summaryrefslogtreecommitdiff
path: root/baserockimport/mainloop.py
diff options
context:
space:
mode:
Diffstat (limited to 'baserockimport/mainloop.py')
-rw-r--r--baserockimport/mainloop.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/baserockimport/mainloop.py b/baserockimport/mainloop.py
index 057ab98..8a7ae26 100644
--- a/baserockimport/mainloop.py
+++ b/baserockimport/mainloop.py
@@ -202,7 +202,7 @@ class ImportLoop(object):
# 1. Make the source code available.
- lorry = self._find_or_create_lorry_file(kind, name)
+ lorry = self._find_or_create_lorry_file(kind, name, version)
source_repo, url = self._fetch_or_update_source(lorry)
checked_out_version, ref = self._checkout_source_version_for_package(
@@ -288,15 +288,22 @@ class ImportLoop(object):
dep_package.set_is_build_dep(True)
processed.add_edge(dep_package, current_item)
- def _find_or_create_lorry_file(self, kind, name):
+ def _find_or_create_lorry_file(self, kind, name, version):
# Note that the lorry file may already exist for 'name', but lorry
# files are named for project name rather than package name. In this
# case we will generate the lorry, and try to add it to the set, at
# which point LorrySet will notice the existing one and merge the two.
- lorry = self.lorry_set.find_lorry_for_package(kind, name)
+ comp = None
+
+ if 'package_comp_callback' in self.importers[kind]['kwargs']:
+ comp = self.importers[kind]['kwargs']['package_comp_callback']
+ else:
+ comp = lambda x, y: x == y
+
+ lorry = self.lorry_set.find_lorry_for_package(kind, name, comp)
if lorry is None:
- lorry = self._generate_lorry_for_package(kind, name)
+ lorry = self._generate_lorry_for_package(kind, name, version)
if len(lorry) != 1:
raise Exception(
@@ -323,14 +330,18 @@ class ImportLoop(object):
return lorry
- def _generate_lorry_for_package(self, kind, name):
+ def _generate_lorry_for_package(self, kind, name, version):
tool = '%s.to_lorry' % kind
if kind not in self.importers:
raise Exception('Importer for %s was not enabled.' % kind)
extra_args = self.importers[kind]['extra_args']
self.app.status(
'%s: calling %s to generate lorry', name, tool)
- lorry_text = run_extension(tool, extra_args + [name])
+
+ args = extra_args + [name]
+ if version != 'master':
+ args.append(version)
+ lorry_text = run_extension(tool, args)
try:
lorry = json.loads(lorry_text)
except ValueError: