1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2011 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.354 2011/02/25 21:58:19 ulm Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.363 2011/09/12 20:44:01 mgorny 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 |
… | |
… | |
64 | fi |
64 | fi |
65 | |
65 | |
66 | # @FUNCTION: eqawarn |
66 | # @FUNCTION: eqawarn |
67 | # @USAGE: [message] |
67 | # @USAGE: [message] |
68 | # @DESCRIPTION: |
68 | # @DESCRIPTION: |
69 | # Proxy to einfo for package managers that don't provide eqawarn and use the PM |
69 | # Proxy to ewarn for package managers that don't provide eqawarn and use the PM |
70 | # implementation if available. |
70 | # implementation if available. Reuses PORTAGE_ELOG_CLASSES as set by the dev |
|
|
71 | # profile. |
71 | if ! declare -F eqawarn >/dev/null ; then |
72 | if ! declare -F eqawarn >/dev/null ; then |
72 | eqawarn() { |
73 | eqawarn() { |
73 | einfo "$@" |
74 | has qa ${PORTAGE_ELOG_CLASSES} && ewarn "$@" |
74 | } |
75 | } |
75 | fi |
76 | fi |
76 | |
77 | |
77 | # @FUNCTION: ecvs_clean |
78 | # @FUNCTION: ecvs_clean |
78 | # @USAGE: [list of dirs] |
79 | # @USAGE: [list of dirs] |
… | |
… | |
250 | |
251 | |
251 | elif [[ -d $1 ]] ; then |
252 | elif [[ -d $1 ]] ; then |
252 | # Some people like to make dirs of patches w/out suffixes (vim) |
253 | # Some people like to make dirs of patches w/out suffixes (vim) |
253 | set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"} |
254 | set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"} |
254 | |
255 | |
|
|
256 | elif [[ -f ${EPATCH_SOURCE}/$1 ]] ; then |
|
|
257 | # Re-use EPATCH_SOURCE as a search dir |
|
|
258 | epatch "${EPATCH_SOURCE}/$1" |
|
|
259 | return $? |
|
|
260 | |
255 | else |
261 | else |
256 | # sanity check ... if it isn't a dir or file, wtf man ? |
262 | # sanity check ... if it isn't a dir or file, wtf man ? |
257 | [[ $# -ne 0 ]] && EPATCH_SOURCE=$1 |
263 | [[ $# -ne 0 ]] && EPATCH_SOURCE=$1 |
258 | echo |
264 | echo |
259 | eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:" |
265 | eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:" |
… | |
… | |
375 | _epatch_draw_line "***** ${patchname} *****" |
381 | _epatch_draw_line "***** ${patchname} *****" |
376 | echo |
382 | echo |
377 | echo "PATCH COMMAND: patch -p${count} ${EPATCH_OPTS} < '${PATCH_TARGET}'" |
383 | echo "PATCH COMMAND: patch -p${count} ${EPATCH_OPTS} < '${PATCH_TARGET}'" |
378 | echo |
384 | echo |
379 | _epatch_draw_line "***** ${patchname} *****" |
385 | _epatch_draw_line "***** ${patchname} *****" |
|
|
386 | patch -p${count} ${EPATCH_OPTS} --dry-run -f < "${PATCH_TARGET}" 2>&1 |
|
|
387 | ret=$? |
|
|
388 | echo |
|
|
389 | echo "patch program exited with status ${ret}" |
|
|
390 | exit ${ret} |
380 | ) >> "${STDERR_TARGET}" |
391 | ) >> "${STDERR_TARGET}" |
381 | |
392 | |
382 | if (patch -p${count} ${EPATCH_OPTS} --dry-run -f < "${PATCH_TARGET}") >> "${STDERR_TARGET}" 2>&1 ; then |
393 | if [ $? -eq 0 ] ; then |
383 | ( |
394 | ( |
384 | _epatch_draw_line "***** ${patchname} *****" |
395 | _epatch_draw_line "***** ${patchname} *****" |
385 | echo |
396 | echo |
386 | echo "ACTUALLY APPLYING ${patchname} ..." |
397 | echo "ACTUALLY APPLYING ${patchname} ..." |
387 | echo |
398 | echo |
388 | _epatch_draw_line "***** ${patchname} *****" |
399 | _epatch_draw_line "***** ${patchname} *****" |
389 | patch -p${count} ${EPATCH_OPTS} < "${PATCH_TARGET}" 2>&1 |
400 | patch -p${count} ${EPATCH_OPTS} < "${PATCH_TARGET}" 2>&1 |
|
|
401 | ret=$? |
|
|
402 | echo |
|
|
403 | echo "patch program exited with status ${ret}" |
|
|
404 | exit ${ret} |
390 | ) >> "${STDERR_TARGET}" |
405 | ) >> "${STDERR_TARGET}" |
391 | |
406 | |
392 | if [ $? -ne 0 ] ; then |
407 | if [ $? -ne 0 ] ; then |
393 | echo |
408 | echo |
394 | eerror "A dry-run of patch command succeeded, but actually" |
409 | eerror "A dry-run of patch command succeeded, but actually" |
… | |
… | |
425 | done |
440 | done |
426 | |
441 | |
427 | [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching" |
442 | [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching" |
428 | : # everything worked |
443 | : # everything worked |
429 | } |
444 | } |
|
|
445 | |
|
|
446 | # @FUNCTION: epatch_user |
|
|
447 | # @USAGE: |
|
|
448 | # @DESCRIPTION: |
|
|
449 | # Applies user-provided patches to the source tree. The patches are |
|
|
450 | # taken from /etc/portage/patches/<CATEGORY>/<PF|P|PN>/, where the first |
|
|
451 | # of these three directories to exist will be the one to use, ignoring |
|
|
452 | # any more general directories which might exist as well. |
|
|
453 | # |
|
|
454 | # User patches are intended for quick testing of patches without ebuild |
|
|
455 | # modifications, as well as for permanent customizations a user might |
|
|
456 | # desire. Obviously, there can be no official support for arbitrarily |
|
|
457 | # patched ebuilds. So whenever a build log in a bug report mentions that |
|
|
458 | # user patches were applied, the user should be asked to reproduce the |
|
|
459 | # problem without these. |
|
|
460 | # |
|
|
461 | # Not all ebuilds do call this function, so placing patches in the |
|
|
462 | # stated directory might or might not work, depending on the package and |
|
|
463 | # the eclasses it inherits and uses. It is safe to call the function |
|
|
464 | # repeatedly, so it is always possible to add a call at the ebuild |
|
|
465 | # level. The first call is the time when the patches will be |
|
|
466 | # applied. |
|
|
467 | # |
|
|
468 | # Ideally, this function should be called after gentoo-specific patches |
|
|
469 | # have been applied, so that their code can be modified as well, but |
|
|
470 | # before calls to e.g. eautoreconf, as the user patches might affect |
|
|
471 | # autotool input files as well. |
430 | epatch_user() { |
472 | epatch_user() { |
431 | [[ $# -ne 0 ]] && die "epatch_user takes no options" |
473 | [[ $# -ne 0 ]] && die "epatch_user takes no options" |
|
|
474 | |
|
|
475 | # Allow multiple calls to this function; ignore all but the first |
|
|
476 | local applied="${T}/epatch_user.applied" |
|
|
477 | [[ -e ${applied} ]] && return 2 |
432 | |
478 | |
433 | # don't clobber any EPATCH vars that the parent might want |
479 | # don't clobber any EPATCH vars that the parent might want |
434 | local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches |
480 | local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches |
435 | for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do |
481 | for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do |
436 | EPATCH_SOURCE=${base}/${CTARGET}/${check} |
482 | EPATCH_SOURCE=${base}/${CTARGET}/${check} |
… | |
… | |
440 | EPATCH_SOURCE=${EPATCH_SOURCE} \ |
486 | EPATCH_SOURCE=${EPATCH_SOURCE} \ |
441 | EPATCH_SUFFIX="patch" \ |
487 | EPATCH_SUFFIX="patch" \ |
442 | EPATCH_FORCE="yes" \ |
488 | EPATCH_FORCE="yes" \ |
443 | EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." \ |
489 | EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." \ |
444 | epatch |
490 | epatch |
|
|
491 | echo "${EPATCH_SOURCE}" > "${applied}" |
445 | return 0 |
492 | return 0 |
446 | fi |
493 | fi |
447 | done |
494 | done |
|
|
495 | echo "none" > "${applied}" |
448 | return 1 |
496 | return 1 |
449 | } |
497 | } |
450 | |
498 | |
451 | # @FUNCTION: emktemp |
499 | # @FUNCTION: emktemp |
452 | # @USAGE: [temp dir] |
500 | # @USAGE: [temp dir] |
… | |
… | |
497 | egetent() { |
545 | egetent() { |
498 | case ${CHOST} in |
546 | case ${CHOST} in |
499 | *-darwin[678]) |
547 | *-darwin[678]) |
500 | case "$2" in |
548 | case "$2" in |
501 | *[!0-9]*) # Non numeric |
549 | *[!0-9]*) # Non numeric |
502 | nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" |
550 | nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2\$/) {print \$0;exit;} }" |
503 | ;; |
551 | ;; |
504 | *) # Numeric |
552 | *) # Numeric |
505 | nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" |
553 | nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" |
506 | ;; |
554 | ;; |
507 | esac |
555 | esac |
… | |
… | |
1391 | dd) exe="dd ibs=${skip} skip=1 if='${src}'";; |
1439 | dd) exe="dd ibs=${skip} skip=1 if='${src}'";; |
1392 | *) die "makeself cant handle exe '${exe}'" |
1440 | *) die "makeself cant handle exe '${exe}'" |
1393 | esac |
1441 | esac |
1394 | |
1442 | |
1395 | # lets grab the first few bytes of the file to figure out what kind of archive it is |
1443 | # lets grab the first few bytes of the file to figure out what kind of archive it is |
1396 | local tmpfile=$(emktemp) |
1444 | local filetype tmpfile=$(emktemp) |
1397 | eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" |
1445 | eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" |
1398 | local filetype=$(file -b "${tmpfile}") |
1446 | filetype=$(file -b "${tmpfile}") || die |
1399 | case ${filetype} in |
1447 | case ${filetype} in |
1400 | *tar\ archive*) |
1448 | *tar\ archive*) |
1401 | eval ${exe} | tar --no-same-owner -xf - |
1449 | eval ${exe} | tar --no-same-owner -xf - |
1402 | ;; |
1450 | ;; |
1403 | bzip2*) |
1451 | bzip2*) |
… | |
… | |
1713 | else |
1761 | else |
1714 | newls="" |
1762 | newls="" |
1715 | fi |
1763 | fi |
1716 | for f in $(find "$d" -name '*.po' -exec basename {} .po ';') ; do |
1764 | for f in $(find "$d" -name '*.po' -exec basename {} .po ';') ; do |
1717 | if [[ ${op} == "-i" ]] ; then |
1765 | if [[ ${op} == "-i" ]] ; then |
1718 | hasq ${f} ${ls} && newls="${newls} ${f}" |
1766 | has ${f} ${ls} && newls="${newls} ${f}" |
1719 | else |
1767 | else |
1720 | hasq ${f} ${ls} || newls="${newls} ${f}" |
1768 | has ${f} ${ls} || newls="${newls} ${f}" |
1721 | fi |
1769 | fi |
1722 | done |
1770 | done |
1723 | ls=${newls} |
1771 | ls=${newls} |
1724 | done |
1772 | done |
1725 | else |
1773 | else |
… | |
… | |
1727 | fi |
1775 | fi |
1728 | |
1776 | |
1729 | nols="" |
1777 | nols="" |
1730 | newls="" |
1778 | newls="" |
1731 | for f in ${LINGUAS} ; do |
1779 | for f in ${LINGUAS} ; do |
1732 | if hasq ${f} ${ls} ; then |
1780 | if has ${f} ${ls} ; then |
1733 | newls="${newls} ${f}" |
1781 | newls="${newls} ${f}" |
1734 | else |
1782 | else |
1735 | nols="${nols} ${f}" |
1783 | nols="${nols} ${f}" |
1736 | fi |
1784 | fi |
1737 | done |
1785 | done |
… | |
… | |
1792 | ewarn "the libraries are not being removed. You need to run revdep-rebuild" |
1840 | ewarn "the libraries are not being removed. You need to run revdep-rebuild" |
1793 | ewarn "in order to remove these old dependencies. If you do not have this" |
1841 | ewarn "in order to remove these old dependencies. If you do not have this" |
1794 | ewarn "helper program, simply emerge the 'gentoolkit' package." |
1842 | ewarn "helper program, simply emerge the 'gentoolkit' package." |
1795 | ewarn |
1843 | ewarn |
1796 | fi |
1844 | fi |
|
|
1845 | # temp hack for #348634 #357225 |
|
|
1846 | [[ ${PN} == "mpfr" ]] && lib=${lib##*/} |
1797 | ewarn " # revdep-rebuild --library '${lib}'" |
1847 | ewarn " # revdep-rebuild --library '${lib}'" |
1798 | done |
1848 | done |
1799 | if [[ ${notice} -eq 1 ]] ; then |
1849 | if [[ ${notice} -eq 1 ]] ; then |
1800 | ewarn |
1850 | ewarn |
1801 | ewarn "Once you've finished running revdep-rebuild, it should be safe to" |
1851 | ewarn "Once you've finished running revdep-rebuild, it should be safe to" |