common/do-patch: handle spaces in patch filename

This commit is contained in:
Piotr Wójcik 2022-05-19 20:56:42 +02:00
parent f134c0484c
commit bfda85dace
2 changed files with 10 additions and 10 deletions

View File

@ -6,23 +6,23 @@ _process_patch() {
_args="-Np1"
_patch=${i##*/}
if [ -f $PATCHESDIR/${_patch}.args ]; then
_args=$(<$PATCHESDIR/${_patch}.args)
if [ -f "$PATCHESDIR/${_patch}.args" ]; then
_args=$(<"$PATCHESDIR/${_patch}.args")
elif [ -n "$patch_args" ]; then
_args=$patch_args
fi
cp -f $i "$wrksrc"
cp -f "$i" "$wrksrc"
# Try to guess if its a compressed patch.
if [[ $f =~ .gz$ ]]; then
if [[ $i =~ .gz$ ]]; then
gunzip "$wrksrc/${_patch}"
_patch=${_patch%%.gz}
elif [[ $f =~ .bz2$ ]]; then
elif [[ $i =~ .bz2$ ]]; then
bunzip2 "$wrksrc/${_patch}"
_patch=${_patch%%.bz2}
elif [[ $f =~ .diff$ ]]; then
elif [[ $i =~ .diff$ ]]; then
:
elif [[ $f =~ .patch$ ]]; then
elif [[ $i =~ .patch$ ]]; then
:
else
msg_warn "$pkgver: unknown patch type: $i.\n"
@ -31,7 +31,7 @@ _process_patch() {
cd "$wrksrc"
msg_normal "$pkgver: patching: ${_patch}.\n"
patch -s ${_args} <${_patch} 2>/dev/null
patch -s ${_args} <"${_patch}" 2>/dev/null
}
hook() {
@ -44,11 +44,11 @@ hook() {
done < $PATCHESDIR/series
else
for f in $PATCHESDIR/*; do
[ ! -f $f ] && continue
[ ! -f "$f" ] && continue
if [[ $f =~ ^.*.args$ ]]; then
continue
fi
_process_patch $f
_process_patch "$f"
done
fi
}