From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] epatch: splitting out common options from user-specific ones
Date: Thu, 19 Apr 2012 23:24:19 -0400 [thread overview]
Message-ID: <201204192324.20395.vapier@gentoo.org> (raw)
In-Reply-To: <201204181403.07937.vapier@gentoo.org>
[-- Attachment #1: Type: Text/Plain, Size: 3678 bytes --]
no complaints, so here's the patch. precedence order is EPATCH_COMMON_OPTS
then EPATCH_OPTS then whatever has been specified on the cmdline.
so you can do:
EPATCH_OPTS="-F0"
epatch <all these patches will use -F0>
epatch -p0 <patches will use -p0 and -F0>
epatch <all these patches will use -F0>
(more for highlighting precedence than a realistic use case)
-mike
--- eutils.eclass
+++ eutils.eclass
@@ -230,13 +230,21 @@
EPATCH_SUFFIX="patch.bz2"
# @VARIABLE: EPATCH_OPTS
# @DESCRIPTION:
-# Default options for patch:
+# Options to pass to patch. Meant for ebuild/package-specific tweaking
+# such as forcing the patch level (-p#) or fuzz (-F#) factor. Note that
+# for single patch tweaking, you can also pass flags directly to epatch.
+EPATCH_OPTS=""
+# @VARIABLE: EPATCH_COMMON_OPTS
+# @DESCRIPTION:
+# Common options to pass to `patch`. You probably should never need to
+# change these. If you do, please discuss it with base-system first to
+# be sure.
# @CODE
# -g0 - keep RCS, ClearCase, Perforce and SCCS happy #24571
# --no-backup-if-mismatch - do not leave .orig files behind
# -E - automatically remove empty files
# @CODE
-EPATCH_OPTS="-g0 -E --no-backup-if-mismatch"
+EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
# @VARIABLE: EPATCH_EXCLUDE
# @DESCRIPTION:
# List of patches not to apply. Note this is only file names,
@@ -257,7 +265,7 @@ EPATCH_MULTI_MSG="Applying various patch
EPATCH_FORCE="no"
# @FUNCTION: epatch
-# @USAGE: [patches] [dirs of patches]
+# @USAGE: [options] [patches] [dirs of patches]
# @DESCRIPTION:
# epatch is designed to greatly simplify the application of patches. It can
# process patch files directly, or directories of patches. The patches may be
@@ -265,8 +273,12 @@ EPATCH_FORCE="no"
# the -p option as epatch will automatically attempt -p0 to -p5 until things
# apply successfully.
#
-# If you do not specify any options, then epatch will default to the directory
-# specified by EPATCH_SOURCE.
+# If you do not specify any patches/dirs, then epatch will default to the
+# directory specified by EPATCH_SOURCE.
+#
+# Any options specified that start with a dash will be passed down to patch
+# for this specific invocation. As soon as an arg w/out a dash is found, then
+# arg processing stops.
#
# When processing directories, epatch will apply all patches that match:
# @CODE
@@ -294,6 +306,18 @@ epatch() {
unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402
+ # First process options. We localize the EPATCH_OPTS setting
+ # from above so that we can pass it on in the loop below with
+ # any additional values the user has specified.
+ local EPATCH_OPTS=( ${EPATCH_OPTS[*]} )
+ while [[ $# -gt 0 ]] ; do
+ case $1 in
+ -*) EPATCH_OPTS+=( "$1" ) ;;
+ *) break ;;
+ esac
+ shift
+ done
+
# Let the rest of the code process one user arg at a time --
# each arg may expand into multiple patches, and each arg may
# need to start off with the default global EPATCH_xxx values
@@ -305,6 +329,10 @@ epatch() {
return 0
fi
+ # Now that we know we're actually going to apply something, merge
+ # all of the patch options back in to a single variable for below.
+ EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}"
+
local SINGLE_PATCH="no"
# no args means process ${EPATCH_SOURCE}
[[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}"
@@ -445,6 +473,7 @@ epatch() {
local patch_cmd
while [[ ${count} -lt 5 ]] ; do
patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}"
+einfo $patch_cmd
# Generate some useful debug info ...
(
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-04-20 3:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-18 18:03 [gentoo-dev] epatch: splitting out common options from user-specific ones Mike Frysinger
2012-04-20 3:24 ` Mike Frysinger [this message]
2012-04-20 3:38 ` Mike Frysinger
[not found] <iRHui-2kD-3@gated-at.bofh.it>
2012-04-20 19:38 ` Leho Kraav
2012-04-20 19:54 ` Leho Kraav
2012-04-20 19:59 ` Mike Frysinger
2012-04-20 20:06 ` Leho Kraav
2012-04-20 21:40 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201204192324.20395.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox