From 30e2e7b423d8d8efbea9679ac92de313d42d00f9 Mon Sep 17 00:00:00 2001 From: Pyry Haulos Date: Wed, 10 Aug 2016 12:26:45 -0700 Subject: [PATCH] fetch_souces.py: cache extracted hash and only extract if necessary Change-Id: I62119f60325d1d646b7777ed57941e34df601df3 --- external/fetch_sources.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/external/fetch_sources.py b/external/fetch_sources.py index 6a68bf5..d7ad204 100644 --- a/external/fetch_sources.py +++ b/external/fetch_sources.py @@ -65,9 +65,10 @@ class SourcePackage (Source): if not self.isArchiveUpToDate(): self.fetchAndVerifyArchive() - # \note No way to verify that extracted contents match archive, re-extract - Source.clean(self) - self.extract() + if self.getExtractedChecksum() != self.checksum: + Source.clean(self) + self.extract() + self.storeExtractedChecksum(self.checksum) def removeArchives (self): archiveDir = os.path.join(EXTERNAL_DIR, pkg.baseDir, pkg.archiveDir) @@ -81,6 +82,20 @@ class SourcePackage (Source): else: return False + def getExtractedChecksumFilePath (self): + return os.path.join(EXTERNAL_DIR, pkg.baseDir, pkg.archiveDir, "extracted") + + def getExtractedChecksum (self): + extractedChecksumFile = self.getExtractedChecksumFilePath() + + if os.path.exists(extractedChecksumFile): + return readFile(extractedChecksumFile) + else: + return None + + def storeExtractedChecksum (self, checksum): + writeFile(self.getExtractedChecksumFilePath(), checksum) + def fetchAndVerifyArchive (self): print "Fetching %s" % self.url -- 2.7.4