diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-07-03 13:48:20 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-07-14 13:43:04 +0000 |
commit | 1feadd7671feb41d422c39cec607e45ceb3844e0 (patch) | |
tree | f5d51bc7791c1c7040cd815a41e56cea1bc425f4 | |
parent | 3f686a074fdb66e75e67e276d21bdc604b34920c (diff) | |
download | morph-1feadd7671feb41d422c39cec607e45ceb3844e0.tar.gz |
Use the whole chunk morphology to compute cache keys
Change the cache key computer to use all (useful) fields in the chunk
morphology to compute the cache key for a chunk. Previously, changing a
chunk morphology meant the chunk ref would need to change, but now this
is not the case, so the cache key needs to change when the morphology
does.
Also, amend the cache key computation for systems and strata to store
the use the morphology contents directly rather than hashing it.
-rw-r--r-- | morphlib/cachekeycomputer.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py index ca374436..be9da335 100644 --- a/morphlib/cachekeycomputer.py +++ b/morphlib/cachekeycomputer.py @@ -101,9 +101,12 @@ class CacheKeyComputer(object): kind = artifact.source.morphology['kind'] if kind == 'chunk': - keys['build-mode'] = artifact.source.build_mode - keys['prefix'] = artifact.source.prefix - keys['tree'] = artifact.source.tree + morphology = artifact.source.morphology + morph_dict = dict((k, morphology[k]) for k in morphology.keys()) + ignored_fields = ['description'] + for key in morph_dict: + if key not in ignored_fields: + keys[key] = morph_dict[key] keys['split-rules'] = [(a, [rgx.pattern for rgx in r._regexes]) for (a, r) in artifact.source.split_rules] elif kind in ('system', 'stratum'): @@ -117,13 +120,9 @@ class CacheKeyComputer(object): # so are already handled by the 'kids' field. 'strata', 'build-depends', 'chunks', 'products') - for ignored_field in ignored_fields: - if ignored_field in le_dict: - del le_dict[ignored_field] - - checksum = hashlib.sha1() - self._hash_thing(checksum, le_dict) - keys['morphology-sha1'] = checksum.hexdigest() + for key in le_dict: + if key not in ignored_fields: + keys[key] = le_dict[key] if kind == 'stratum': keys['stratum-format-version'] = 1 elif kind == 'system': |