summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2014-07-18 16:10:20 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2014-07-22 15:55:26 +0100
commit416594f21f672f651a383f37dd244381af61b10b (patch)
treead1aeb73451c94625be429f94c6d7bf4efed17d3
parentd0496731276c7b5314e7201117ca8536be4b5308 (diff)
downloadmorph-416594f21f672f651a383f37dd244381af61b10b.tar.gz
Use chunk morpholgy contents in cache keys
Previously the contents of the morphology would be included by virtue of the fact that it came from the source repository, so would be included in the "tree" field. Now that chunk morphologies can come from the definitions repository, it is not always included in the "tree" field, so the logical contents of the morphology need to be included in the cache key computation. Build commands are included after looking them up in the build-system, so that in future, we don't need to change the chunk morphology compatibility version when we change how build-systems work. Since we may be moving the morphologies about in the definitions repository, it would suck if we had to do a full rebuild after we move things, so I dropped the filename from the cache key. This also tweaks the system and stratum cache keys to include the contents directly, rather than hashed in the "morphology-sha1" field.
-rw-r--r--morphlib/cachekeycomputer.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py
index ca374436..292047c8 100644
--- a/morphlib/cachekeycomputer.py
+++ b/morphlib/cachekeycomputer.py
@@ -93,7 +93,6 @@ class CacheKeyComputer(object):
def _calculate(self, artifact):
keys = {
'env': self._filterenv(self._build_env.env),
- 'filename': artifact.source.filename,
'kids': [{'artifact': a.name, 'cache-key': self.compute_key(a)}
for a in artifact.dependencies],
'metadata-version': artifact.metadata_version
@@ -106,9 +105,24 @@ class CacheKeyComputer(object):
keys['tree'] = artifact.source.tree
keys['split-rules'] = [(a, [rgx.pattern for rgx in r._regexes])
for (a, r) in artifact.source.split_rules]
+
+ # Include morphology contents, since it doesn't always come
+ # from the source tree
+ morphology = artifact.source.morphology
+ # include {pre-,,post-}{configure,build,test,install}-commands
+ # in morphology key
+ for prefix in ('pre-', '', 'post-'):
+ for cmdtype in ('configure', 'build', 'test', 'install'):
+ cmd_field = prefix + cmdtype + '-commands'
+ keys[cmd_field] = morphology.get_commands(cmd_field)
+ keys['devices'] = morphology.get('devices')
+ keys['max-jobs'] = morphology.get('max-jobs')
+ keys['system-integration'] = morphology.get('system-integration',
+ {})
+ # products is omitted as they are part of the split-rules
elif kind in ('system', 'stratum'):
morphology = artifact.source.morphology
- le_dict = dict((k, morphology[k]) for k in morphology.keys())
+ morph_dict = dict((k, morphology[k]) for k in morphology.keys())
# Disregard all fields of a morphology that aren't important
ignored_fields = (
@@ -117,13 +131,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 morph_dict:
+ if key not in ignored_fields:
+ keys[key] = morph_dict[key]
if kind == 'stratum':
keys['stratum-format-version'] = 1
elif kind == 'system':