summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2010-01-05 14:25:13 -0800
committerJesse Keating <jkeating@redhat.com>2010-01-05 14:25:13 -0800
commit7d94d9968d1ada36ce2190f2a2601b89aab2dd56 (patch)
tree9bd0eff54754b3f3e92c541b93bd52c06b7a82c3 /src
parentc905e7a9f89171d32b4238a90d6c1fb1247a760d (diff)
downloadfedora-packager-7d94d9968d1ada36ce2190f2a2601b89aab2dd56.tar.gz
fedora-packager-7d94d9968d1ada36ce2190f2a2601b89aab2dd56.tar.xz
fedora-packager-7d94d9968d1ada36ce2190f2a2601b89aab2dd56.zip
Add an install function
Diffstat (limited to 'src')
-rw-r--r--src/fedpkg/__init__.py31
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"""