@@ -179,14 +179,18 @@ def report_hook(index, blksize, size):
179179 shprint (sh .git , 'submodule' , 'update' , '--recursive' )
180180 return target
181181
182- def apply_patch (self , filename , arch ):
182+ def apply_patch (self , filename , arch , build_dir = None ):
183183 """
184184 Apply a patch from the current recipe directory into the current
185185 build directory.
186+
187+ .. versionchanged:: 0.6.0
188+ Add ability to apply patch from any dir via kwarg `build_dir`'''
186189 """
187190 info ("Applying patch {}" .format (filename ))
191+ build_dir = build_dir if build_dir else self .get_build_dir (arch )
188192 filename = join (self .get_recipe_dir (), filename )
189- shprint (sh .patch , "-t" , "-d" , self . get_build_dir ( arch ) , "-p1" ,
193+ shprint (sh .patch , "-t" , "-d" , build_dir , "-p1" ,
190194 "-i" , filename , _tail = 10 )
191195
192196 def copy_file (self , filename , dest ):
@@ -441,8 +445,11 @@ def is_patched(self, arch):
441445 build_dir = self .get_build_dir (arch .arch )
442446 return exists (join (build_dir , '.patched' ))
443447
444- def apply_patches (self , arch ):
445- '''Apply any patches for the Recipe.'''
448+ def apply_patches (self , arch , build_dir = None ):
449+ '''Apply any patches for the Recipe.
450+
451+ .. versionchanged:: 0.6.0
452+ Add ability to apply patches from any dir via kwarg `build_dir`'''
446453 if self .patches :
447454 info_main ('Applying patches for {}[{}]'
448455 .format (self .name , arch .arch ))
@@ -451,6 +458,7 @@ def apply_patches(self, arch):
451458 info_main ('{} already patched, skipping' .format (self .name ))
452459 return
453460
461+ build_dir = build_dir if build_dir else self .get_build_dir (arch .arch )
454462 for patch in self .patches :
455463 if isinstance (patch , (tuple , list )):
456464 patch , patch_check = patch
@@ -459,9 +467,9 @@ def apply_patches(self, arch):
459467
460468 self .apply_patch (
461469 patch .format (version = self .version , arch = arch .arch ),
462- arch .arch )
470+ arch .arch , build_dir = build_dir )
463471
464- shprint (sh .touch , join (self . get_build_dir ( arch . arch ) , '.patched' ))
472+ shprint (sh .touch , join (build_dir , '.patched' ))
465473
466474 def should_build (self , arch ):
467475 '''Should perform any necessary test and return True only if it needs
0 commit comments