layerindex/update_layer.py: Preserve the recipedependency files

In order to keep primary keys from constantly changing, preserve the
existing keys as much as possible.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@WindRiver.com>
This commit is contained in:
Mark Hatle 2016-09-28 14:24:53 -05:00 committed by Paul Eggleton
parent b1375847d9
commit 9282cba99f

View File

@ -88,13 +88,30 @@ def update_recipe_file(tinfoil, data, path, recipe, layerdir_start, repodir):
if depstr.startswith(layerdir_start) and not depstr.endswith('/conf/layer.conf'): if depstr.startswith(layerdir_start) and not depstr.endswith('/conf/layer.conf'):
filedeps.append(os.path.relpath(depstr, repodir)) filedeps.append(os.path.relpath(depstr, repodir))
from layerindex.models import RecipeFileDependency from layerindex.models import RecipeFileDependency
RecipeFileDependency.objects.filter(recipe=recipe).delete()
recipedeps_delete = []
recipedeps = RecipeFileDependency.objects.filter(recipe=recipe)
for values in recipedeps.values('path'):
if 'path' in values:
recipedeps_delete.append(values['path'])
for filedep in filedeps: for filedep in filedeps:
if filedep in recipedeps_delete:
recipedeps_delete.remove(filedep)
continue
# New item, add it...
recipedep = RecipeFileDependency() recipedep = RecipeFileDependency()
recipedep.layerbranch = recipe.layerbranch recipedep.layerbranch = recipe.layerbranch
recipedep.recipe = recipe recipedep.recipe = recipe
recipedep.path = filedep recipedep.path = filedep
recipedep.save() recipedep.save()
for filedep in recipedeps_delete:
logger.debug('%s: removing %s' % (recipe.layerbranch, filedep))
recipedeps.filter(path=filedep).delete()
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except BaseException as e: except BaseException as e: