Allow layers to have no master branch

With BSPs being "retired" e.g. in meta-intel, it is possible for layers
to not exist on the master branch; since this is legitimate we need the
layer index to handle it.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2014-04-06 14:59:06 +01:00
parent 4c08b28387
commit f7fa15dd36
2 changed files with 19 additions and 12 deletions

View File

@ -63,7 +63,10 @@ class LayerItem(models.Model):
self.status = newstatus self.status = newstatus
def get_layerbranch(self, branchname): def get_layerbranch(self, branchname):
if branchname:
res = list(self.layerbranch_set.filter(branch__name=branchname)[:1]) res = list(self.layerbranch_set.filter(branch__name=branchname)[:1])
else:
res = list(self.layerbranch_set.all()[:1])
if res: if res:
return res[0] return res[0]
return None return None

View File

@ -278,17 +278,25 @@ def main():
layerbranch = LayerBranch() layerbranch = LayerBranch()
layerbranch.layer = layer layerbranch.layer = layer
layerbranch.branch = branch layerbranch.branch = branch
layerbranch_master = layer.get_layerbranch('master') layerbranch_source = layer.get_layerbranch('master')
if layerbranch_master: if not layerbranch_source:
layerbranch.vcs_subdir = layerbranch_master.vcs_subdir layerbranch_source = layer.get_layerbranch(None)
if layerbranch_source:
layerbranch.vcs_subdir = layerbranch_source.vcs_subdir
if layerbranch.vcs_subdir:
checksubdir = os.path.join(repodir, layerbranch.vcs_subdir)
if not os.path.exists(checksubdir):
logger.info("Skipping update of layer %s for branch %s - subdirectory %s does not exist on this branch" % (layer.name, branchdesc, layerbranch.vcs_subdir))
transaction.rollback()
continue
layerbranch.save() layerbranch.save()
if layerbranch_master: if layerbranch_source:
for maintainer in layerbranch_master.layermaintainer_set.all(): for maintainer in layerbranch_source.layermaintainer_set.all():
maintainer.pk = None maintainer.pk = None
maintainer.id = None maintainer.id = None
maintainer.layerbranch = layerbranch maintainer.layerbranch = layerbranch
maintainer.save() maintainer.save()
for dep in layerbranch_master.dependencies_set.all(): for dep in layerbranch_source.dependencies_set.all():
dep.pk = None dep.pk = None
dep.id = None dep.id = None
dep.layerbranch = layerbranch dep.layerbranch = layerbranch
@ -315,11 +323,7 @@ def main():
if not os.path.exists(layerdir): if not os.path.exists(layerdir):
if options.branch == 'master': if options.branch == 'master':
logger.error("Subdirectory for layer %s does not exist on branch %s!" % (layer.name, branchdesc)) logger.error("Subdirectory for layer %s does not exist on branch %s - if this is legitimate, the layer branch record should be deleted" % (layer.name, branchdesc))
transaction.rollback()
continue
else:
logger.info("Skipping update of layer %s for branch %s - subdirectory does not exist on this branch" % (layer.name, branchdesc))
transaction.rollback() transaction.rollback()
continue continue