diff --git a/apatch b/apatch old mode 100644 new mode 100755 index 342ad5d..e8b8584 --- a/apatch +++ b/apatch @@ -1,7 +1,10 @@ #!/bin/sh +startdir="$PWD" +patch_exists=0 + [ -f APKBUILD ] || ( echo "please run this in a package directory"; exit 1 ) -[ ! -f "$1" ] || ( echo "patch $1 already exists"; exit 1 ) +[ -f "$1" ] && patch_exists=1 [ "$1" != "" ] || ( echo "usage: apatch "; exit 1 ) abuild clean fetch unpack prepare @@ -13,6 +16,7 @@ abuild clean fetch unpack prepare cp -r src src-old ( 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