diff options
Diffstat (limited to 'modules/package.py')
| -rw-r--r-- | modules/package.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/modules/package.py b/modules/package.py index 8fdeb93..bf1e3ec 100644 --- a/modules/package.py +++ b/modules/package.py @@ -23,7 +23,7 @@ from os.path import split from base.base import log from base.dirfactory import DirFactory from base.exceptions import ExecutionException -from base.util import pwd, copy, move +from base.util import pwd, copy, move, symlink from base.profiles import ver_rel, name from modules.directory import Directory @@ -32,9 +32,21 @@ class Package(Directory): # These two methods are here as examples. def load_dir(self, dir): super(Package, self).load_dir(dir) + self._check_sources() def make_dir(self, dir): super(Package, self).make_dir(dir) + self._check_sources() + + def _check_sources(self): + '''necessary to make sure self.sources is a list + ''' + if 'sources' not in self.cfg: + self.cfg['sources'] = list() + elif type(self.sources) is not list: + log.warn('sources for this package is not a list, overwriting!') + log.info('sources was, fyi, ' + str(self.sources)) + self.cfg['sources'] = list() def add_spec(self, spec_file): '''add's a spec file to the package, and sets the canonical package @@ -82,11 +94,41 @@ class Package(Directory): def sources(self): return self.cfg['sources'] + def copy_source(self, source_dir): + source = DirFactory(source_dir) + target_dir = join(self.dir, source.name) + if not source.dir == target_dir: + source.copy(target_dir) + self.add_source(source_dir) + + def move_source(self, source_dir): + source = DirFactory(source_dir) + target_dir = join(self.dir, source.name) + if not source.dir == target_dir: + source.move(target_dir) + self.add_source(source_dir) + def add_source(self, source_dir): source = DirFactory(source_dir) if not source.name in self.sources: self.cfg['sources'].append(source.name) + def rem_source(self, source): + self.cfg['sources'].remove(source) + + def del_source(self, source): + self.rem_source(source) + with pwd(self.dir): + rm(source) + + def fetch_sourceballs(self, profile=None): + pkg_srcen = self.sources + pkg_srcen = (DirFactory(pkg_src) for pkg_src in pkg_srcen) + with pwd(self.dir): + for pkg_src in pkg_srcen: + pkg_src.setup_sourceball(self.ver(profile)) + symlink(pkg_src.sourceball_loc, pkg_src.sourceball) + # These don't make sense anymore # TODO: Figure out the API to iterate over PackageSources where *args should be diff for each one # def source_dir(self, *args): |
