diff options
-rwxr-xr-x | fedpkg-pull-build-chain | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/fedpkg-pull-build-chain b/fedpkg-pull-build-chain index 9c1d35c..f72acff 100755 --- a/fedpkg-pull-build-chain +++ b/fedpkg-pull-build-chain @@ -25,6 +25,10 @@ def check_call_verbose(*args, **kwargs): print "Running: %r" % (args[0], ) subprocess.check_call(*args, **kwargs) +def popen_verbose(*args, **kwargs): + print "Running: %r" % (args[0], ) + return subprocess.Popen(*args, **kwargs) + STATE_STARTING = 'starting' STATE_VCS = 'vcs' STATE_BUILDING = 'building' @@ -40,7 +44,7 @@ class FedpkgPullBuildChainState(dbus.service.Object): def main(): try: - opts, args = getopt.getopt(sys.argv[1:], '', ['release=', 'arch=', 'resultdir=', 'force']) + opts, args = getopt.getopt(sys.argv[1:], '', ['release=', 'arch=', 'resultdir=', 'delete-old', 'force']) except getopt.GetoptError, e: print unicode(e) print "Usage: fedpkg-pull-build-chain --release=F-12 --resultdir=/path/to/repo rpm1 rpm2 ..." @@ -61,6 +65,7 @@ def main(): dbus.SessionBus().flush() force = False + delete_old = False release = None resultdir = None architectures = [] @@ -73,7 +78,9 @@ def main(): architectures.append(a) elif o in ('--resultdir', ): resultdir = a - + elif o in ('--delete-old', ): + delete_old = True + if release is None: print "Must specify --release" sys.exit(1) @@ -201,6 +208,12 @@ def main(): os.link(src, linkname) notify_state('createrepo', {}) check_call_verbose(['createrepo', '.'], cwd=resultdir) + if delete_old: + proc = popen_verbose(['repomanage', '-o', '.'], stdout=subprocess.PIPE, stderr=sys.stderr, cwd=resultdir) + output = proc.communicate()[0] + for line in output.split('\n'): + if line.endswith('.rpm') and os.path.exists(line): + os.unlink(line) f = open(lastbuild_filepath, 'w') f.write('success') |