@@ -179,14 +179,18 @@ def report_hook(index, blksize, size):
179
179
shprint (sh .git , 'submodule' , 'update' , '--recursive' )
180
180
return target
181
181
182
- def apply_patch (self , filename , arch ):
182
+ def apply_patch (self , filename , arch , build_dir = None ):
183
183
"""
184
184
Apply a patch from the current recipe directory into the current
185
185
build directory.
186
+
187
+ .. versionchanged:: 0.6.0
188
+ Add ability to apply patch from any dir via kwarg `build_dir`'''
186
189
"""
187
190
info ("Applying patch {}" .format (filename ))
191
+ build_dir = build_dir if build_dir else self .get_build_dir (arch )
188
192
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" ,
190
194
"-i" , filename , _tail = 10 )
191
195
192
196
def copy_file (self , filename , dest ):
@@ -441,8 +445,11 @@ def is_patched(self, arch):
441
445
build_dir = self .get_build_dir (arch .arch )
442
446
return exists (join (build_dir , '.patched' ))
443
447
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`'''
446
453
if self .patches :
447
454
info_main ('Applying patches for {}[{}]'
448
455
.format (self .name , arch .arch ))
@@ -451,6 +458,7 @@ def apply_patches(self, arch):
451
458
info_main ('{} already patched, skipping' .format (self .name ))
452
459
return
453
460
461
+ build_dir = build_dir if build_dir else self .get_build_dir (arch .arch )
454
462
for patch in self .patches :
455
463
if isinstance (patch , (tuple , list )):
456
464
patch , patch_check = patch
@@ -459,9 +467,9 @@ def apply_patches(self, arch):
459
467
460
468
self .apply_patch (
461
469
patch .format (version = self .version , arch = arch .arch ),
462
- arch .arch )
470
+ arch .arch , build_dir = build_dir )
463
471
464
- shprint (sh .touch , join (self . get_build_dir ( arch . arch ) , '.patched' ))
472
+ shprint (sh .touch , join (build_dir , '.patched' ))
465
473
466
474
def should_build (self , arch ):
467
475
'''Should perform any necessary test and return True only if it needs
0 commit comments