Skip to content

Commit 8108bec

Browse files
committed
allow different patches with the same name as long as they are for different package versions; note that dependency patches currently must have different names
1 parent a8228e1 commit 8108bec

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

lib/spack/spack/mirror.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ def add_single_spec(spec, mirror_root, mirror_stats):
504504
try:
505505
with spec.package.stage as pkg_stage:
506506
pkg_stage.cache_mirror(mirror_stats)
507-
for patch in spec.package.all_patches():
508-
patch.fetch(pkg_stage)
507+
for patch in spec.package.patches_for_spec(spec):
508+
patch.fetch(spec.version)
509509
if patch.cache():
510510
patch.cache().cache_mirror(mirror_stats)
511511
patch.clean()

lib/spack/spack/package.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,15 +1202,16 @@ def do_patch(self):
12021202
touch(no_patches_file)
12031203

12041204
@classmethod
1205-
def all_patches(cls):
1205+
def patches_for_spec(cls, spec):
12061206
"""Retrieve all patches associated with the package.
12071207
12081208
Retrieves patches on the package itself as well as patches on the
12091209
dependencies of the package."""
12101210
patches = []
1211-
for _, patch_list in cls.patches.items():
1212-
for patch in patch_list:
1213-
patches.append(patch)
1211+
for when_spec, patch_list in cls.patches.items():
1212+
if spec.satisfies(when_spec):
1213+
for patch in patch_list:
1214+
patches.append(patch)
12141215

12151216
pkg_deps = cls.dependencies
12161217
for dep_name in pkg_deps:

lib/spack/spack/patch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ def __init__(self, pkg, url, level=1, working_dir='.', ordering_key=None,
184184
if not self.sha256:
185185
raise PatchDirectiveError("URL patches require a sha256 checksum")
186186

187-
# TODO: this function doesn't use the stage arg
188-
def fetch(self, stage):
187+
def fetch(self, version):
189188
"""Retrieve the patch in a temporary stage and compute self.path
190189
191190
Args:
@@ -200,7 +199,8 @@ def fetch(self, stage):
200199
expand=bool(self.archive_sha256))
201200

202201
per_package_ref = os.path.join(
203-
self.owner.split('.')[-1], os.path.basename(self.url))
202+
self.owner.split('.')[-1],
203+
"{0}-{1}".format(os.path.basename(self.url), str(version)))
204204
# Reference starting with "spack." is required to avoid cyclic imports
205205
mirror_ref = spack.mirror.mirror_archive_paths(
206206
fetcher, per_package_ref)

lib/spack/spack/test/patch.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ def test_url_patch(mock_patch_stage, filename, sha256, archive_sha256):
6161

6262
# make a stage
6363
with Stage(url) as stage: # TODO: url isn't used; maybe refactor Stage
64-
stage.mirror_path = mock_patch_stage
65-
6664
mkdirp(stage.source_path)
6765
with working_dir(stage.source_path):
6866
# write a file to be patched
@@ -79,7 +77,7 @@ def test_url_patch(mock_patch_stage, filename, sha256, archive_sha256):
7977
third line
8078
""")
8179
# apply the patch and compare files
82-
patch.fetch(stage)
80+
patch.fetch('1.0')
8381
patch.apply(stage)
8482
patch.clean()
8583

0 commit comments

Comments
 (0)