live_images: Allow custom name prefix for live ISOs.

This commit is contained in:
Tomas Mlcoch 2015-08-25 07:49:29 -04:00 committed by Daniel Mach
parent 39c073abf9
commit 44ebf5eedc
2 changed files with 23 additions and 11 deletions

View File

@ -464,7 +464,7 @@ class ComposePaths(object):
makedirs(path)
return path
def iso_path(self, arch, variant, disc_type="dvd", disc_num=1, suffix=".iso", symlink_to=None, create_dir=True, relative=False):
def iso_path(self, arch, variant, disc_type="dvd", disc_num=1, suffix=".iso", symlink_to=None, create_dir=True, relative=False, name=None):
"""
Examples:
compose/Server/x86_64/iso/rhel-7.0-20120127.0-Server-x86_64-dvd1.iso
@ -489,7 +489,10 @@ class ComposePaths(object):
variant_uid = variant.parent.uid
else:
variant_uid = variant.uid
file_name = "%s-%s-%s-%s%s%s" % (compose_id, variant_uid, arch, disc_type, disc_num, suffix)
if not name:
file_name = "%s-%s-%s-%s%s%s" % (compose_id, variant_uid, arch, disc_type, disc_num, suffix)
else:
file_name = "%s-%s-%s-%s%s%s" % (name, variant_uid, arch, disc_type, disc_num, suffix)
result = os.path.join(path, file_name)
return result

View File

@ -79,20 +79,12 @@ class LiveImagesPhase(PhaseBase):
if not iso_dir:
continue
# XXX: hardcoded disc_type and disc_num
iso_path = self.compose.paths.compose.iso_path(arch, variant, disc_type="live", disc_num=None, symlink_to=symlink_isos_to)
if os.path.isfile(iso_path):
self.compose.log_warning("Skipping creating live image, it already exists: %s" % iso_path)
continue
iso_name = os.path.basename(iso_path)
cmd = {
"name": None,
"version": None,
"arch": arch,
"variant": variant,
"iso_path": iso_path,
"iso_path": None,
"build_arch": arch,
"ks_file": ks_file,
"specfile": None,
@ -121,6 +113,23 @@ class LiveImagesPhase(PhaseBase):
# For other images is scratch always on
cmd["scratch"] = data[0].get("scratch", False)
# Custom name (prefix)
custom_iso_name = None
if cmd["name"]:
custom_iso_name = cmd["name"]
if cmd["version"]:
custom_iso_name += "-%s" % cmd["version"]
# XXX: hardcoded disc_type and disc_num
iso_path = self.compose.paths.compose.iso_path(arch, variant, disc_type="live", disc_num=None, symlink_to=symlink_isos_to, name=custom_iso_name)
if os.path.isfile(iso_path):
self.compose.log_warning("Skipping creating live image, it already exists: %s" % iso_path)
continue
cmd["iso_path"] = iso_path
iso_name = os.path.basename(iso_path)
# Additional commands
chdir_cmd = "cd %s" % pipes.quote(iso_dir)
cmd["cmd"].append(chdir_cmd)