From b1e084e93b5dab2c7ba3fe33a015b9f5386a890c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20R=C5=AF=C5=BEi=C4=8Dka?= Date: Wed, 3 Jan 2024 13:06:26 +0100 Subject: [PATCH] Use platform.machine() when processor() fails. With CPUARCH being set up automatically from the system via the platform.processor() function, on some machines an empty string is returned and the script refuses to build any images. According to the documentation for the platform module, this can be an issue with some processors, that either return nothing or return the same string as with platform.machine(). This PR adds the option to obtain the value from platform.machine() if the first (and preferred) method returns nothing. --- createhdds.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/createhdds.py b/createhdds.py index 5c9290b..c727ffc 100755 --- a/createhdds.py +++ b/createhdds.py @@ -43,6 +43,11 @@ from six.moves.urllib.request import urlopen # directory. SCRIPTDIR = os.path.abspath(os.path.dirname(sys.argv[0])) CPUARCH = platform.processor() +# Some processors or platforms return an empty string in +# previous step and the script then ends with an error +# saying "Won't create X image on host." +# If that happens, let's read the value from the +# platform.machine() instead. if not CPUARCH: CPUARCH = platform.machine() logger = logging.getLogger('createhdds') @@ -157,7 +162,7 @@ class GuestfsImage(object): gpt_type = part.get("gpt_type", None) if gpt_type: gfs.part_set_gpt_type(disk, partnum, gpt_type) - # format the partition + # format the partition gfs.mkfs(part['filesystem'], partname, label=part.get('label')) # do file 'writes' (create a file with a given string as # its content) @@ -308,7 +313,7 @@ class VirtInstallImage(object): # build Workstation images out of Everything if variant == 'Workstation': variant = 'Everything' - + try: # this is almost complex enough to need fedfind but not # quite, I think. also fedfind can't find the 'transient'