diff options
author | Jesse Keating <jkeating@redhat.com> | 2010-01-05 14:21:21 -0800 |
---|---|---|
committer | Jesse Keating <jkeating@redhat.com> | 2010-01-05 14:21:21 -0800 |
commit | 7c1f76b3657a3cbb7b34da3b72d9f0e724081ecc (patch) | |
tree | 40176ce9ad1dd93507090532feee56bd28d8ab6e /src/fedpkg | |
parent | 480574e1dd20d17a97988454e5d20d77b5f40c04 (diff) | |
download | fedora-packager-7c1f76b3657a3cbb7b34da3b72d9f0e724081ecc.tar.gz fedora-packager-7c1f76b3657a3cbb7b34da3b72d9f0e724081ecc.tar.xz fedora-packager-7c1f76b3657a3cbb7b34da3b72d9f0e724081ecc.zip |
Add a compile function
Diffstat (limited to 'src/fedpkg')
-rw-r--r-- | src/fedpkg/__init__.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py index 55e6ffe..5efa69e 100644 --- a/src/fedpkg/__init__.py +++ b/src/fedpkg/__init__.py @@ -182,6 +182,37 @@ class PackageModule: self.rel = self.getrel() self.localarch = self._getlocalarch() + def compile(self, arch=None, short=False): + """Run rpm -bc on a module + + optionally for a specific arch, or short-circuit it + + Returns the output""" + + # Get the sources + self.sources() + # setup the rpm command + cmd = ['rpmbuild'] + cmd.extend(self.rpmdefines) + if arch: + cmd.extend(['--target', arch]) + if short: + cmd.append('--short-circuit') + cmd.extend(['-bc', 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 getver(self): """Return the version-release of a package module.""" |