From e87586088603c31fd285fc21010158a702f91bf5 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 11 Aug 2016 05:54:31 +0200 Subject: [PATCH] patchinstall.sh: Add support for eapply backend and mark epatch as deprecated (thanks NP-Hardass). --- README.md | 3 ++- patches/patchinstall.sh | 31 +++++++++++++++++-------------- staging/patchinstall.sh.in | 31 +++++++++++++++++-------------- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 273c35b2..6b4dc9ad 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,8 @@ Configuration: Backends: --backend=patch Use regular 'patch' utility to apply patches (default) - --backend=epatch Use 'epatch' to apply patches (Gentoo only) + --backend=eapply Use 'eapply' to apply patches (Gentoo only) + --backend=epatch Use 'epatch' to apply patches (Gentoo only, deprecated) --backend=git-am Use 'git am' to apply patches --backend=git-apply Use 'git apply' to apply patches --backend=stg Import the patches using stacked git diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 4d11a45d..b860e02d 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -41,7 +41,8 @@ usage() echo "" echo "Backends:" echo " --backend=patch Use regular 'patch' utility to apply patches (default)" - echo " --backend=epatch Use 'epatch' to apply patches (Gentoo only)" + echo " --backend=eapply Use 'eapply' to apply patches (Gentoo only)" + echo " --backend=epatch Use 'epatch' to apply patches (Gentoo only, deprecated)" echo " --backend=git-am Use 'git am' to apply patches" echo " --backend=git-apply Use 'git apply' to apply patches" echo " --backend=stg Import the patches using stacked git" @@ -1484,7 +1485,7 @@ elif test ! -f "$DESTDIR/tools/make_requests"; then abort "DESTDIR does not point to the Wine source tree." fi -# Change directory to DESTDIR, epatch depends on that +# Change directory to DESTDIR, eapply/epatch depends on that if ! cd "$DESTDIR"; then abort "Unable to change directory to $DESTDIR." fi @@ -1599,8 +1600,8 @@ if test "$backend" = "patch"; then fi } -# 'epatch' backend - used on Gentoo -elif test "$backend" = "epatch"; then +# 'eapply/epatch' backend - used on Gentoo +elif test "$backend" = "eapply" -o "$backend" = "epatch"; then if test "$workaround_git_bug" -eq 0; then gitapply_args="--nogit" @@ -1608,11 +1609,11 @@ elif test "$backend" = "epatch"; then gitapply_args="" fi - if ! command -v epatch >/dev/null 2>&1 || \ - ! command -v ebegin >/dev/null 2>&1 || \ - ! command -v eend >/dev/null 2>&1 || \ - ! command -v die >/dev/null 2>&1; then - abort "Shell functions epatch/ebegin/eend not found. You have to source this script from your ebuild." + if ! command -v "$backend" >/dev/null 2>&1 || \ + ! command -v ebegin >/dev/null 2>&1 || \ + ! command -v eend >/dev/null 2>&1 || \ + ! command -v nonfatal >/dev/null 2>&1; then + abort "Shell functions $backend/ebegin/eend/nonfatal not found. You have to source this script from your ebuild." fi if test "$enable_autoconf" -gt 1; then @@ -1625,13 +1626,15 @@ elif test "$backend" = "epatch"; then _shortname="$(basename "$1")" if grep -q "^GIT binary patch" "$1"; then ebegin "Applying $_shortname" - if ! "$patchdir/gitapply.sh" $gitapply_args < "$1"; then - die "Failed Patch: $1!" + "$patchdir/gitapply.sh" $gitapply_args < "$1" + if ! eend $?; then + exit 1 fi - eend - else - epatch "$1" # epatch calls die upon failure + # we are run from a subshell, so we can't call die + if ! nonfatal "$backend" "$1"; then + exit 1 + fi fi unset _shortname } diff --git a/staging/patchinstall.sh.in b/staging/patchinstall.sh.in index 527435bc..aac0d536 100644 --- a/staging/patchinstall.sh.in +++ b/staging/patchinstall.sh.in @@ -41,7 +41,8 @@ usage() echo "" echo "Backends:" echo " --backend=patch Use regular 'patch' utility to apply patches (default)" - echo " --backend=epatch Use 'epatch' to apply patches (Gentoo only)" + echo " --backend=eapply Use 'eapply' to apply patches (Gentoo only)" + echo " --backend=epatch Use 'epatch' to apply patches (Gentoo only, deprecated)" echo " --backend=git-am Use 'git am' to apply patches" echo " --backend=git-apply Use 'git apply' to apply patches" echo " --backend=stg Import the patches using stacked git" @@ -177,7 +178,7 @@ elif test ! -f "$DESTDIR/tools/make_requests"; then abort "DESTDIR does not point to the Wine source tree." fi -# Change directory to DESTDIR, epatch depends on that +# Change directory to DESTDIR, eapply/epatch depends on that if ! cd "$DESTDIR"; then abort "Unable to change directory to $DESTDIR." fi @@ -292,8 +293,8 @@ if test "$backend" = "patch"; then fi }} -# 'epatch' backend - used on Gentoo -elif test "$backend" = "epatch"; then +# 'eapply/epatch' backend - used on Gentoo +elif test "$backend" = "eapply" -o "$backend" = "epatch"; then if test "$workaround_git_bug" -eq 0; then gitapply_args="--nogit" @@ -301,11 +302,11 @@ elif test "$backend" = "epatch"; then gitapply_args="" fi - if ! command -v epatch >/dev/null 2>&1 || \ - ! command -v ebegin >/dev/null 2>&1 || \ - ! command -v eend >/dev/null 2>&1 || \ - ! command -v die >/dev/null 2>&1; then - abort "Shell functions epatch/ebegin/eend not found. You have to source this script from your ebuild." + if ! command -v "$backend" >/dev/null 2>&1 || \ + ! command -v ebegin >/dev/null 2>&1 || \ + ! command -v eend >/dev/null 2>&1 || \ + ! command -v nonfatal >/dev/null 2>&1; then + abort "Shell functions $backend/ebegin/eend/nonfatal not found. You have to source this script from your ebuild." fi if test "$enable_autoconf" -gt 1; then @@ -318,13 +319,15 @@ elif test "$backend" = "epatch"; then _shortname="$(basename "$1")" if grep -q "^GIT binary patch" "$1"; then ebegin "Applying $_shortname" - if ! "$patchdir/gitapply.sh" $gitapply_args < "$1"; then - die "Failed Patch: $1!" + "$patchdir/gitapply.sh" $gitapply_args < "$1" + if ! eend $?; then + exit 1 fi - eend - else - epatch "$1" # epatch calls die upon failure + # we are run from a subshell, so we can't call die + if ! nonfatal "$backend" "$1"; then + exit 1 + fi fi unset _shortname }}