Created
September 12, 2017 14:05
-
-
Save matyasselmeci/8c6e8d03a4e0fb256ec83a1aec2a04aa to your computer and use it in GitHub Desktop.
Patch to kojid to check spec file after running the command to fetch sources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From da3dc7e9b7ba17d8448a00eacab9adfc6a75b444 Mon Sep 17 00:00:00 2001 | |
From: Matyas Selmeci <matyas@cs.wisc.edu> | |
Date: Thu, 8 Sep 2016 11:12:23 -0500 | |
Subject: [PATCH] kojid_scmbuild_check_spec_after_running_sourcecmd | |
Check that the spec file is present and valid _after_ using the | |
source_cmd to fetch it (for VCS builds). | |
--- | |
builder/kojid | 21 +++++++++++++-------- | |
1 file changed, 13 insertions(+), 8 deletions(-) | |
diff --git a/builder/kojid b/builder/kojid | |
index 6cc50e0..f8bb0dd 100755 | |
--- a/builder/kojid | |
+++ b/builder/kojid | |
@@ -474,17 +474,11 @@ class BuildRoot(object): | |
else: | |
logfile = 'root.log' | |
msg = '; see %s for more information' % logfile | |
return parseStatus(rv, 'mock') + msg | |
- def build_srpm(self, specfile, sourcedir, source_cmd): | |
- self.session.host.setBuildRootState(self.id,'BUILDING') | |
- alt_sources_dir = "%s/SOURCES" % sourcedir | |
- if self.options.support_rpm_source_layout and os.path.isdir(alt_sources_dir): | |
- sources_dir = alt_sources_dir | |
- else: | |
- sources_dir = sourcedir | |
+ def scm_call_source_cmd(self, sourcedir, source_cmd): | |
if source_cmd: | |
# call the command defined by source_cmd in the chroot so any required files not stored in | |
# the SCM can be retrieved | |
chroot_sourcedir = sourcedir[len(self.rootdir()):] | |
args = ['--no-clean', '--unpriv', '--cwd', chroot_sourcedir, '--chroot'] | |
@@ -492,10 +486,19 @@ class BuildRoot(object): | |
rv = self.mock(args) | |
if rv: | |
self.expire() | |
raise koji.BuildError, "error retrieving sources, %s" % self._mockResult(rv) | |
+ def build_srpm(self, specfile, sourcedir, source_cmd): | |
+ self.session.host.setBuildRootState(self.id,'BUILDING') | |
+ alt_sources_dir = "%s/SOURCES" % sourcedir | |
+ if self.options.support_rpm_source_layout and os.path.isdir(alt_sources_dir): | |
+ sources_dir = alt_sources_dir | |
+ else: | |
+ sources_dir = sourcedir | |
+ self.scm_call_source_cmd(sourcedir, source_cmd) | |
+ | |
args = ['--no-clean', '--buildsrpm', '--spec', specfile, '--sources', sources_dir, | |
'--target', 'noarch'] | |
rv = self.mock(args) | |
@@ -4313,10 +4316,12 @@ class BuildSRPMFromSCMTask(BaseBuildTask): | |
self.chownTree(scmdir, uid, gid) | |
# Hook for patching spec file in place | |
self.patch_scm_source(sourcedir, logfile, opts) | |
+ # Run the source_cmd | |
+ broot.scm_call_source_cmd(sourcedir, scm.source_cmd) | |
# Find and verify that there is only one spec file. | |
spec_files = glob.glob("%s/*.spec" % sourcedir) | |
if not spec_files and self.options.support_rpm_source_layout: | |
# also check SPECS dir | |
spec_files = glob.glob("%s/SPECS/*.spec" % sourcedir) | |
@@ -4329,11 +4334,11 @@ class BuildSRPMFromSCMTask(BaseBuildTask): | |
# Run spec file sanity checks. Any failures will throw a BuildError | |
self.spec_sanity_checks(spec_file) | |
#build srpm | |
self.logger.debug("Running srpm build") | |
- broot.build_srpm(spec_file, sourcedir, scm.source_cmd) | |
+ broot.build_srpm(spec_file, sourcedir, None) | |
srpms = glob.glob('%s/*.src.rpm' % broot.resultdir()) | |
if len(srpms) == 0: | |
raise koji.BuildError, "No srpms found in %s" % sourcedir | |
elif len(srpms) > 1: | |
-- | |
2.6.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment