add 'subvariant' image property, create live/appliance names

This adds the new 'subvariant' property to all images produced by Pungi.
For most image types this is the same as the variant, for now. For
live_images and livemedia_phase, the image config may specify
'subvariant' and the value will be used if present, otherwise the
variant name will be used.

We also now synthesize the Koji image 'name' for live and appliance
images if the image config doesn't specify it, and use a name that
complies better with the naming policy for ARM disk images (partially
resolving https://pagure.io/pungi-fedora/issue/7 ).

This is completely untested as yet, just bashing stuff out on a Sunday,
will work more on it tomorrow.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2016-03-10 18:53:40 +00:00 committed by Dennis Gilmore
parent 2fd117367e
commit 254bfb8ca4
5 changed files with 24 additions and 7 deletions

View File

@ -364,6 +364,7 @@ def link_boot_iso(compose, arch, variant):
img.disc_number = 1
img.disc_count = 1
img.bootable = True
img.subvariant = variant.name
img.implant_md5 = implant_md5
try:
img.volume_id = iso.get_volume_id(new_boot_iso_path)

View File

@ -299,6 +299,7 @@ class CreateIsoThread(WorkerThread):
img.disc_number = cmd["disc_num"]
img.disc_count = cmd["disc_count"]
img.bootable = cmd["bootable"]
img.subvariant = str(cmd['variant'])
img.implant_md5 = iso.get_implanted_md5(cmd["iso_path"])
try:
img.volume_id = iso.get_volume_id(cmd["iso_path"])

View File

@ -229,6 +229,7 @@ class CreateImageBuildThread(WorkerThread):
img.disc_number = 1 # We don't expect multiple disks
img.disc_count = 1
img.bootable = False
img.subvariant = cmd["image_conf"]["image-build"]["variant"]
compose.im.add(variant=cmd["image_conf"]["image-build"]["variant"].uid,
arch=image_info['arch'],
image=img)

View File

@ -122,6 +122,7 @@ class LiveImagesPhase(PhaseBase):
for variant in self.compose.variants.values():
for arch in variant.arches + ["src"]:
for data in get_arch_variant_data(self.compose.conf, "live_images", arch, variant):
subvariant = data.get('subvariant', variant.uid)
type = data.get('type', 'live')
if type == 'live':
@ -136,7 +137,7 @@ class LiveImagesPhase(PhaseBase):
continue
cmd = {
"name": data.get("name", None),
"name": data.get('name'),
"version": data.get("version", None),
"release": self._get_release(data),
"dest_dir": dest_dir,
@ -153,6 +154,7 @@ class LiveImagesPhase(PhaseBase):
"sign": False,
"type": type,
"label": "", # currently not used
"subvariant": subvariant,
}
if 'ksurl' in data:
@ -217,12 +219,18 @@ class CreateLiveImageThread(WorkerThread):
self.basename = '%(name)s-%(version)s-%(release)s' % cmd
log_file = compose.paths.log.log_file(arch, "liveimage-%s" % self.basename)
subvariant = cmd.pop('subvariant')
imgname = "%s-%s-%s-%s" % (compose.ci_base.release.short, subvariant,
'Live' if cmd['type'] == 'live' else 'Disk',
arch)
msg = "Creating ISO (arch: %s, variant: %s): %s" % (arch, variant, self.basename)
self.pool.log_info("[BEGIN] %s" % msg)
koji_wrapper = KojiWrapper(compose.conf["koji_profile"])
name, version = compose.compose_id.rsplit("-", 1)
name = cmd["name"] or name
_, version = compose.compose_id.rsplit("-", 1)
name = cmd["name"] or imgname
version = cmd["version"] or version
archive = False
if cmd["specfile"] and not cmd["scratch"]:
@ -278,11 +286,11 @@ class CreateLiveImageThread(WorkerThread):
# ISO manifest only makes sense for live images
self._write_manifest(destination)
self._add_to_images(compose, variant, arch, cmd['type'], self._get_format(image_path), destination)
self._add_to_images(compose, variant, subvariant, arch, cmd['type'], self._get_format(image_path), destination)
self.pool.log_info("[DONE ] %s" % msg)
def _add_to_images(self, compose, variant, arch, type, format, path):
def _add_to_images(self, compose, variant, subvariant, arch, type, format, path):
"""Adds the image to images.json"""
img = Image(compose.im)
img.type = 'raw-xz' if type == 'appliance' else type
@ -294,6 +302,7 @@ class CreateLiveImageThread(WorkerThread):
img.disc_number = 1 # We don't expect multiple disks
img.disc_count = 1
img.bootable = True
img.subvariant = subvariant
compose.im.add(variant=variant.uid, arch=arch, image=img)
def _is_image(self, path):

View File

@ -127,8 +127,10 @@ class LiveMediaPhase(PhaseBase):
def run(self):
for variant in self.compose.get_variants():
arches = set([x for x in variant.arches if x != 'src'])
for image_conf in get_variant_data(self.compose.conf, self.name, variant):
subvariant = image_conf.get('subvariant', variant.uid)
name = image_conf.get(
'name', "%s-%s-Live" % (self.compose.ci_base.release.short, subvariant))
config = {
'target': self._get_config(image_conf, 'target'),
'arches': self._get_arches(image_conf, arches),
@ -138,7 +140,8 @@ class LiveMediaPhase(PhaseBase):
'scratch': image_conf.get('scratch', False),
'release': self._get_release(image_conf),
'skip_tag': image_conf.get('skip_tag'),
'name': image_conf['name'],
'name': name,
'subvariant': subvariant,
'title': image_conf.get('title'),
'repo': self._get_repos(image_conf, variant),
'install_tree': self._get_install_tree(image_conf, variant),
@ -189,6 +192,7 @@ class LiveMediaThread(WorkerThread):
' '.join(config['arches']),
variant.uid)
self.pool.log_info('[BEGIN] %s' % msg)
subvariant = config.pop('subvariant')
koji_wrapper = KojiWrapper(compose.conf['koji_profile'])
cmd = self._get_cmd(koji_wrapper, config)
@ -236,6 +240,7 @@ class LiveMediaThread(WorkerThread):
img.disc_number = 1 # We don't expect multiple disks
img.disc_count = 1
img.bootable = True
img.subvariant = subvariant
compose.im.add(variant=variant.uid, arch=image_info['arch'], image=img)
self.pool.log_info('[DONE ] %s' % msg)