From b34d5072d712ee15ce2c2199121dccd3af329acf Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Wed, 5 Sep 2018 15:34:38 +1200 Subject: [PATCH] rrs_distros: match recipe on filename not PN In the current RRS we should expect that more than one recipe with the same PN can exist in a layer - in fact it is common to have this (i.e. multiple versions of the same recipe). Use the filename to match the recipe record instead. At the same time, fix the exception handling. Signed-off-by: Paul Eggleton --- rrs/tools/rrs_distros.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rrs/tools/rrs_distros.py b/rrs/tools/rrs_distros.py index c8ccf66..6942254 100755 --- a/rrs/tools/rrs_distros.py +++ b/rrs/tools/rrs_distros.py @@ -22,6 +22,7 @@ from layerindex import utils utils.setup_django() from django.db import transaction +from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned import settings logger = get_logger("RecipeDistros", settings) @@ -139,11 +140,16 @@ if __name__=="__main__": for recipe_data in recipes: pn = recipe_data.getVar('PN', True) + fn = os.path.basename(recipe_data.getVar('FILE', True)) try: - recipe = Recipe.objects.get(pn = pn, layerbranch = layerbranch) - except: - logger.warn('%s: layer branch %s, NOT found' % (pn, + recipe = Recipe.objects.get(filename=fn, layerbranch=layerbranch) + except MultipleObjectsReturned: + logger.warn('Recipe file %s appears more than once in layerbranch %s!' % (fn, + str(layerbranch))) + continue + except ObjectDoesNotExist: + logger.warn('Recipe file %s not found in layerbranch %s' % (fn, str(layerbranch))) continue