From aefd1dd647fea16a418497e8370dffdf5a2c71ef Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 9 Jul 2024 14:35:49 +0200 Subject: addPkgbuildPatch: can now also remove patches --- addPkgbuildPatch | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'addPkgbuildPatch') 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 -- cgit v1.2.3-70-g09d2