apatch/apatch

41 lines
875 B
Bash
Executable file

#!/bin/sh
cleanup() {
rm -rf src-old
}
trap 'cleanup' EXIT INT HUP
startdir="$PWD"
[ -f APKBUILD ] || ( echo "please run this in a package directory"; exit 1 )
[ "$1" != "" ] || ( echo "usage: apatch <patch name>"; exit 1 )
abuild clean fetch unpack prepare || exit 1
# obtain builddir
. APKBUILD
[ -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"
$SHELL
)
busybox diff -N -U3 -r "src-old$builddir" "src$builddir" | sed "s|src-old$builddir|a|g;s|src$builddir|b|g" > $1