summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2011-01-21 17:02:47 -0800
committerJesse Keating <jkeating@redhat.com>2011-01-21 17:02:47 -0800
commit7c894bd5084493546872cce636ea38d6af6a0524 (patch)
treec115a956e3cf7946dac702cfb5c43043f890e8e7
parent6cf795ba83fb86b366d87d2df546356ee9223090 (diff)
downloadfedora-packager-7c894bd5084493546872cce636ea38d6af6a0524.tar.gz
fedora-packager-7c894bd5084493546872cce636ea38d6af6a0524.tar.xz
fedora-packager-7c894bd5084493546872cce636ea38d6af6a0524.zip
Regenerate the srpm if spec file is newer (ticket #84)
Compare the modification times of the spec and the srpm if it exists and see if we need to re-generate due to a spec change. Most of this code comes from Gianluca Sforna <giallu@gmail.com> with modifications from me.
-rw-r--r--src/pyfedpkg/__init__.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index 1d954de..f78cee0 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -227,6 +227,15 @@ def _verify_file(file, hash, hashtype):
return True
return False
+def _newer(file1, file2):
+ """Compare the last modification time of the given files
+
+ Returns True is file1 is newer than file2
+
+ """
+
+ return os.path.getmtime(file1) > os.path.getmtime(file2)
+
def _get_build_arches_from_srpm(srpm, arches):
"""Given the path to an srpm, determine the possible build arches
@@ -1527,21 +1536,14 @@ class PackageModule:
"""
# Make sure we have an srpm to run on
- srpm = os.path.join(self.path,
- "%s-%s-%s.src.rpm" % (self.module,
- self.ver, self.rel))
- # See if we need to build the srpm
- if not os.path.exists(srpm):
- # This should figure out the hashtype to use
- log.debug('No srpm found, building one.')
- self.srpm()
+ self.srpm()
# setup the command
cmd = ['mock']
cmd.extend(mockargs)
cmd.extend(['-r', self.mockconfig, '--resultdir',
os.path.join(self.path, self.module, self.ver, self.rel),
- '--rebuild', srpm])
+ '--rebuild', self.srpmname])
# Run the command
_run_command(cmd)
return
@@ -1699,6 +1701,17 @@ class PackageModule:
"""
+ self.srpmname = os.path.join(self.path,
+ "%s-%s-%s.src.rpm" % (self.module,
+ self.ver, self.rel))
+ # See if we need to build the srpm
+ if not os.path.exists(self.srpmname):
+ log.debug('No srpm found, building one.')
+ elif _newer(self.srpmname, self.spec):
+ log.debug('srpm is up-to-date, skip rebuilding')
+ # srpm is newer, don't redo it
+ return
+
cmd = ['rpmbuild']
cmd.extend(self.rpmdefines)
# Figure out which hashtype to use, if not provided one