diff options
-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 5efa69e..99b3e5e 100644 --- a/src/fedpkg/__init__.py +++ b/src/fedpkg/__init__.py @@ -252,6 +252,37 @@ class PackageModule: return f raise FedpkgError('No spec file found.') + def install(self, arch=None, short=False): + """Run rpm -bi 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(['-bi', 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 lint(self): """Run rpmlint over a built srpm""" |