feat: improve patch updating

This commit is contained in:
psykose 2022-04-29 06:49:13 +00:00
parent a065129fdb
commit 131c15e715
Signed by: psykose
SSH key fingerprint: SHA256:HwlGVJNLZqHoOvMtkshyGaXLkcdbEJahYMlepHFL+Uk

18
apatch
View file

@ -1,10 +1,8 @@
#!/bin/sh
startdir="$PWD"
patch_exists=0
[ -f APKBUILD ] || ( echo "please run this in a package directory"; exit 1 )
[ -f "$1" ] && patch_exists=1
[ "$1" != "" ] || ( echo "usage: apatch <patch name>"; exit 1 )
abuild clean fetch unpack prepare
@ -14,10 +12,24 @@ abuild clean fetch unpack prepare
[ -z "$builddir" ] && builddir="/$pkgname-$pkgver"
cp -r src src-old
for patch in $source; do
if [ "$patch" = "$1" ]; then
# if the patch was in source, it was already applied in prepare() above,
# but we want the original src to not have it, so we can get a full diff of
# its original changes + our new ones
(
cd "src-old/$builddir"
patch -R -p1 < "$startdir/$1"
)
break
fi
done
(
cd "src$builddir"
[ "$patch_exists" -eq 1 ] && patch -p1 < "$startdir/$1"
$SHELL
)
busybox diff -U3 -r "src-old$builddir" "src$builddir" | sed "s|src-old$builddir|a|g;s|src$builddir|b|g" > $1
rm -rf src-old