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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-09-05 15:34:38 +12:00
parent c629787630
commit b34d5072d7

View File

@ -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