summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfedpkg-make-pull67
1 files changed, 54 insertions, 13 deletions
diff --git a/fedpkg-make-pull b/fedpkg-make-pull
index 84530eb..337af34 100755
--- a/fedpkg-make-pull
+++ b/fedpkg-make-pull
@@ -25,12 +25,12 @@ import urlparse
import getopt
import subprocess
import shutil
+import hashlib
class Vcs(object):
def __init__(self, parsedurl):
self._parsed_url = parsedurl
# Deliberately drop params/query
- print "%r %r %r" % (parsedurl.scheme, parsedurl.netloc, parsedurl.path)
self._nonfragment_url_string = urlparse.urlunparse((parsedurl.scheme,
parsedurl.netloc,
parsedurl.path,
@@ -116,7 +116,7 @@ class AutogenAutotools(Autotools):
def get_substitutions(self):
# We'll configure twice with this, but oh well. Need this in RPM.
- return [(re.compile('^%configure'), './autogen.sh')]
+ return [(re.compile('^%configure'), './autogen.sh && %configure')]
class Spec(object):
def __init__(self, filename):
@@ -132,24 +132,27 @@ class Spec(object):
self._substitutions = []
def add_buildrequires(self, new_buildrequires):
+ current_buildrequires = self.get_key_allvalues('BuildRequires')
+ new_buildrequires = filter(lambda x: x not in current_buildrequires, new_buildrequires)
self._append_buildrequires = new_buildrequires
def increment_release_snapshot(self, identifier):
- cur_release = self._get_key('Release')
+ cur_release = self.get_key('Release')
release_has_dist = cur_release.endswith('%{?dist}')
if release_has_dist:
cur_release = cur_release[:-8]
- snapshot_release_re = re.compile(r'^([0-9]+)\.')
+ snapshot_release_re = re.compile(r'^([0-9]+)\.([0-9]+)\.')
numeric_re = re.compile(r'^([0-9]+)$')
match = snapshot_release_re.match(cur_release)
if match:
- relint = int(match.group(1)) + 1
+ firstint = int(match.group(1))
+ relint = int(match.group(2)) + 1
+ new_release = '%d.%d.%s' % (firstint, relint, identifier)
else:
match = numeric_re.match(cur_release)
if not match:
raise ValueError("Can't handle Release value: %r" % (cur_release, ))
- relint = int(cur_release) + 1
- new_release = '%d.%s' % (relint, identifier)
+ new_release = '%s.%d.%s' % (cur_release, relint, identifier)
if release_has_dist:
new_release += '%{?dist}'
@@ -191,7 +194,7 @@ class Spec(object):
output.close()
def get_version(self):
- return self._get_key('Version')
+ return self.get_key('Version')
def get_vcs(self):
for line in self._lines:
@@ -199,16 +202,24 @@ class Spec(object):
return line[5:].strip()
raise ValueError("No such key #VCS in file %r" % (self._filename, ))
- def _get_key(self, key):
+ def get_key(self, key):
key = key + ':'
for line in self._lines:
if line.startswith(key):
return line[len(key):].strip()
raise ValueError("No such key %r in file %r" % (key, self._filename))
+ def get_key_allvalues(self, key):
+ key = key + ':'
+ result = []
+ for line in self._lines:
+ if line.startswith(key):
+ result.append(line[len(key):].strip())
+ return result
+
def main():
try:
- opts, args = getopt.getopt(sys.argv[1:], 'f', ['force', '--apply', '--srpm'])
+ opts, args = getopt.getopt(sys.argv[1:], 'f', ['force', 'apply', 'srpm'])
except getopt.GetoptError, e:
print unicode(e)
print ""
@@ -236,6 +247,13 @@ def main():
spec = Spec(targetspec)
name = targetspec[:-5]
version = spec.get_version()
+
+ f = open('sources')
+ lines = f.readlines()
+ f.close()
+ if len(lines) != 1:
+ print "Must have exactly one source in sources file"
+ sys.exit(1)
try:
vcsurl = spec.get_vcs()
@@ -277,7 +295,7 @@ def main():
spec.increment_release_snapshot(newid)
spec.save(new_specname)
- if opt_srpm:
+ if opt_srpm and not opt_apply:
tempdir_name = new_specname + '.dir'
os.mkdir(tempdir_name)
# Ok, this is a gross hack...parse Source/Patch? from .spec?
@@ -299,8 +317,31 @@ def main():
print "Created SRPM: %s" % (srpm_name, )
elif opt_apply:
os.rename(new_specname, targetspec)
- subprocess.check_call(['make', 'new-sources', 'FILES=' + snapshot_archivename])
- print "Updated %s and sources" % (targetspec, )
+
+ snapshot_md5 = hashlib.md5()
+ f = open(snapshot_archivename)
+ b = f.read(8192)
+ while b != '':
+ snapshot_md5.update(b)
+ b = f.read(8192)
+ f.close()
+
+ snapshot_md5 = snapshot_md5.hexdigest()
+
+ f = open('sources', 'w')
+ f.write(snapshot_md5)
+ f.write(' ')
+ f.write(snapshot_archivename)
+ f.write('\n')
+ f.close()
+
+ print "Updated %s and sources file" % (targetspec, )
+ print "If you want to upload to Fedora, you'll need to run:"
+ print " make upload FILE=%s" % (snapshot_archivename, )
+ print " cvs commit && make tag build"
+
+ if opt_srpm:
+ check_call_verbose(['make', 'srpm'])
sys.exit(0)
if __name__ == '__main__':