diff options
Diffstat (limited to 'lib/spack/spack/patch.py')
-rw-r--r-- | lib/spack/spack/patch.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/spack/spack/patch.py b/lib/spack/spack/patch.py index cb012af7ff..79550538db 100644 --- a/lib/spack/spack/patch.py +++ b/lib/spack/spack/patch.py @@ -16,6 +16,7 @@ import spack.fetch_strategy as fs import spack.repo import spack.stage import spack.util.spack_json as sjson +import spack from spack.util.compression import allowed_archive from spack.util.crypto import checksum, Checker @@ -87,6 +88,9 @@ class Patch(object): apply_patch(stage, self.path, self.level, self.working_dir) + def cache(self): + return None + def to_dict(self): """Partial dictionary -- subclases should add to this.""" return { @@ -180,6 +184,7 @@ class UrlPatch(Patch): if not self.sha256: raise PatchDirectiveError("URL patches require a sha256 checksum") + # TODO: this function doesn't use the stage arg def fetch(self, stage): """Retrieve the patch in a temporary stage and compute self.path @@ -191,15 +196,19 @@ class UrlPatch(Patch): if self.archive_sha256: fetch_digest = self.archive_sha256 - fetcher = fs.URLFetchStrategy(self.url, fetch_digest) - mirror = os.path.join(os.path.dirname(stage.mirror_path), - os.path.basename(self.url)) + fetcher = fs.URLFetchStrategy(self.url, fetch_digest, + expand=bool(self.archive_sha256)) + + per_package_ref = os.path.join( + self.owner.split('.')[-1], os.path.basename(self.url)) + # Reference starting with "spack." is required to avoid cyclic imports + mirror_ref = spack.mirror.mirror_archive_paths( + fetcher, per_package_ref) - self.stage = spack.stage.Stage(fetcher, mirror_path=mirror) + self.stage = spack.stage.Stage(fetcher, mirror_paths=mirror_ref) self.stage.create() self.stage.fetch() self.stage.check() - self.stage.cache_local() root = self.stage.path if self.archive_sha256: @@ -230,6 +239,9 @@ class UrlPatch(Patch): "sha256 checksum failed for %s" % self.path, "Expected %s but got %s" % (self.sha256, checker.sum)) + def cache(self): + return self.stage + def clean(self): self.stage.destroy() |