Compare commits

...

4 commits

9
apatch
View file

@ -44,7 +44,8 @@ abuild clean fetch unpack default_prepare
startdir="$PWD"
srcdir="$startdir/src"
. APKBUILD
test -n "$builddir" || builddir="$srcdir/$pkgname-$pkgver"
unset -f grep cut head git rm mv
[ -n "$builddir" ] || builddir="$srcdir/$pkgname-$pkgver"
patchpath="$startdir/$1"
@ -67,7 +68,7 @@ if [ -f "$patchpath" ]; then
msg "patch exists, trying to extract existing message"
# try to extract the original header from the patch
patch_start=$(grep -En '^(diff --git|--- )' "$patchpath" | cut -d: -f1 | head -n 1)
header_file="$(mktemp -t apatch.XXXXXX)"
header_file="/tmp/$(mktemp -u apatch.XXXXXX)"
head -n $(( patch_start - 1 )) "$patchpath" > "$header_file"
fi
@ -80,7 +81,7 @@ fi
# if file exists, try to apply
if [ -e "$patchpath" ]; then
git apply --reject --whitespace=fix "$patchpath" || {
rejects="$(git status --porcelain | grep '\?\? .*\.rej$' | cut -c4-)"
rejects="$(git status --porcelain | grep -F '??' | grep -F '.rej' | cut -c4-)"
if [ -n "$rejects" ]; then
warning "$1 partially applied with rejects"
for reject in $rejects; do
@ -93,7 +94,7 @@ fi
rm "$target.porig" # left by wiggle
done
else
warning "$patch failed to apply"
warning "$1 failed to apply"
fi
}
fi