diff options
author | Paul Sherwood <paul.sherwood@codethink.co.uk> | 2017-02-01 17:11:24 +0000 |
---|---|---|
committer | Paul Sherwood <paul.sherwood@codethink.co.uk> | 2017-02-05 12:22:41 +0000 |
commit | d1836d171f90fa3c4b59cf98954143f00d778adc (patch) | |
tree | caaaa1a3958a0158ef90ba7b323ba3d39dae2bec | |
parent | b6fa6243244b43610295be8acf908a88b81389f5 (diff) | |
download | ybd-ps-manifest-improvements.tar.gz |
Build from single .yml file if that's what is providedps-manifest-improvements
-rwxr-xr-x | ybd/__main__.py | 2 | ||||
-rw-r--r-- | ybd/app.py | 1 | ||||
-rw-r--r-- | ybd/morphs.py | 1 | ||||
-rw-r--r-- | ybd/pots.py | 17 |
4 files changed, 16 insertions, 5 deletions
diff --git a/ybd/__main__.py b/ybd/__main__.py index d1248d5..15688fa 100755 --- a/ybd/__main__.py +++ b/ybd/__main__.py @@ -72,7 +72,7 @@ with timer('TOTAL'): cache.cache_key(target) app.defs.prune() - app.defs.save('./definitions.yml') + app.defs.save(os.path.basename(config['target']) + '.yml') if 'release-note' in config: do_release_note(config['release-note']) @@ -139,6 +139,7 @@ def setup(args, original_cwd=""): sys.exit(1) log('SETUP', 'Running %s in' % args[0], os.getcwd()) + config['arg'] = args[1] config['target'] = os.path.basename(os.path.splitext(args[1])[0]) config['arch'] = args[2] config['sandboxes'] = [] diff --git a/ybd/morphs.py b/ybd/morphs.py index 5796d15..a317f76 100644 --- a/ybd/morphs.py +++ b/ybd/morphs.py @@ -28,7 +28,6 @@ class Morphs(object): self._data = {} self.defaults = Defaults() self.fields = self.defaults.build_steps + self.defaults.fields - config['cpu'] = self.defaults.cpus.get(config['arch'], config['arch']) directories = [d[0] for d in os.walk(directory) if '/.' not in d[0]] for d in sorted(directories): diff --git a/ybd/pots.py b/ybd/pots.py index c322d3f..c2dc6d6 100644 --- a/ybd/pots.py +++ b/ybd/pots.py @@ -34,10 +34,17 @@ class ExplicitDumper(yaml.SafeDumper): class Pots(object): def __init__(self, directory='.'): - self._data = Morphs()._data + if config['arg'].endswith('yml'): + log('DEFINITIONS', 'Loading all definitions from', config['arg']) + self._data = self._load_pots(config['arg']) + else: + log('DEFINITIONS', 'Loading definitions from morph files') + self._data = Morphs()._data + self._trees = {} self._set_trees() self.defaults = Defaults() + config['cpu'] = self.defaults.cpus.get(config['arch'], config['arch']) def get(self, dn): ''' Return a definition from the dictionary. @@ -61,6 +68,8 @@ class Pots(object): def _load_pots(self, filename): with open(filename) as f: + config['target'] = f.readline().strip().strip(':') + with open(filename) as f: text = f.read() return yaml.safe_load(text) @@ -98,8 +107,10 @@ class Pots(object): def prune(self): ''' Removes all elements not required for the target build/deploy ''' - log('CHECK', 'Total definitions', len(self._data)) + log('CHECK', 'Total definitions:', len(self._data)) for key in list(self._data): if not self._data[key].get('cache'): del self._data[key] - log('CHECK', 'Pruned to', len(self._data)) + if config['total'] != len(self._data): + config['total'] = len(self._data) + log('CHECK', 'Pruned to:', config['total']) |