diff options
author | Jesse Keating <jkeating@redhat.com> | 2010-01-05 13:27:56 -0800 |
---|---|---|
committer | Jesse Keating <jkeating@redhat.com> | 2010-01-05 13:27:56 -0800 |
commit | 1ed74f3ecaae0631a5824d492e61835ff7a99d58 (patch) | |
tree | 3c958a08d17d3f6a789a0613cff47bdbbabc061d /src | |
parent | 32e108d2229f064e96a422fd9e8aa9e9f30763fb (diff) | |
download | fedora-packager-1ed74f3ecaae0631a5824d492e61835ff7a99d58.tar.gz fedora-packager-1ed74f3ecaae0631a5824d492e61835ff7a99d58.tar.xz fedora-packager-1ed74f3ecaae0631a5824d492e61835ff7a99d58.zip |
Create a prep action
Diffstat (limited to 'src')
-rw-r--r-- | src/fedpkg/__init__.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py index 61bd477..55e6ffe 100644 --- a/src/fedpkg/__init__.py +++ b/src/fedpkg/__init__.py @@ -293,6 +293,35 @@ class PackageModule: hash = _hash_file(file, self.lookasidehash) print "Would upload %s:%s" % (hash, file) return + + def prep(self, arch=None): + """Run rpm -bp on a module + + optionally for a specific arch + + Returns the output""" + + # Get the sources + self.sources() + # setup the rpm command + cmd = ['rpmbuild'] + cmd.extend(self.rpmdefines) + if arch: + cmd.extend(['--target', arch]) + cmd.extend(['--nodeps', '-bp', os.path.join(self.path, self.spec)]) + # Run the command and capture output + try: + proc = subprocess.Popen(' '.join(cmd), stderr=subprocess.STDOUT, + stdout=subprocess.PIPE, shell=True) + output = proc.communicate() + except OSError, e: + raise FedpkgError(e) + # See if we exited cleanly + if proc.returncode: + raise FedpkgError('%s returned %s: %s' % + (subprocess.list2cmdline(cmd), + proc.returncode, output[0])) + return output[0] def sources(self, outdir=None): """Download source files""" |