* [gentoo-dev] epatch: splitting out common options from user-specific ones
@ 2012-04-18 18:03 Mike Frysinger
2012-04-20 3:24 ` Mike Frysinger
0 siblings, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2012-04-18 18:03 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 861 bytes --]
it isn't uncommon for people to want to force the patch (-p#) or fuzz (-f#)
level when applying specific patches. but it is unusual that they want to kill
off the extra options: -g0 -E --no-backup-if-mismatch. so i'd like to split
these off and improve the epatch API.
# Extra options to pass to `patch` (such as -p1).
EPATCH_OPTS=""
# Common options to pass to `patch` (you probably shouldn't need
# to change these at all).
EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
and then i'll try to extend `epatch` so the first set of arguments can
implicitly set EPATCH_OPTS for that one patch:
epatch -p1 "${FILESDIR}"/${P}-foo.patch
this is much nicer than the current:
EPATCH_OPTS="-p1" epatch "${FILESDIR}"/${P}-foo.patch
i can't see this causing any issues, but considering everyone uses `epatch`,
best to ask first.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] epatch: splitting out common options from user-specific ones
2012-04-18 18:03 Mike Frysinger
@ 2012-04-20 3:24 ` Mike Frysinger
2012-04-20 3:38 ` Mike Frysinger
0 siblings, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2012-04-20 3:24 UTC (permalink / raw
To: gentoo-dev
[-- 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 --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] epatch: splitting out common options from user-specific ones
2012-04-20 3:24 ` Mike Frysinger
@ 2012-04-20 3:38 ` Mike Frysinger
0 siblings, 0 replies; 8+ messages in thread
From: Mike Frysinger @ 2012-04-20 3:38 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: Text/Plain, Size: 338 bytes --]
On Thursday 19 April 2012 23:24:19 Mike Frysinger wrote:
> @@ -445,6 +473,7 @@ epatch() {
> local patch_cmd
> while [[ ${count} -lt 5 ]] ; do
> patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count}
> +einfo $patch_cmd
>
> # Generate some useful debug info ...
> (
err, meant to delete that debug line
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] epatch: splitting out common options from user-specific ones
[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
0 siblings, 2 replies; 8+ messages in thread
From: Leho Kraav @ 2012-04-20 19:38 UTC (permalink / raw
To: linux.gentoo.dev; +Cc: gentoo-dev
On Wednesday, April 18, 2012 9:10:02 PM UTC+3, Mike Frysinger wrote:
> it isn't uncommon for people to want to force the patch (-p#) or fuzz (-f#)
> level when applying specific patches. but it is unusual that they want to kill
> off the extra options: -g0 -E --no-backup-if-mismatch. so i'd like to split
> these off and improve the epatch API.
LOL mike, i'm fighting with this thing at the very moment. there's a patch i received that has whitespace issues and i'd like to specify custom EPATCH_OPTS.
i applied the patch to my eclass overlay, and einfo is showing that the new eclass is used.
$ EPATCH_OPTS="--ignore-whitespace" emerge -va pf-sources
isn't achieved though. do you mean "cmdline" as in only within ebuild? what's the optimal way here? i was desperately searching for PATCHCOMMAND in "man make.conf".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] epatch: splitting out common options from user-specific ones
2012-04-20 19:38 ` [gentoo-dev] epatch: splitting out common options from user-specific ones Leho Kraav
@ 2012-04-20 19:54 ` Leho Kraav
2012-04-20 19:59 ` Mike Frysinger
1 sibling, 0 replies; 8+ messages in thread
From: Leho Kraav @ 2012-04-20 19:54 UTC (permalink / raw
To: gentoo-dev
On Wednesday, April 18, 2012 9:10:02 PM UTC+3, Mike Frysinger wrote:
> it isn't uncommon for people to want to force the patch (-p#) or fuzz (-f#)
> level when applying specific patches. but it is unusual that they want to kill
> off the extra options: -g0 -E --no-backup-if-mismatch. so i'd like to split
> these off and improve the epatch API.
LOL mike, i'm fighting with this thing at the very moment. there's a
patch i received that has whitespace issues and i'd like to specify
custom EPATCH_OPTS.
i applied the patch to my eclass overlay, and einfo is showing that the
new eclass is used.
$ EPATCH_OPTS="--ignore-whitespace" emerge -va pf-sources
isn't achieved though. if i do:
236 EPATCH_OPTS="${EPATCH_OPTS}"
everything works as expected. do you mean "cmdline" as in only within
ebuild? what's the optimal way here? i was desperately searching for
PATCHCOMMAND in "man make.conf", but this definitely would do the job
for me.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] epatch: splitting out common options from user-specific ones
2012-04-20 19:38 ` [gentoo-dev] epatch: splitting out common options from user-specific ones Leho Kraav
2012-04-20 19:54 ` Leho Kraav
@ 2012-04-20 19:59 ` Mike Frysinger
2012-04-20 20:06 ` Leho Kraav
1 sibling, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2012-04-20 19:59 UTC (permalink / raw
To: gentoo-dev; +Cc: Leho Kraav
[-- Attachment #1: Type: Text/Plain, Size: 903 bytes --]
On Friday 20 April 2012 15:38:19 Leho Kraav wrote:
> On Wednesday, April 18, 2012 9:10:02 PM UTC+3, Mike Frysinger wrote:
> > it isn't uncommon for people to want to force the patch (-p#) or fuzz
> > (-f#) level when applying specific patches. but it is unusual that they
> > want to kill off the extra options: -g0 -E --no-backup-if-mismatch. so
> > i'd like to split these off and improve the epatch API.
>
> LOL mike, i'm fighting with this thing at the very moment. there's a patch
> i received that has whitespace issues and i'd like to specify custom
> EPATCH_OPTS.
>
> i applied the patch to my eclass overlay, and einfo is showing that the new
> eclass is used.
i just committed it since no one responded. so sync up.
> $ EPATCH_OPTS="--ignore-whitespace" emerge -va pf-sources
that's not the intention. EPATCH_OPTS modification should be inside the
ebuild.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] epatch: splitting out common options from user-specific ones
2012-04-20 19:59 ` Mike Frysinger
@ 2012-04-20 20:06 ` Leho Kraav
2012-04-20 21:40 ` Mike Frysinger
0 siblings, 1 reply; 8+ messages in thread
From: Leho Kraav @ 2012-04-20 20:06 UTC (permalink / raw
To: Mike Frysinger; +Cc: gentoo-dev
On 20.04.2012 22:59, Mike Frysinger wrote:
> i just committed it since no one responded. so sync up.
>
>> $ EPATCH_OPTS="--ignore-whitespace" emerge -va pf-sources
>
> that's not the intention. EPATCH_OPTS modification should be inside the
> ebuild.
I can't see how having this available could hurt anything. Am I blind?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] epatch: splitting out common options from user-specific ones
2012-04-20 20:06 ` Leho Kraav
@ 2012-04-20 21:40 ` Mike Frysinger
0 siblings, 0 replies; 8+ messages in thread
From: Mike Frysinger @ 2012-04-20 21:40 UTC (permalink / raw
To: Leho Kraav; +Cc: gentoo-dev
[-- Attachment #1: Type: Text/Plain, Size: 569 bytes --]
On Friday 20 April 2012 16:06:02 Leho Kraav wrote:
> On 20.04.2012 22:59, Mike Frysinger wrote:
> > i just committed it since no one responded. so sync up.
> >
> >> $ EPATCH_OPTS="--ignore-whitespace" emerge -va pf-sources
> >
> > that's not the intention. EPATCH_OPTS modification should be inside the
> > ebuild.
>
> I can't see how having this available could hurt anything. Am I blind?
i could remove EPATCH_OPTS="" from the eclass, but you'd get inconsistent
behavior. many ebuilds atm set that, so you wouldn't be able to override it.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-04-20 21:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <iRHui-2kD-3@gated-at.bofh.it>
2012-04-20 19:38 ` [gentoo-dev] epatch: splitting out common options from user-specific ones 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
2012-04-18 18:03 Mike Frysinger
2012-04-20 3:24 ` Mike Frysinger
2012-04-20 3:38 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox