From e97c28e5b3c8b65dc57d6fe737a14b7bc2a5d8ac Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Tue, 6 Feb 2018 10:50:49 -0500 Subject: package: ensure patches are applied in-order This helps to ensure that patches are applied consistently and will also be used as the source for the patch part of full package hashes. --- lib/spack/spack/package.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 0b49cf5db3..19a565e019 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -37,6 +37,7 @@ import contextlib import copy import functools import inspect +import itertools import os import re import shutil @@ -1107,7 +1108,7 @@ class PackageBase(with_metaclass(PackageMeta, object)): # Apply all the patches for specs that match this one patched = False - for patch in patches: + for patch in self.patches_to_apply(): try: with working_dir(self.stage.source_path): patch.apply(self.stage) @@ -1151,6 +1152,15 @@ class PackageBase(with_metaclass(PackageMeta, object)): else: touch(no_patches_file) + def patches_to_apply(self): + """If the patch set does not change between two invocations of spack, + then all patches in the set will be applied in the same order""" + patchesToApply = itertools.chain.from_iterable( + patch_list + for spec, patch_list in self.patches.items() + if self.spec.satisfies(spec)) + return sorted(patchesToApply, key=lambda p: p.path_or_url) + @property def namespace(self): namespace, dot, module = self.__module__.rpartition('.') -- cgit v1.2.3-70-g09d2