Hello,
This patch implements a --tag option to the cli for the spin-appliance or
spin-livecd directives. It causes the <target> parameter to be interpreted as a
tag rather than a target. The patch includes minor changes to the client,
builder, and some simple logic in the webUI to keep the task options listing
clear to the user.
Thanks,
- Jay
>From 028ac4c9c988b6ba1f2f15dd575c0992db6f4afa Mon Sep 17 00:00:00 2001
From: Jay Greguske <[email protected]>
Date: Tue, 28 Sep 2010 15:54:19 -0400
Subject: [PATCH] added --tag option to spin-appliance and spin-livecd
---
builder/kojid | 37 ++++++++++++++++++++-----------------
cli/koji | 23 ++++++++++++++---------
www/kojiweb/index.py | 4 ++++
www/kojiweb/taskinfo.chtml | 4 ++++
4 files changed, 42 insertions(+), 26 deletions(-)
diff --git a/builder/kojid b/builder/kojid
index 277daaa..b0d3fac 100755
--- a/builder/kojid
+++ b/builder/kojid
@@ -2875,14 +2875,14 @@ class ImageTask(BaseTaskHandler):
self.uploadFile(kspath) # upload the original ks file
return kspath # full absolute path to the file in the chroot
- def prepareKickstart(self, repo_info, target_info, arch, broot, kspath):
+ def prepareKickstart(self, repo_info, tag_name, arch, broot, kspath):
"""
Process the ks file to be used for controlled image generation. This
method also uploads the modified kickstart file to the task output
area.
@args:
- target_info: a sesion.getBuildTarget() object
+ tag_name: the "build" tag we're going to build am image from
repo_info: session.getRepo() object
arch: canonical architecture name
broot: a buildroot object
@@ -2932,16 +2932,14 @@ class ImageTask(BaseTaskHandler):
if not topurl:
raise koji.LiveCDError, 'topurl must be defined in kojid.conf'
path_info = koji.PathInfo(topdir=topurl)
- repopath = path_info.repo(repo_info['id'],
- target_info['build_tag_name'])
+ repopath = path_info.repo(repo_info['id'], tag_name)
baseurl = '%s/%s' % (repopath, arch)
self.logger.debug('BASEURL: %s' % baseurl)
- ks.handler.repo.repoList.append(repo_class(baseurl=baseurl, name='koji-%s-%i' % (target_info['build_tag_name'], repo_info['id'])))
+ ks.handler.repo.repoList.append(repo_class(baseurl=baseurl, name='koji-%s-%i' % (tag_name, repo_info['id'])))
# Write out the new ks file. Note that things may not be in the same
# order and comments in the original ks file may be lost.
- kskoji = os.path.join('/tmp', 'koji-image-%s-%i.ks' %
- (target_info['build_tag_name'], self.id))
+ kskoji = os.path.join('/tmp', 'koji-image-%s-%i.ks' % (tag_name, self.id))
kojikspath = os.path.join(broot.rootdir(), kskoji[1:])
outfile = open(kojikspath, 'w')
outfile.write(str(ks.handler))
@@ -3005,14 +3003,17 @@ class ApplianceTask(ImageTask):
'qcow2': 'QCOW2 Image',
'vmx': 'VMWare Image'}
- target_info = session.getBuildTarget(target, strict=True)
- build_tag = target_info['build_tag']
- repo_info = session.getRepo(build_tag)
-
if not opts:
opts = {}
self.opts = opts
+ if opts.get('tag'):
+ build_tag = target
+ else:
+ tmp_target = session.getBuildTarget(target, strict=True)
+ build_tag = tmp_target['build_tag_name']
+ repo_info = session.getRepo(build_tag)
+
if not image_enabled:
self.logger.error("Appliance features require the following dependencies: pykickstart, and possibly python-hashlib")
raise koji.ApplianceError, 'Appliance functions not available'
@@ -3020,7 +3021,7 @@ class ApplianceTask(ImageTask):
broot = self.makeImgBuildRoot(build_tag, repo_info, arch,
'appliance-build')
kspath = self.fetchKickstart(broot, ksfile)
- kskoji = self.prepareKickstart(repo_info, target_info, arch, broot,
+ kskoji = self.prepareKickstart(repo_info, build_tag, arch, broot,
kspath)
# Figure out appliance-creator arguments, we let it fail if something
@@ -3181,13 +3182,15 @@ class LiveCDTask(ImageTask):
def handler(self, arch, target, ksfile, opts=None):
- target_info = session.getBuildTarget(target, strict=True)
- build_tag = target_info['build_tag']
- repo_info = session.getRepo(build_tag)
-
if not opts:
opts = {}
self.opts = opts
+ if opts.get('tag'):
+ build_tag = target
+ else:
+ tmp_target = session.getBuildTarget(target, strict=True)
+ build_tag = tmp_target['build_tag_name']
+ repo_info = session.getRepo(build_tag)
if not image_enabled:
self.logger.error("LiveCD features require the following dependencies: "
@@ -3196,7 +3199,7 @@ class LiveCDTask(ImageTask):
broot = self.makeImgBuildRoot(build_tag, repo_info, arch, 'livecd-build')
kspath = self.fetchKickstart(broot, ksfile)
- kskoji = self.prepareKickstart(repo_info, target_info, arch, broot, kspath)
+ kskoji = self.prepareKickstart(repo_info, build_tag, arch, broot, kspath)
cachedir = '/tmp/koji-livecd' # arbitrary paths in chroot
livecd_log = '/tmp/livecd.log'
diff --git a/cli/koji b/cli/koji
index cfb0683..460419d 100755
--- a/cli/koji
+++ b/cli/koji
@@ -4512,6 +4512,8 @@ def handle_spin_livecd(options, session, args):
help=_("The syntax version used in the kickstart file"))
parser.add_option("--scratch", action="store_true",
help=_("Create a scratch LiveCD image"))
+ parser.add_option("--tag", action="store_true",
+ help=_("Interpret <target> as a tag instead"))
parser.add_option("--repo",
help=_("Specify a comma-separated list of repos that will override " +
"the repo used to install RPMs in the LiveCD image. The " +
@@ -4551,6 +4553,8 @@ def handle_spin_appliance(options, session, args):
help=_("The syntax version used in the kickstart file"))
parser.add_option("--scratch", action="store_true",
help=_("Create a scratch appliance"))
+ parser.add_option("--tag", action="store_true",
+ help=_("Interpret <target> as a tag instead"))
parser.add_option("--repo",
help=_("Specify a comma-separated list of repos that will override " +
"the repo used to install RPMs in the appliance. The " +
@@ -4601,17 +4605,18 @@ def _build_image(options, task_opts, session, args, img_type):
else:
callback = _progress_callback
- # We do some early sanity checking of the given target.
+ # We do some early sanity checking of the given target/tag.
# Kojid gets these values again later on, but we check now as a convenience
# for the user.
target = args[0]
- tmp_target = session.getBuildTarget(target)
- if not tmp_target:
- raise koji.GenericError, _("Unknown build target: %s" % target)
- dest_tag = session.getTag(tmp_target['dest_tag'])
- if not dest_tag:
- raise koji.GenericError, _("Unknown destination tag: %s" %
- tmp_target['dest_tag_name'])
+ if task_opts.tag:
+ tmp_tag = session.getTag(target)
+ if not tmp_tag:
+ raise koji.GenericError, _("Unknown tag: %s" % target)
+ else:
+ tmp_target = session.getBuildTarget(args[0])
+ if not tmp_target:
+ raise koji.GenericError, _("Unknown build target: %s" % target)
# Set the architecture
arch = koji.canonArch(args[1])
@@ -4627,7 +4632,7 @@ def _build_image(options, task_opts, session, args, img_type):
print
hub_opts = {}
- for opt in ('isoname', 'ksurl', 'ksversion', 'scratch', 'repo',
+ for opt in ('isoname', 'ksurl', 'ksversion', 'scratch', 'repo', 'tag',
'name', 'version', 'release', 'vmem', 'vcpu', 'format'):
val = getattr(task_opts, opt, None)
if val is not None:
diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py
index 9d16114..b831238 100644
--- a/www/kojiweb/index.py
+++ b/www/kojiweb/index.py
@@ -539,6 +539,10 @@ def taskinfo(req, taskID):
buildTag = params[1]
values['buildTag'] = buildTag
elif task['method'] == 'createLiveCD' or task['method'] == 'createAppliance':
+ if params[3].get('tag', None):
+ values['tagid'] = server.getTag(params[1])['id']
+ else:
+ values['tagid'] = None
values['image'] = server.getImageInfo(taskID=taskID)
elif task['method'] == 'buildSRPMFromSCM':
if len(params) > 1:
diff --git a/www/kojiweb/taskinfo.chtml b/www/kojiweb/taskinfo.chtml
index 16b9375..0099828 100644
--- a/www/kojiweb/taskinfo.chtml
+++ b/www/kojiweb/taskinfo.chtml
@@ -144,7 +144,11 @@ $value
#end if
#elif $task.method == 'createLiveCD' or $task.method == 'createAppliance'
<strong>Arch:</strong> $params[0]<br/>
+ #if $tagid
+ <strong>Tag:</strong> <a href="taginfo?tagID=$tagid">$params[1]</a><br/>
+ #else
<strong>Target:</strong> <a href="buildtargetinfo?name=$params[1]">$params[1]</a><br/>
+ #end if
<strong>Kickstart File:</strong> $params[2]<br/>
#if $len($params) > 3
$printOpts($params[3])
--
1.7.2.2
--
buildsys mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/buildsys