@@ -454,13 +454,17 @@ def fetch_patches(self, patch_specs=None, extension=False, checksums=None):
454454 Add a list of patches.
455455 All patches will be checked if a file exists (or can be located)
456456 """
457+ post_install_patches = []
457458 if patch_specs is None :
458- patch_specs = self .cfg ['patches' ]
459+ # if no patch_specs are specified, use all pre-install and post-install patches
460+ post_install_patches = self .cfg ['postinstallpatches' ]
461+ patch_specs = self .cfg ['patches' ] + post_install_patches
459462
460463 patches = []
461464 for index , patch_spec in enumerate (patch_specs ):
462465
463466 patch_info = create_patch_info (patch_spec )
467+ patch_info ['postinstall' ] = patch_spec in post_install_patches
464468
465469 force_download = build_option ('force_download' ) in [FORCE_DOWNLOAD_ALL , FORCE_DOWNLOAD_PATCHES ]
466470 path = self .obtain_file (patch_info ['name' ], extension = extension , force_download = force_download )
@@ -2230,7 +2234,7 @@ def fetch_step(self, skip_checksums=False):
22302234 self .dry_run_msg ("\n List of patches:" )
22312235
22322236 # fetch patches
2233- if self .cfg ['patches' ]:
2237+ if self .cfg ['patches' ] + self . cfg [ 'postinstallpatches' ] :
22342238 if isinstance (self .cfg ['checksums' ], (list , tuple )):
22352239 # if checksums are provided as a list, first entries are assumed to be for sources
22362240 patches_checksums = self .cfg ['checksums' ][len (self .cfg ['sources' ]):]
@@ -2402,11 +2406,15 @@ def extract_step(self):
24022406 else :
24032407 raise EasyBuildError ("Unpacking source %s failed" , src ['name' ])
24042408
2405- def patch_step (self , beginpath = None ):
2409+ def patch_step (self , beginpath = None , patches = None ):
24062410 """
24072411 Apply the patches
24082412 """
2409- for patch in self .patches :
2413+ if patches is None :
2414+ # if no patches are specified, use all non-post-install patches
2415+ patches = [p for p in self .patches if not p ['postinstall' ]]
2416+
2417+ for patch in patches :
24102418 self .log .info ("Applying patch %s" % patch ['name' ])
24112419 trace_msg ("applying patch %s" % patch ['name' ])
24122420
@@ -2821,13 +2829,25 @@ def run_post_install_commands(self, commands=None):
28212829 raise EasyBuildError ("Invalid element in 'postinstallcmds', not a string: %s" , cmd )
28222830 run_cmd (cmd , simple = True , log_ok = True , log_all = True )
28232831
2832+ def apply_post_install_patches (self , patches = None ):
2833+ """
2834+ Apply post-install patch files that are specified via the 'postinstallpatches' easyconfig parameter.
2835+ """
2836+ if patches is None :
2837+ patches = [p for p in self .patches if p ['postinstall' ]]
2838+
2839+ self .log .debug ("Post-install patches to apply: %s" , patches )
2840+ if patches :
2841+ self .patch_step (beginpath = self .installdir , patches = patches )
2842+
28242843 def post_install_step (self ):
28252844 """
28262845 Do some postprocessing
28272846 - run post install commands if any were specified
28282847 """
28292848
28302849 self .run_post_install_commands ()
2850+ self .apply_post_install_patches ()
28312851
28322852 self .fix_shebang ()
28332853
0 commit comments