From c9ce6b5d0ad03238d4cabb00582456635d577f5d Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 6 May 2020 16:04:19 -0700 Subject: [PATCH] Tweak get_virtinstall_images to not include dupes Some of the version config directives make it possible to wind up with dupes - for instance, our config for the 'minimal' image can result in multiple instances of VirtInstallImage for F31 appearing in the list, meaning we'll build the same image two or more times in the same run. That's silly! Let's not do that. Using a dict keyed on the release number and arch we wind up with after interpreting the config file should avoid it. Signed-off-by: Adam Williamson --- createhdds.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/createhdds.py b/createhdds.py index 5c85ddb..3514143 100755 --- a/createhdds.py +++ b/createhdds.py @@ -456,7 +456,7 @@ def get_virtinstall_images(imggrp, nextrel=None, releases=None): -2 means 'two releases lower than the "next" release', and so on. The values are the arches to build for that release. """ - imgs = [] + imgs = {} # Set this here so if we need to calculate it, we only do it once if not nextrel: nextrel = 0 @@ -502,10 +502,11 @@ def get_virtinstall_images(imggrp, nextrel=None, releases=None): # we can just ditch them from hdds.json and remove this if arch == 'i686' and (rel == 'rawhide' or int(rel) > 30): continue - imgs.append( - VirtInstallImage(name, rel, arch, variant=variant, size=size, imgver=imgver, - maxage=maxage, bootopts=bootopts)) - return imgs + key = "{0}-{1}".format(rel, arch) + # using a dict here avoids dupes + imgs[key] = VirtInstallImage(name, rel, arch, variant=variant, size=size, + imgver=imgver, maxage=maxage, bootopts=bootopts) + return list(imgs.values()) def get_all_images(hdds, nextrel=None): """Simply iterates over the 'image group' dicts in hdds.json and