diff options
author | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2008-10-05 03:36:59 -0400 |
---|---|---|
committer | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2008-10-05 03:36:59 -0400 |
commit | c304da3ab83ece610fb75cd9b9bedca8f30eaa47 (patch) | |
tree | ade3fb147170f900a88395efae22b4643d57d15e /modules | |
parent | 9b80ff4d4def847d9aaeaf3bf88bddcb35ef8ea2 (diff) | |
download | fedora-devshell-c304da3ab83ece610fb75cd9b9bedca8f30eaa47.tar.gz fedora-devshell-c304da3ab83ece610fb75cd9b9bedca8f30eaa47.tar.xz fedora-devshell-c304da3ab83ece610fb75cd9b9bedca8f30eaa47.zip |
Adds some more builder functions
Diffstat (limited to 'modules')
-rw-r--r-- | modules/build.py | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/modules/build.py b/modules/build.py index 5787674..99c05ea 100644 --- a/modules/build.py +++ b/modules/build.py @@ -1,13 +1,15 @@ from __future__ import with_statement from shutil import copyfileobj -from os.path import join -from os import listdir, getcwd +from os.path import join, abspath +from os import listdir, getcwd, walk +from subprocess import Popen from base.base import log from base.module import Module -from base.util import pwd, copy +from base.util import pwd, copy, symlink, move from base.exceptions import ExecutionException +from base.vars import FEDORA_DIR from modules.package import Package @@ -26,13 +28,56 @@ class Build(Module): raise ExecutionException(None, 'no Target Dir specified') log.debug('target dir is %s' % target_dir) with pwd(self.pkg.code_dir): - copy(self.name + '.spec', - join(self.target_dir, 'SPECS', self.name + '.spec')) + symlink(self.name + '.spec', + join(self.target_dir, 'SPECS', self.name + '.spec')) sball = self.pkg.pkg_cfg['sourceball'] - copy(sball, join(self.target_dir, 'SOURCES', sball)) + symlink(sball, join(self.target_dir, 'SOURCES', sball)) patches = [f for f in listdir(getcwd()) if f.endswith('.patch')] for p in patches: - copy(patch, join(self.target_dir, 'SOURCES', p)) + symlink(patch, join(self.target_dir, 'SOURCES', p)) + def build_quick_rpm(self, target_dir=None): + self.rpmbuild('-ba', target_dir) + + def build_source_rpm(self, target_dir=None): + self.rpmbuild('-bs', target_dir) + + def rpmbuild(self, param, target_dir=None): + if not target_dir: + if self.target_dir: + target_dir = self.target_dir + else: + raise ExecutionException(None, 'no Target Dir specified') + with pwd(self.pkg.code_dir): + rpm_out = file('rpmbuild.log', 'w') + with pwd(join(target_dir, 'SPECS')): + p = Popen(['rpmbuild', param, self.name + '.spec'], + stdout=rpm_out, stderr=rpm_out) + log.info('quick compiling %s... please wait' % self.name) + p.wait() + rpm_out.close() + + def fetch_rpms(self, target_dir=None): + if not target_dir: + if self.target_dir: + target_dir = self.target_dir + else: + raise ExecutionException(None, 'no Target Dir specified') + with pwd(target_dir): + for path, dirs, files in walk('.'): + for f in files: + if f.endswith('.rpm'): + move(join(path, f), join(FEDORA_DIR, f)) + + def fetch_build(self, target_dir=None): + if not target_dir: + if self.target_dir: + target_dir = self.target_dir + else: + raise ExecutionException(None, 'no Target Dir specified') + with pwd(target_dir): + source = self.pkg.pkg_cfg['source'] + move(join('BUILD', source), join(self.pkg.code_dir, 'results')) + def close(self): - pass
\ No newline at end of file + self.pkg.close() |