FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 04-18-2012, 06:03 PM
Mike Frysinger
 
Default epatch: splitting out common options from user-specific ones

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
 
Old 04-20-2012, 03:24 AM
Mike Frysinger
 
Default epatch: splitting out common options from user-specific ones

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 ...
(
 
Old 04-20-2012, 03:38 AM
Mike Frysinger
 
Default epatch: splitting out common options from user-specific ones

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
 
Old 04-20-2012, 07:38 PM
Leho Kraav
 
Default epatch: splitting out common options from user-specific ones

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".
 
Old 04-20-2012, 07:54 PM
Leho Kraav
 
Default epatch: splitting out common options from user-specific ones

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.
 
Old 04-20-2012, 07:59 PM
Mike Frysinger
 
Default epatch: splitting out common options from user-specific ones

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
 
Old 04-20-2012, 08:06 PM
Leho Kraav
 
Default epatch: splitting out common options from user-specific ones

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?
 
Old 04-20-2012, 09:40 PM
Mike Frysinger
 
Default epatch: splitting out common options from user-specific ones

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
 

Thread Tools




All times are GMT. The time now is 07:24 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org