From 131c15e715226910833fb90e56ba2fd1f490a30e Mon Sep 17 00:00:00 2001 From: psykose Date: Fri, 29 Apr 2022 06:49:13 +0000 Subject: [PATCH] feat: improve patch updating --- apatch | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apatch b/apatch index e8b8584..39720b9 100755 --- a/apatch +++ b/apatch @@ -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 "; 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