00-patches.sh (1075B)
1# This hook applies patches from "patches" directory. 2 3_process_patch() { 4 local _args= _patch= i=$1 5 6 _args="-Np0" 7 _patch=${i##*/} 8 9 if [ -f $PATCHESDIR/${_patch}.args ]; then 10 _args=$(<$PATCHESDIR/${_patch}.args) 11 elif [ -n "$patch_args" ]; then 12 _args=$patch_args 13 fi 14 cp -f $i "$wrksrc" 15 16 # Try to guess if its a compressed patch. 17 if [[ $f =~ .gz$ ]]; then 18 gunzip "$wrksrc/${_patch}" 19 _patch=${_patch%%.gz} 20 elif [[ $f =~ .bz2$ ]]; then 21 bunzip2 "$wrksrc/${_patch}" 22 _patch=${_patch%%.bz2} 23 elif [[ $f =~ .diff$ ]]; then 24 : 25 elif [[ $f =~ .patch$ ]]; then 26 : 27 else 28 msg_warn "$pkgver: unknown patch type: $i.\n" 29 return 0 30 fi 31 32 cd "$wrksrc" 33 msg_normal "$pkgver: patching: ${_patch}.\n" 34 patch -sl ${_args} -i ${_patch} 2>/dev/null 35} 36 37hook() { 38 if [ ! -d "$wrksrc" ]; then 39 return 0 40 fi 41 if [ -r $PATCHESDIR/series ]; then 42 while read -r f; do 43 _process_patch "$PATCHESDIR/$f" 44 done < $PATCHESDIR/series 45 else 46 for f in $PATCHESDIR/*; do 47 [ ! -f $f ] && continue 48 if [[ $f =~ ^.*.args$ ]]; then 49 continue 50 fi 51 _process_patch $f 52 done 53 fi 54}