diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-05-09 17:45:57 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-05-09 17:45:57 +0100 |
commit | 5b8c9e5ce0ffd6dec032c3637069b9dbc91e718f (patch) | |
tree | 7c9297a3548c48183a8e97e62dc4ac49ac33463c /morphlib/cachekeycomputer.py | |
parent | a1305ad1e8f0496b42a6037ed114523d963d9698 (diff) | |
download | morph-5b8c9e5ce0ffd6dec032c3637069b9dbc91e718f.tar.gz |
Change cache keys for strata, systems to use sha of morphology, instead of commit
This avoids a problem where we make a change to one system morphology in
the "morphs" repository, and then we have to rebuild all system and
stratum artifacts, because their commit sha1 also changed. With this
change, we don't care about the commit sha1 for systems and strata,
just the contents of the morphologies.
Diffstat (limited to 'morphlib/cachekeycomputer.py')
-rw-r--r-- | morphlib/cachekeycomputer.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py index 033c0318..a1c2ebd6 100644 --- a/morphlib/cachekeycomputer.py +++ b/morphlib/cachekeycomputer.py @@ -78,10 +78,23 @@ class CacheKeyComputer(object): return cacheid def _calculate(self, artifact): - return { + keys = { 'arch': self._build_env.arch, 'env': self._filterenv(self._build_env.env), - 'ref': artifact.source.sha1, 'filename': artifact.source.filename, 'kids': [self.compute_key(x) for x in artifact.dependencies] } + + kind = artifact.source.morphology['kind'] + if kind == 'chunk': + keys['ref'] = artifact.source.sha1 + elif kind in ('system', 'stratum'): + checksum = hashlib.sha1() + morphology = artifact.source.morphology + getkey = lambda s: [ord(c) for c in s] + for key in sorted(morphology.keys(), key=getkey): + checksum.update('%s=%s' % (key, morphology[key])) + keys['morphology-sha1'] = checksum.hexdigest() + + return keys + |