summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-02-23 13:51:31 -0500
committerColin Walters <walters@verbum.org>2010-02-23 13:51:31 -0500
commit35e96ff0fe270e7dab7b2f9a95e607468396bd28 (patch)
tree418dba982c32b9ee0874d82916dbf6d91c19009f
parent7eeea948dcab8e38f8c8a3c018a31f42f9f70639 (diff)
downloadfedpkg-make-pull-35e96ff0fe270e7dab7b2f9a95e607468396bd28.tar.gz
fedpkg-make-pull-35e96ff0fe270e7dab7b2f9a95e607468396bd28.tar.xz
fedpkg-make-pull-35e96ff0fe270e7dab7b2f9a95e607468396bd28.zip
Add pull-build-chain, various fixes
-rwxr-xr-xfedpkg-make-pull47
-rw-r--r--fedpkg-pull-build-chain102
2 files changed, 137 insertions, 12 deletions
diff --git a/fedpkg-make-pull b/fedpkg-make-pull
index b4f38c9..a6bc34a 100755
--- a/fedpkg-make-pull
+++ b/fedpkg-make-pull
@@ -1,6 +1,6 @@
#!/usr/bin/python
-# make-pull.py
+# fedpkg-make-pull:
# 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>
@@ -89,7 +89,10 @@ class BuildSystem(object):
return Autotools(directory)
def get_bootstrap_buildrequires(self):
- pass
+ return []
+
+ def get_substitutions(self):
+ return []
class Autotools(BuildSystem):
def get_bootstrap_buildrequires(self):
@@ -101,6 +104,10 @@ class GnomeAutotools(Autotools):
bootstrap.append('gnome-common')
return bootstrap
+ def get_substitutions(self):
+ # We'll configure twice with this, but oh well. Need this in RPM.
+ return [(re.compile('^%configure'), './autogen.sh\n%configure')]
+
class Spec(object):
def __init__(self, filename):
self._filename = filename
@@ -112,6 +119,7 @@ class Spec(object):
self._new_release = None
self._source_dirname = None
self._source_archivename = None
+ self._substitutions = []
def add_buildrequires(self, new_buildrequires):
self._append_buildrequires = new_buildrequires
@@ -141,15 +149,31 @@ class Spec(object):
self._source_dirname = dirname
self._source_archivename = archivename
+ def substitute(self, substitutions):
+ self._substitutions = substitutions
+
def save(self, new_filename):
+ wrote_buildrequires = False
output = open(new_filename, 'w')
for line in self._lines:
- if line.startswith('Release:'):
+ replacement_matched = False
+ for sub_re, replacement in self._substitutions:
+ (line, subcount) = sub_re.subn(replacement, line)
+ if subcount > 0:
+ replacement_matched = True
+ break
+ if replacement_matched:
+ output.write(line)
+ elif line.startswith('Release:'):
output.write('Release: %s\n' % self._new_release)
elif line.startswith('Source0:'):
output.write('Source0: %s\n' % self._source_archivename)
elif line.startswith('%setup'): # This is dumb, need to automate this in RPM
output.write('%%setup -q -n %s\n' % self._source_dirname)
+ elif line.startswith('BuildRequires:') and not wrote_buildrequires:
+ output.write(line)
+ for req in self._append_buildrequires:
+ output.write('BuildRequires: %s\n' % req)
else:
output.write(line)
@@ -224,21 +248,20 @@ def main():
print "Checking out from %r into new directory %r" % (vcsurl, targetdir)
vcs.checkout(targetdir)
newid = vcs.get_id(targetdir)
-
- buildsys = BuildSystem.new_from_directory(targetdir)
- if buildsys is None:
- print "WARNING: Unrecognized buildsystem in directory %r" % (targetdir, )
- bootstrap_deps = []
- else:
- bootstrap_deps = buildsys.get_bootstrap_buildrequires()
snapshot_dirname = '%s-%s%s%s' % (name, version, vcs.get_scheme(), newid)
snapshot_archivename = snapshot_dirname + '.tar.bz2'
- subprocess.check_call(['tar', '-cj', '--transform=s,^,' + snapshot_dirname + ',', '-f', '../' + snapshot_archivename, '.'], cwd=targetdir)
+ subprocess.check_call(['tar', '-cj', r'--transform=s,^\.,' + snapshot_dirname + ',', '-f', '../' + snapshot_archivename, '.'], cwd=targetdir)
new_specname = '%s-%s%s.spec.tmp' % (name, vcs.get_scheme(), newid)
- spec.add_buildrequires(bootstrap_deps)
+ buildsys = BuildSystem.new_from_directory(targetdir)
+ if buildsys is None:
+ print "WARNING: Unrecognized buildsystem in directory %r" % (targetdir, )
+ else:
+ spec.add_buildrequires(buildsys.get_bootstrap_buildrequires())
+ spec.substitute(buildsys.get_substitutions())
+
spec.set_source(snapshot_dirname, snapshot_archivename)
spec.increment_release_snapshot(newid)
spec.save(new_specname)
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()