diff options
author | Colin Walters <walters@verbum.org> | 2010-02-23 13:51:31 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-02-23 13:51:31 -0500 |
commit | 35e96ff0fe270e7dab7b2f9a95e607468396bd28 (patch) | |
tree | 418dba982c32b9ee0874d82916dbf6d91c19009f /fedpkg-pull-build-chain | |
parent | 7eeea948dcab8e38f8c8a3c018a31f42f9f70639 (diff) | |
download | fedpkg-make-pull-35e96ff0fe270e7dab7b2f9a95e607468396bd28.tar.gz fedpkg-make-pull-35e96ff0fe270e7dab7b2f9a95e607468396bd28.tar.xz fedpkg-make-pull-35e96ff0fe270e7dab7b2f9a95e607468396bd28.zip |
Add pull-build-chain, various fixes
Diffstat (limited to 'fedpkg-pull-build-chain')
-rw-r--r-- | fedpkg-pull-build-chain | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/fedpkg-pull-build-chain b/fedpkg-pull-build-chain new file mode 100644 index 0000000..47f4ba7 --- /dev/null +++ b/fedpkg-pull-build-chain @@ -0,0 +1,102 @@ +#!/usr/bin/python + +# fedpkg-pull-build-chain: +# Build binary RPMS for the named source RPMs from the latest upstream code. Fedora CVS tree +# is checked out into the current directory. Build logs go in _build. You must specify +# a destination path for RPMS with --resultdir. +# +# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php) +# Copyright (C) 2010 Red Hat, Inc. +# Written by Colin Walters <walters@verbum.org> + +import getopt +import os +import sys +import subprocess + +def main(): + try: + opts, args = getopt.getopt(sys.argv[1:], '', ['release', 'arch']) + except getopt.GetoptError, e: + print "Usage: fedpkg-pull-build-chain --release=F-12 --resultdir=/path/to/repo rpm1 rpm2 ..." + sys.exit(1) + + release = None + resultdir = None + architectures = [] + for o, a in opts: + if o in ('--release', ): + release = a + elif o in ('--arch', ): + architectures.append(a) + elif o in ('--resultdir', ): + resultdir = a + + if release is None: + print "Must specify --release" + sys.exit(1) + if resultdir is None: + print "Must specify --resultdir=/path/to/repository" + sys.exit(1) + + if len(architectures) == 0: + architectures.append(subprocess.check_call(['uname', '-m'], stdout=subprocess.PIPE).communicate()[0]) + + failed = [] + for arg in args: + if not os.path.isdir(arg): + print "Checking out %r from fedora-cvs" % (arg, ) + subprocess.check_call(['fedora-cvs', arg], stdout=sys.stdout, stderr=sys.stderr) + release_dir = os.path.join(arg, release) + for filename in os.listdir(release_dir): + fpath = os.path.join(release_dir, filename) + if filename.endswith('.src.rpm'): + print "Deleting old srpm: " + fpath + os.unlink(fpath) + print "Running fedpkg-make-pull" + try: + subprocess.check_call(['fedpkg-make-pull'], stdout=sys.stdout, stderr=sys.stderr) + except subprocess.CalledProcessError, e: + print "Failed: " + unicode(e) + failed.append(arg) + continue + + srpm = None + for filename in os.listdir(release_dir): + fpath = os.path.join(release_dir, filename) + if filename.endswith('.src.rpm'): + srpm = fpath + if srpm is None: + print "No SRPM, assuming no changes upstream" + continue + + mock_resultdir = os.path.join('_build', arg) + try: + os.mkdir(mock_resultdir) + except OSError, e: + # assume EEXIST, and clean out old results + for filename in os.listdir(mock_resultdir): + os.unlink(os.path.join(mock_resultdir, filename)) + + for architecture in architectures: + # FIXME do this better + mockrelease = 'fedora-' + release[2:].lower() + '-' + architecture + try: + subprocess.check_call(['mock', '-r', mockrelease, '--resultdir=' + mock_resultdir, 'rebuild', srpm], stdout=sys.stdout, stderr=sys.stderr) + except subprocess.CalledProcessError, e: + print "Failed: " + unicode(e) + failed.append(arg) + continue + + for filename in os.listdir(mock_resultdir): + if not filename.endswith('.rpm'): + continue + os.link(os.path.join(resultdir, filename), os.path.join(mock_resultdir, filename)) + + if len(failed) > 0: + sys.exit(1) + else: + sys.exit(0) + +if __name__ == '__main__': + main() |