gns3-server: update to 2.2.52.
[void-pkg.git] / common / hooks / do-patch / 00-patches.sh
blobc75209f931e19bf02bb8ec7549dec9d8ff574118
1 # This hook applies patches from "patches" directory.
3 _process_patch() {
4 local _args= _patch= i=$1
6 _args="-Np1"
7 _patch=${i##*/}
9 if [ -f "$PATCHESDIR/${_patch}.args" ]; then
10 _args=$(<"$PATCHESDIR/${_patch}.args")
11 elif [ -n "$patch_args" ]; then
12 _args=$patch_args
14 cp -f "$i" "$wrksrc"
16 # Try to guess if its a compressed patch.
17 if [[ $i =~ .gz$ ]]; then
18 gunzip "$wrksrc/${_patch}"
19 _patch=${_patch%%.gz}
20 elif [[ $i =~ .bz2$ ]]; then
21 bunzip2 "$wrksrc/${_patch}"
22 _patch=${_patch%%.bz2}
23 elif [[ $i =~ .diff$ ]]; then
25 elif [[ $i =~ .patch$ ]]; then
27 else
28 msg_warn "$pkgver: unknown patch type: $i.\n"
29 return 0
32 cd "$wrksrc"
33 msg_normal "$pkgver: patching: ${_patch}.\n"
34 patch -s ${_args} <"${_patch}" 2>/dev/null
37 hook() {
38 if [ ! -d "$wrksrc" ]; then
39 return 0
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
51 _process_patch "$f"
52 done