From 7d94d9968d1ada36ce2190f2a2601b89aab2dd56 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Tue, 5 Jan 2010 14:25:13 -0800 Subject: Add an install function --- src/fedpkg/__init__.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src') 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""" -- cgit