From 770a81b76ced1abe1a598d178708c7fbad2dfc54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 4 Jan 2016 19:27:11 +0100 Subject: [PATCH] Don't crash on generating volid without variant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First, this fixes the crash when volume id requires variant uid, but it is not specified. This happened in buildinstall phase. When lorax is used, it is run once for each variant, so we can actually specify the variant and get the correct variant. When using buildinstall, no volume id will be generated and pungi will possibly crash later on. Signed-off-by: Lubomír Sedlář --- pungi/phases/buildinstall.py | 1 + pungi/util.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index fb0faf60..41472e92 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -130,6 +130,7 @@ class BuildinstallPhase(PhaseBase): if buildinstall_method == "lorax": for variant in self.compose.get_variants(arch=arch, types=['variant']): + volid = get_volid(self.compose, arch, variant=variant, disc_type="boot") commands.append( self._get_lorax_cmd(repo_baseurl, output_dir, variant, arch, buildarch, volid) ) diff --git a/pungi/util.py b/pungi/util.py index 5bfd02fa..facecd20 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -347,9 +347,9 @@ def get_volid(compose, arch, variant=None, escape_spaces=False, disc_type=False) # iso = IsoWrapper(logger=compose._logger) # volid = iso._truncate_volid(volid) - if len(volid) > 32: + if volid and len(volid) > 32: raise ValueError("Could not create volume ID <= 32 characters") - if escape_spaces: + if volid and escape_spaces: volid = volid.replace(" ", r"\x20") return volid