From 39358b4ffedbaa463a77b1051f1687f2be9ee2cf Mon Sep 17 00:00:00 2001 From: Brendan Reilly Date: Jan 30 2019 18:38:03 +0000 Subject: [PATCH 1/3] Added volume id as argument to livemedia task --- diff --git a/builder/kojid b/builder/kojid index 4ed8af2..687e990 100755 --- a/builder/kojid +++ b/builder/kojid @@ -3122,7 +3122,12 @@ class LiveCDTask(ImageTask): cmd = ['/usr/bin/livecd-creator', '-c', kskoji, '-d', '-v', '--logfile', livecd_log, '--cache', cachedir] isoname = '%s-%s-%s' % (name, version, release) - cmd.extend(['-f', self._shortenVolID(name, version, release)]) + volid = opts.get('volid') + if not volid: + volid = self._shortenVolID(name, version, release) + else: + volid = volid[:32] + cmd.extend(['-f', volid]) # Run livecd-creator rv = broot.mock(['--cwd', broot.tmpdir(within=True), '--chroot', '--'] + cmd) @@ -3307,11 +3312,18 @@ class LiveMediaTask(ImageTask): #'--tmp', '/tmp' ] + + volid = opts.get('volid') + if not volid: + volid = self._shortenVolID(name, version, release) + else: + volid = volid[:32] + # note: at the moment, we are only generating live isos. We may add support # for other types in the future cmd.extend(['--make-iso', - '--volid', self._shortenVolID(name, version, release), + '--volid', volid, '--iso-only', ]) diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 71c02a7..4202709 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -5376,6 +5376,7 @@ def handle_spin_livecd(options, session, args): "RPMs in the LiveCD. May be used multiple times. The " + "build tag repo associated with the target is the default.")) parser.add_option("--release", help=_("Forcibly set the release field")) + parser.add_option("--volid", help=_("Set the volume id")) parser.add_option("--specfile", metavar="URL", help=_("SCM URL to spec file fragment to use to generate wrapper RPMs")) parser.add_option("--skip-tag", action="store_true", @@ -5424,6 +5425,7 @@ def handle_spin_livemedia(options, session, args): "build tag repo associated with the target is the default.")) parser.add_option("--release", help=_("Forcibly set the release field")) parser.add_option("--title", help=_("Set the image title (defaults to )")) + parser.add_option("--volid", help=_("Set the volume id")) parser.add_option("--specfile", metavar="URL", help=_("SCM URL to spec file fragment to use to generate wrapper RPMs")) parser.add_option("--skip-tag", action="store_true", @@ -5827,7 +5829,7 @@ def _build_image(options, task_opts, session, args, img_type): passthru_opts = [ 'format', 'install_tree_url', 'isoname', 'ksurl', 'ksversion', 'release', 'repo', 'scratch', 'skip_tag', - 'specfile', 'title', 'vcpu', 'vmem', 'optional_arches', + 'specfile', 'title', 'vcpu', 'vmem', 'volid', 'optional_arches', 'lorax_dir', 'lorax_url', ] for opt in passthru_opts: From f07b7ff85d02d38733f7aa494b45c9023ddc7536 Mon Sep 17 00:00:00 2001 From: Brendan Reilly Date: Jan 30 2019 18:38:03 +0000 Subject: [PATCH 2/3] Updated tests for volume id option --- diff --git a/tests/test_cli/test_spin_commands.py b/tests/test_cli/test_spin_commands.py index b50f528..eaba95e 100644 --- a/tests/test_cli/test_spin_commands.py +++ b/tests/test_cli/test_spin_commands.py @@ -22,6 +22,7 @@ LIVECD_OPTIONS = { "ksversion": None, "repo": None, "release": None, + "volid": None, "specfile": None, } @@ -41,6 +42,7 @@ LIVEMEDIA_OPTIONS = { "lorax_url": None, "optional_arches": None, "title": None, + "volid": None, } APPLIANCE_OPTIONS = { @@ -413,6 +415,7 @@ Options: is the default. --release=RELEASE Forcibly set the release field --title=TITLE Set the image title (defaults to ) + --volid=VOLID Set the volume id --specfile=URL SCM URL to spec file fragment to use to generate wrapper RPMs --skip-tag Do not attempt to tag package @@ -499,6 +502,7 @@ Options: The build tag repo associated with the target is the default. --release=RELEASE Forcibly set the release field + --volid=VOLID Set the volume id --specfile=URL SCM URL to spec file fragment to use to generate wrapper RPMs --skip-tag Do not attempt to tag package From 29dfc9dd72a409ca8f7b54044a28d67aecb0c089 Mon Sep 17 00:00:00 2001 From: Brendan Reilly Date: Feb 06 2019 21:59:05 +0000 Subject: [PATCH 3/3] Added warnings and failures for too long volid --- diff --git a/builder/kojid b/builder/kojid index 687e990..b42c08c 100755 --- a/builder/kojid +++ b/builder/kojid @@ -3126,7 +3126,9 @@ class LiveCDTask(ImageTask): if not volid: volid = self._shortenVolID(name, version, release) else: - volid = volid[:32] + if len(volid) > 32: + logger.warning("volume ID is longer than 32 characters, it will be truncated") + volid = volid[:32] cmd.extend(['-f', volid]) # Run livecd-creator @@ -3317,7 +3319,9 @@ class LiveMediaTask(ImageTask): if not volid: volid = self._shortenVolID(name, version, release) else: - volid = volid[:32] + if len(volid) > 32: + logger.warning("volume ID is longer than 32 characters, it will be truncated") + volid = volid[:32] # note: at the moment, we are only generating live isos. We may add support # for other types in the future diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 4202709..7803528 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -5390,6 +5390,8 @@ def handle_spin_livecd(options, session, args): " architecture, a build target, and a relative path to" + " a kickstart file.")) assert False # pragma: no cover + if task_options.volid is not None and len(task_options.volid) > 32: + parser.error(_('Volume ID has a maximum length of 32 characters')) return _build_image(options, task_options, session, args, 'livecd') @@ -5451,6 +5453,8 @@ def handle_spin_livemedia(options, session, args): if task_options.lorax_url is not None and task_options.lorax_dir is None: parser.error(_('The "--lorax_url" option requires that "--lorax_dir" ' 'also be used.')) + if task_options.volid is not None and len(task_options.volid) > 32: + parser.error(_('Volume ID has a maximum length of 32 characters')) return _build_image(options, task_options, session, args, 'livemedia')