Skip to content

Commit

Permalink
Put cache_keys in .trees file, print target key if mode: keys-only
Browse files Browse the repository at this point in the history
  • Loading branch information
devcurmudgeon committed Mar 13, 2016
1 parent 6cf956a commit 32dc673
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ybd/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
defs = Definitions()
with app.timer('CACHE-KEYS', 'cache-key calculations'):
cache.cache_key(defs, app.config['target'])
if app.config.get('mode', 'normal') == 'keys-only':
os._exit(0)

cache.cull(app.config['artifacts'])
target = defs.get(app.config['target'])
Expand All @@ -61,6 +59,9 @@
app.exit('ARCH', 'ERROR: no definitions found for', app.config['arch'])

defs.save_trees()
if app.config.get('mode', 'normal') == 'keys-only':
print target['cache']
os._exit(0)

sandbox.executor = sandboxlib.executor_for_platform()
app.log(app.config['target'], 'Sandbox using %s' % sandbox.executor)
Expand Down
8 changes: 6 additions & 2 deletions ybd/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,17 @@ def save_trees(self):
checksum for the state of the working subdirectories
'''
with app.chdir(app.config['defdir']):
checksum = check_output('ls -lRA */', shell=True)
try:
checksum = check_output('ls -lRA */', shell=True)
except:
checksum = check_output('ls -lRA .', shell=True)
checksum = hashlib.md5(checksum).hexdigest()
self._trees = {'.checksum': checksum}
for name in self._definitions:
if self._definitions[name].get('tree') is not None:
self._trees[name] = [self._definitions[name]['ref'],
self._definitions[name]['tree']]
self._definitions[name]['tree'],
self._definitions[name].get('cache')]

with open(os.path.join(os.getcwd(), '.trees'), 'w') as f:
f.write(yaml.safe_dump(self._trees, default_flow_style=False))

0 comments on commit 32dc673

Please sign in to comment.