diff options
| author | Jesse Keating <jkeating@redhat.com> | 2010-01-04 15:59:41 -0800 |
|---|---|---|
| committer | Jesse Keating <jkeating@redhat.com> | 2010-01-04 15:59:41 -0800 |
| commit | 5c0a9bef181a3380921b90aafaf985ab0fe07ba1 (patch) | |
| tree | f86b4793cee37f373dec8febacf7f45f0872b638 /src/fedpkg | |
| parent | a52412f0975f2c2b192e8a56f9654e45f4087116 (diff) | |
| download | fedpkg-5c0a9bef181a3380921b90aafaf985ab0fe07ba1.tar.gz fedpkg-5c0a9bef181a3380921b90aafaf985ab0fe07ba1.tar.xz fedpkg-5c0a9bef181a3380921b90aafaf985ab0fe07ba1.zip | |
Add a local target to build locally
This still has some errors, and I think I need to run the rpm stuff in a real
shell, which would require re-working the rpm defines and editing the other
functions that use them. What fun!
Diffstat (limited to 'src/fedpkg')
| -rw-r--r-- | src/fedpkg/__init__.py | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py index 4f5e559..696338f 100644 --- a/src/fedpkg/__init__.py +++ b/src/fedpkg/__init__.py @@ -204,7 +204,48 @@ class PackageModule: except subprocess.CalledProcessError, e: raise FedpkgError(e) return output[0] - + + def local(self, arch=None, hashtype='sha256'): + """rpmbuild locally for given arch. + + Takes arch to build for, and hashtype to build with. + + Writes output to a log file and returns output from build. + + """ + + # Get the sources + self.sources() + # Determine arch to build for + if not arch: + arch = self.localarch + # build up the rpm command + cmd = ['rpmbuild'] + cmd.extend(self.rpmdefines) + # This may need to get updated if we ever change our checksum default + if not hashtype == 'sha256': + cmd.extend(['--define', + '_source_filedigest_algorithm %s' % hashtype, + '--define', + '_binary_filedigest_algorithm %s' % hashtype]) + cmd.extend(['--target', arch, '-ba', + os.path.join(self.path, self.spec)]) + try: + proc = subprocess.Popen(cmd, stderr=subprocess.STDOUT, + stdout=subprocess.PIPE) + output = proc.communicate() + except OSError, e: + raise FedpkgError(e) + outfile = open(os.path.join(self.path, '.build-%s-%s.log' % (self.ver, + self.rel)), 'w') + outfile.writelines(output[0]) + outfile.close() + # See if we had a good return or not, raise accordingly + if proc.returncode: + raise FedpkgError('%s returned %s: %s' % + (subprocess.list2cmdline(cmd), + proc.returncode, output[0])) + return output[0] def new_sources(self, files): """Replace source file(s) in the lookaside cache""" |
