From d79fb78a992bddef575c0dcf064ce82cf2dd7254 Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Thu, 31 Jan 2008 19:06:37 -0500 Subject: [PATCH] make the spec file fragment a Cheetah template --- builder/kojid | 35 +++++++++++++---------------------- hub/kojihub.py | 5 +++-- koji.spec | 1 + 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/builder/kojid b/builder/kojid index 0bcd880f..922060a1 100755 --- a/builder/kojid +++ b/builder/kojid @@ -50,6 +50,7 @@ import traceback import urllib2 import urlparse import xmlrpclib +import Cheetah.Template from ConfigParser import ConfigParser from fnmatch import fnmatch from optparse import OptionParser @@ -2031,40 +2032,30 @@ class JarWrapperRPMTask(BaseTaskHandler): koji.ensuredir(scmdir) specdir = scm.checkout(scmdir, self.getUploadDir(), logfile, use_common=False) - specfile = None + spec_template = None for path, dir, files in os.walk(specdir): files.sort() for filename in files: - if filename.endswith('.spec'): - specfile = os.path.join(path, filename) + if filename.endswith('.spec.tmpl'): + spec_template = os.path.join(path, filename) break - if not specfile: - raise koji.BuildError, 'no spec file found at URL: %s' % spec_url + if not spec_template: + raise koji.BuildError, 'no spec file template found at URL: %s' % spec_url jardir = os.path.join(self.workdir, 'jars') koji.ensuredir(jardir) - sourcelist = '' - installlist = '' - filelist = '' - i = 0 for jarpath in jars: shutil.copy(jarpath, jardir) - jarname = os.path.basename(jarpath) - # sourcelist += jarname += '\n' - sourcelist += 'Source%i: %s\n' % (i, jarname) - installlist += '/usr/bin/install -m 644 %%{SOURCE%i} $RPM_BUILD_ROOT/usr/share/java\n' % i - filelist += '/usr/share/java/' + jarname + '\n' - i += 1 - values = {'sourcelist': sourcelist, - 'installlist': installlist, - 'filelist': filelist} + + values = {'jars': [os.path.basename(jarpath) for jarpath in jars]} values.update((build or task)) - specfd = file(specfile, 'r+') - contents = specfd.read() - contents = contents % values - specfd.seek(0) + contents = Cheetah.Template.Template(file=spec_template, searchList=[values], + filter='EncodeUnicode').respond() + + specfile = spec_template[:-5] + specfd = file(specfile, 'w') specfd.write(contents) specfd.close() diff --git a/hub/kojihub.py b/hub/kojihub.py index 957c7114..e45710fb 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -4674,7 +4674,7 @@ class RootExports(object): def downloadTaskOutput(self, taskID, fileName, offset=0, size=-1): """Download the file with the given name, generated by the task with the given ID.""" - if '..' in fileName or '/' in fileName: + if '..' in fileName: raise koji.GenericError, 'Invalid file name: %s' % fileName filePath = '%s/tasks/%i/%s' % (koji.pathinfo.work(), taskID, fileName) filePath = os.path.normpath(filePath) @@ -6839,8 +6839,9 @@ class HostExports(object): add_rpm_sig(rpminfo['id'], koji.rip_rpm_sighdr(rpmpath)) for log in logs: + # assume we're only importing noarch packages import_build_log('%s/tasks/%i/%s' % (koji.pathinfo.work(), wrapper_task_id, log), - build, subdir='wrapper') + build, subdir='noarch') def failBuild(self, task_id, build_id): """Mark the build as failed. If the current state is not diff --git a/koji.spec b/koji.spec index 6373f2ab..18b6ec61 100644 --- a/koji.spec +++ b/koji.spec @@ -53,6 +53,7 @@ Requires: /usr/bin/svn Requires: /usr/bin/git Requires: rpm-build Requires: redhat-rpm-config +Requires: python-cheetah %if 0%{?rhel} >= 5 Requires: createrepo >= 0.4.11-2 %endif