1 |
no complaints, so here's the patch. precedence order is EPATCH_COMMON_OPTS |
2 |
then EPATCH_OPTS then whatever has been specified on the cmdline. |
3 |
|
4 |
so you can do: |
5 |
EPATCH_OPTS="-F0" |
6 |
epatch <all these patches will use -F0> |
7 |
epatch -p0 <patches will use -p0 and -F0> |
8 |
epatch <all these patches will use -F0> |
9 |
(more for highlighting precedence than a realistic use case) |
10 |
-mike |
11 |
|
12 |
--- eutils.eclass |
13 |
+++ eutils.eclass |
14 |
@@ -230,13 +230,21 @@ |
15 |
EPATCH_SUFFIX="patch.bz2" |
16 |
# @VARIABLE: EPATCH_OPTS |
17 |
# @DESCRIPTION: |
18 |
-# Default options for patch: |
19 |
+# Options to pass to patch. Meant for ebuild/package-specific tweaking |
20 |
+# such as forcing the patch level (-p#) or fuzz (-F#) factor. Note that |
21 |
+# for single patch tweaking, you can also pass flags directly to epatch. |
22 |
+EPATCH_OPTS="" |
23 |
+# @VARIABLE: EPATCH_COMMON_OPTS |
24 |
+# @DESCRIPTION: |
25 |
+# Common options to pass to `patch`. You probably should never need to |
26 |
+# change these. If you do, please discuss it with base-system first to |
27 |
+# be sure. |
28 |
# @CODE |
29 |
# -g0 - keep RCS, ClearCase, Perforce and SCCS happy #24571 |
30 |
# --no-backup-if-mismatch - do not leave .orig files behind |
31 |
# -E - automatically remove empty files |
32 |
# @CODE |
33 |
-EPATCH_OPTS="-g0 -E --no-backup-if-mismatch" |
34 |
+EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch" |
35 |
# @VARIABLE: EPATCH_EXCLUDE |
36 |
# @DESCRIPTION: |
37 |
# List of patches not to apply. Note this is only file names, |
38 |
@@ -257,7 +265,7 @@ EPATCH_MULTI_MSG="Applying various patch |
39 |
EPATCH_FORCE="no" |
40 |
|
41 |
# @FUNCTION: epatch |
42 |
-# @USAGE: [patches] [dirs of patches] |
43 |
+# @USAGE: [options] [patches] [dirs of patches] |
44 |
# @DESCRIPTION: |
45 |
# epatch is designed to greatly simplify the application of patches. It can |
46 |
# process patch files directly, or directories of patches. The patches may be |
47 |
@@ -265,8 +273,12 @@ EPATCH_FORCE="no" |
48 |
# the -p option as epatch will automatically attempt -p0 to -p5 until things |
49 |
# apply successfully. |
50 |
# |
51 |
-# If you do not specify any options, then epatch will default to the directory |
52 |
-# specified by EPATCH_SOURCE. |
53 |
+# If you do not specify any patches/dirs, then epatch will default to the |
54 |
+# directory specified by EPATCH_SOURCE. |
55 |
+# |
56 |
+# Any options specified that start with a dash will be passed down to patch |
57 |
+# for this specific invocation. As soon as an arg w/out a dash is found, then |
58 |
+# arg processing stops. |
59 |
# |
60 |
# When processing directories, epatch will apply all patches that match: |
61 |
# @CODE |
62 |
@@ -294,6 +306,18 @@ epatch() { |
63 |
|
64 |
unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402 |
65 |
|
66 |
+ # First process options. We localize the EPATCH_OPTS setting |
67 |
+ # from above so that we can pass it on in the loop below with |
68 |
+ # any additional values the user has specified. |
69 |
+ local EPATCH_OPTS=( ${EPATCH_OPTS[*]} ) |
70 |
+ while [[ $# -gt 0 ]] ; do |
71 |
+ case $1 in |
72 |
+ -*) EPATCH_OPTS+=( "$1" ) ;; |
73 |
+ *) break ;; |
74 |
+ esac |
75 |
+ shift |
76 |
+ done |
77 |
+ |
78 |
# Let the rest of the code process one user arg at a time -- |
79 |
# each arg may expand into multiple patches, and each arg may |
80 |
# need to start off with the default global EPATCH_xxx values |
81 |
@@ -305,6 +329,10 @@ epatch() { |
82 |
return 0 |
83 |
fi |
84 |
|
85 |
+ # Now that we know we're actually going to apply something, merge |
86 |
+ # all of the patch options back in to a single variable for below. |
87 |
+ EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}" |
88 |
+ |
89 |
local SINGLE_PATCH="no" |
90 |
# no args means process ${EPATCH_SOURCE} |
91 |
[[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}" |
92 |
@@ -445,6 +473,7 @@ epatch() { |
93 |
local patch_cmd |
94 |
while [[ ${count} -lt 5 ]] ; do |
95 |
patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}" |
96 |
+einfo $patch_cmd |
97 |
|
98 |
# Generate some useful debug info ... |
99 |
( |