summaryrefslogtreecommitdiffstats
path: root/modules/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/build.py')
-rw-r--r--modules/build.py96
1 files changed, 37 insertions, 59 deletions
diff --git a/modules/build.py b/modules/build.py
index de89d88..5481507 100644
--- a/modules/build.py
+++ b/modules/build.py
@@ -25,87 +25,65 @@ from subprocess import Popen
from base.base import log
from base.module import Module
-from base.util import pwd, copy, symlink, move
+from base.util import pwd, copy, symlink, move, log_file
from base.exceptions import ExecutionException
from base.vars import FEDORA_DIR
from base.profiles import dir_defines, join_defines, dist_defines, Profile
+from modules.directory import Directory
+from modules.dirfactory import DirFactory
from modules.package import Package
-class Build(Module):
- def __init__(self, name=None, target_dir=None):
- log.debug('name is %s' % name)
- self.name = name
- self.pkg = Package(name)
- self.target_dir = target_dir
-
- def setup_source(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')
- log.debug('target dir is %s' % target_dir)
- with pwd(self.pkg.code_dir):
- symlink(self.name + '.spec',
- join(self.target_dir, 'SPECS', self.name + '.spec'))
- sball = self.pkg.pkg_cfg['sourceball']
- symlink(sball, join(self.target_dir, 'SOURCES', sball))
+class Build(Directory):
+ _type = 'build'
+ def setup_source(self, package):
+ pkg = DirFactory(package)
+ with pwd(pkg.dir):
+ symlink(pkg.spec_file,
+ join(self.dir, 'SPECS', pkg.spec_file()))
+ sball = pkg.cfg['sourceball']
+ symlink(sball, join(self.dir, 'SOURCES', sball))
patches = [f for f in listdir(getcwd()) if f.endswith('.patch')]
- for p in patches:
- symlink(patch, join(self.target_dir, 'SOURCES', p))
+ for patch in patches:
+ symlink(patch, join(self.dir, 'SOURCES', patch))
- def build_quick_rpm(self, target_dir=None):
- self.rpmbuild('-ba', target_dir)
+ def build_quick_rpm(self):
+ self.rpmbuild('-ba')
- def build_source_rpm(self, target_dir=None):
- self.rpmbuild('-bs', target_dir)
+ def build_source_rpm(self):
+ self.rpmbuild('-bs')
- def rpmbuild(self, param, target_dir=None, profile=None):
- if not target_dir:
- if self.target_dir:
- target_dir = self.target_dir
- else:
- raise ExecutionException(None, 'no Target Dir specified')
+ def rpmbuild(self, param, package, profile=None):
+ pkg = DirFactory(package)
if profile:
defines = join_defines(profile.dist_defines,
- dir_defines(target_dir))
+ dir_defines(self.dir))
else:
- defines = dir_defines(target_dir)
- with pwd(self.pkg.code_dir):
- with file('rpmbuild.log', 'w') as rpm_out:
- with pwd(join(target_dir, 'SPECS')):
+ defines = dir_defines(self.dir)
+ with pwd(pkg.dir):
+ with log_file('rpmbuild.log') as rpm_out:
+ with pwd(join(self.dir, 'SPECS')):
p = Popen(['rpmbuild',
defines, param,
- self.name + '.spec'],
+ pkg.spec_file],
stdout=rpm_out, stderr=rpm_out)
- log.info('building %s... please wait' % \
- self.pkg.spec_file())
+ log.info('building %s... please wait'
+ % pkg.spec_file)
p.wait()
- 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):
+ def fetch_rpms(self):
+ with pwd(self.dir):
for path, dirs, files in walk('.'):
for f in files:
if f.endswith('.rpm'):
+ #TODO: Gotta figure out what should be FEDORA_DIR
+ # Probably something involving "Project" or i dunno what
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 fetch_build(self, package):
+ pkg = DirFactory(package)
+ with pwd(self.dir):
+ source = pkg.cfg['source']
+ move(join('BUILD', source), join(pkg.dir, 'results'))
- def close(self):
- self.pkg.close()
-
__all__ = ['Build']