first stab at livemedia control task, based on livecd

This commit is contained in:
Mike McLean 2015-12-11 12:34:40 -05:00
parent 2b8061d443
commit bd52ecff00

View file

@ -2363,6 +2363,95 @@ class BuildLiveCDTask(BuildImageTask):
report += 'livecd build results in: %s' % respath
return report
class BuildLiveMediaTask(BuildImageTask):
Methods = ['livemedia']
def handler(self, name, version, arch, target, ksfile, opts=None):
"""Governing task for building live media"""
target_info = self.session.getBuildTarget(target, strict=True)
build_tag = target_info['build_tag']
repo_info = self.getRepo(build_tag)
#check requested arch against build tag
buildconfig = self.session.getBuildConfig(build_tag)
if not buildconfig['arches']:
raise koji.BuildError, "No arches for tag %(name)s [%(id)s]" % buildconfig
tag_archlist = [koji.canonArch(a) for a in buildconfig['arches'].split()]
if koji.canonArch(arch) not in tag_archlist:
raise koji.BuildError, "Invalid arch for build tag: %s" % arch
if not opts:
opts = {}
if not image_enabled:
# XXX - are these still required here?
self.logger.error("Missing the following dependencies: "
"pykickstart, pycdio, and possibly python-hashlib")
raise koji.PreBuildError, 'Live Media functions not available'
# build the image
try:
release = opts.get('release')
if not release:
release = self.getRelease(name, version)
bld_info = None
if not opts.get('scratch'):
bld_info = self.initImageBuild(name, version, release,
target_info, opts)
create_task_id = self.subtask('createLiveMedia',
[name, version, release, arch, target_info, build_tag,
repo_info, ksfile, opts],
label='livemedia', arch=arch)
results = self.wait(create_task_id)
self.logger.info('image build task (%s) completed' % create_task_id)
self.logger.info('results: %s' % results)
# wrap in an RPM if needed
spec_url = opts.get('specfile')
rpm_results = None
if spec_url:
results[create_task_id]['rpmresults'] = self.buildWrapperRPM(
spec_url, create_task_id,
target_info, bld_info, repo_info['id'])
results[str(create_task_id)] = results[create_task_id]
del results[create_task_id]
# import it (and move)
if not opts.get('scratch'):
self.session.host.completeImageBuild(self.id, bld_info['id'], results)
else:
self.session.host.moveImageBuildToScratch(self.id, results)
except (SystemExit, ServerExit, KeyboardInterrupt):
#we do not trap these
raise
except:
if not opts.get('scratch'):
#scratch builds do not get imported
if bld_info:
self.session.host.failBuild(self.id, bld_info['id'])
# reraise the exception
raise
# tag it if necessary
if not opts.get('scratch') and not opts.get('skip_tag'):
tag_task_id = self.session.host.subtask(method='tagBuild',
arglist=[target_info['dest_tag'], bld_info['id'], False, None, True],
label='tag', parent=self.id, arch='noarch')
self.wait(tag_task_id)
# report the results
if opts.get('scratch'):
respath = os.path.join(koji.pathinfo.work(),
koji.pathinfo.taskrelpath(create_task_id))
report = 'Scratch '
else:
respath = koji.pathinfo.imagebuild(bld_info)
report = ''
report += 'livecd build results in: %s' % respath
return report
# A generic task for building cd or disk images using chroot-based tools.
# Other chroot-based image handlers should inherit this.
class ImageTask(BaseTaskHandler):