From 5b8c9e5ce0ffd6dec032c3637069b9dbc91e718f Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 9 May 2012 17:45:57 +0100 Subject: 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. --- morphlib/cachekeycomputer.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'morphlib/cachekeycomputer.py') 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 + -- cgit v1.2.1