| 1 | # Copyright 1999-2012 Gentoo Foundation |
1 | # Copyright 1999-2012 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.390 2012/04/16 14:40:16 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.391 2012/04/20 19:35:37 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: eutils.eclass |
5 | # @ECLASS: eutils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # base-system@gentoo.org |
7 | # base-system@gentoo.org |
| 8 | # @BLURB: many extra (but common) functions that are used in ebuilds |
8 | # @BLURB: many extra (but common) functions that are used in ebuilds |
| … | |
… | |
| 228 | # @DESCRIPTION: |
228 | # @DESCRIPTION: |
| 229 | # Default extension for patches (do not prefix the period yourself). |
229 | # Default extension for patches (do not prefix the period yourself). |
| 230 | EPATCH_SUFFIX="patch.bz2" |
230 | EPATCH_SUFFIX="patch.bz2" |
| 231 | # @VARIABLE: EPATCH_OPTS |
231 | # @VARIABLE: EPATCH_OPTS |
| 232 | # @DESCRIPTION: |
232 | # @DESCRIPTION: |
| 233 | # Default options for patch: |
233 | # Options to pass to patch. Meant for ebuild/package-specific tweaking |
|
|
234 | # such as forcing the patch level (-p#) or fuzz (-F#) factor. Note that |
|
|
235 | # for single patch tweaking, you can also pass flags directly to epatch. |
|
|
236 | EPATCH_OPTS="" |
|
|
237 | # @VARIABLE: EPATCH_COMMON_OPTS |
|
|
238 | # @DESCRIPTION: |
|
|
239 | # Common options to pass to `patch`. You probably should never need to |
|
|
240 | # change these. If you do, please discuss it with base-system first to |
|
|
241 | # be sure. |
| 234 | # @CODE |
242 | # @CODE |
| 235 | # -g0 - keep RCS, ClearCase, Perforce and SCCS happy #24571 |
243 | # -g0 - keep RCS, ClearCase, Perforce and SCCS happy #24571 |
| 236 | # --no-backup-if-mismatch - do not leave .orig files behind |
244 | # --no-backup-if-mismatch - do not leave .orig files behind |
| 237 | # -E - automatically remove empty files |
245 | # -E - automatically remove empty files |
| 238 | # @CODE |
246 | # @CODE |
| 239 | EPATCH_OPTS="-g0 -E --no-backup-if-mismatch" |
247 | EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch" |
| 240 | # @VARIABLE: EPATCH_EXCLUDE |
248 | # @VARIABLE: EPATCH_EXCLUDE |
| 241 | # @DESCRIPTION: |
249 | # @DESCRIPTION: |
| 242 | # List of patches not to apply. Note this is only file names, |
250 | # List of patches not to apply. Note this is only file names, |
| 243 | # and not the full path. Globs accepted. |
251 | # and not the full path. Globs accepted. |
| 244 | EPATCH_EXCLUDE="" |
252 | EPATCH_EXCLUDE="" |
| … | |
… | |
| 255 | # Only require patches to match EPATCH_SUFFIX rather than the extended |
263 | # Only require patches to match EPATCH_SUFFIX rather than the extended |
| 256 | # arch naming style. |
264 | # arch naming style. |
| 257 | EPATCH_FORCE="no" |
265 | EPATCH_FORCE="no" |
| 258 | |
266 | |
| 259 | # @FUNCTION: epatch |
267 | # @FUNCTION: epatch |
| 260 | # @USAGE: [patches] [dirs of patches] |
268 | # @USAGE: [options] [patches] [dirs of patches] |
| 261 | # @DESCRIPTION: |
269 | # @DESCRIPTION: |
| 262 | # epatch is designed to greatly simplify the application of patches. It can |
270 | # epatch is designed to greatly simplify the application of patches. It can |
| 263 | # process patch files directly, or directories of patches. The patches may be |
271 | # process patch files directly, or directories of patches. The patches may be |
| 264 | # compressed (bzip/gzip/etc...) or plain text. You generally need not specify |
272 | # compressed (bzip/gzip/etc...) or plain text. You generally need not specify |
| 265 | # the -p option as epatch will automatically attempt -p0 to -p5 until things |
273 | # the -p option as epatch will automatically attempt -p0 to -p5 until things |
| 266 | # apply successfully. |
274 | # apply successfully. |
| 267 | # |
275 | # |
| 268 | # If you do not specify any options, then epatch will default to the directory |
276 | # If you do not specify any patches/dirs, then epatch will default to the |
| 269 | # specified by EPATCH_SOURCE. |
277 | # directory specified by EPATCH_SOURCE. |
|
|
278 | # |
|
|
279 | # Any options specified that start with a dash will be passed down to patch |
|
|
280 | # for this specific invocation. As soon as an arg w/out a dash is found, then |
|
|
281 | # arg processing stops. |
| 270 | # |
282 | # |
| 271 | # When processing directories, epatch will apply all patches that match: |
283 | # When processing directories, epatch will apply all patches that match: |
| 272 | # @CODE |
284 | # @CODE |
| 273 | # if ${EPATCH_FORCE} != "yes" |
285 | # if ${EPATCH_FORCE} != "yes" |
| 274 | # ??_${ARCH}_foo.${EPATCH_SUFFIX} |
286 | # ??_${ARCH}_foo.${EPATCH_SUFFIX} |
| … | |
… | |
| 292 | echo "${1//?/=}" |
304 | echo "${1//?/=}" |
| 293 | } |
305 | } |
| 294 | |
306 | |
| 295 | unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402 |
307 | unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402 |
| 296 | |
308 | |
|
|
309 | # First process options. We localize the EPATCH_OPTS setting |
|
|
310 | # from above so that we can pass it on in the loop below with |
|
|
311 | # any additional values the user has specified. |
|
|
312 | local EPATCH_OPTS=( ${EPATCH_OPTS[*]} ) |
|
|
313 | while [[ $# -gt 0 ]] ; do |
|
|
314 | case $1 in |
|
|
315 | -*) EPATCH_OPTS+=( "$1" ) ;; |
|
|
316 | *) break ;; |
|
|
317 | esac |
|
|
318 | shift |
|
|
319 | done |
|
|
320 | |
| 297 | # Let the rest of the code process one user arg at a time -- |
321 | # Let the rest of the code process one user arg at a time -- |
| 298 | # each arg may expand into multiple patches, and each arg may |
322 | # each arg may expand into multiple patches, and each arg may |
| 299 | # need to start off with the default global EPATCH_xxx values |
323 | # need to start off with the default global EPATCH_xxx values |
| 300 | if [[ $# -gt 1 ]] ; then |
324 | if [[ $# -gt 1 ]] ; then |
| 301 | local m |
325 | local m |
| … | |
… | |
| 334 | eerror " ${EPATCH_SOURCE}" |
358 | eerror " ${EPATCH_SOURCE}" |
| 335 | eerror " ( ${EPATCH_SOURCE##*/} )" |
359 | eerror " ( ${EPATCH_SOURCE##*/} )" |
| 336 | echo |
360 | echo |
| 337 | die "Cannot find \$EPATCH_SOURCE!" |
361 | die "Cannot find \$EPATCH_SOURCE!" |
| 338 | fi |
362 | fi |
|
|
363 | |
|
|
364 | # Now that we know we're actually going to apply something, merge |
|
|
365 | # all of the patch options back in to a single variable for below. |
|
|
366 | EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}" |
| 339 | |
367 | |
| 340 | local PIPE_CMD |
368 | local PIPE_CMD |
| 341 | case ${EPATCH_SUFFIX##*\.} in |
369 | case ${EPATCH_SUFFIX##*\.} in |
| 342 | xz) PIPE_CMD="xz -dc" ;; |
370 | xz) PIPE_CMD="xz -dc" ;; |
| 343 | lzma) PIPE_CMD="lzma -dc" ;; |
371 | lzma) PIPE_CMD="lzma -dc" ;; |