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.
This commit is contained in:
Peter Scheibel 2018-02-06 10:50:49 -05:00 committed by Todd Gamblin
parent 2379ed54b9
commit e97c28e5b3

View File

@ -37,6 +37,7 @@
import copy
import functools
import inspect
import itertools
import os
import re
import shutil
@ -1107,7 +1108,7 @@ def do_patch(self):
# 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 @@ def do_patch(self):
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('.')