summaryrefslogtreecommitdiff
path: root/addPkgbuildPatch
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2024-07-09 14:35:49 +0200
committerErich Eckner <git@eckner.net>2024-07-09 14:35:49 +0200
commitaefd1dd647fea16a418497e8370dffdf5a2c71ef (patch)
tree1309cce97a4be0409ce5fe7785747acd877df547 /addPkgbuildPatch
parent1ce958e91ea06e47e907c9770cc04ebb40806cb9 (diff)
downloadarchlinuxewe-aefd1dd647fea16a418497e8370dffdf5a2c71ef.tar.xz
addPkgbuildPatch: can now also remove patches
Diffstat (limited to 'addPkgbuildPatch')
-rwxr-xr-xaddPkgbuildPatch28
1 files changed, 27 insertions, 1 deletions
diff --git a/addPkgbuildPatch b/addPkgbuildPatch
index 247879398..07c4fce74 100755
--- a/addPkgbuildPatch
+++ b/addPkgbuildPatch
@@ -2,7 +2,23 @@
tmpDir=$(dirname "$(readlink -e "$0")")
-if ! grep -qwF _patch_PKGBUILD PKGBUILD; then
+usage() {
+ >&2 printf 'usage:\n'
+ >&2 printf ' %s add|del\n' "$0"
+ >&2 printf 'To be called next to the to be patched PKGBUILD.\n'
+ exit 1
+}
+
+if [ $# -ne 1 ] || [ ! -f 'PKGBUILD' ]; then
+ usage
+fi
+
+if [ "$1" != 'add' ] && [ "$1" != 'del' ]; then
+ usage
+fi
+
+if [ "$1" = 'add' ] \
+&& ! grep -qwF _patch_PKGBUILD PKGBUILD; then
# add PKGBUILD-patches to the PKGBUILD
if grep -q '^\s*pkgbase=' PKGBUILD; then
@@ -39,3 +55,13 @@ if ! grep -qwF _patch_PKGBUILD PKGBUILD; then
} \
>> PKGBUILD
fi
+
+if [ "$1" = 'del' ] \
+&& grep -qwF _patch_PKGBUILD PKGBUILD; then
+
+ # del PKGBUILD-patches from the PKGBUILD
+ sed -i '
+ /^_patch_PKGBUILD$/d
+ /^_patch_PKGBUILD() {$/,/^}/d
+ ' PKGBUILD
+fi