| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2006 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.221 2005/12/31 14:11:39 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.237 2006/06/04 15:18:12 vapier Exp $ |
| 4 | # |
|
|
| 5 | # Author: Martin Schlemmer <azarah@gentoo.org> |
|
|
| 6 | # |
4 | # |
| 7 | # This eclass is for general purpose functions that most ebuilds |
5 | # This eclass is for general purpose functions that most ebuilds |
| 8 | # have to implement themselves. |
6 | # have to implement themselves. |
| 9 | # |
7 | # |
| 10 | # NB: If you add anything, please comment it! |
8 | # NB: If you add anything, please comment it! |
| 11 | |
9 | |
| 12 | inherit multilib portability |
10 | inherit multilib portability |
| 13 | |
11 | |
| 14 | DEPEND="!bootstrap? ( sys-devel/patch )" |
12 | DEPEND="!bootstrap? ( sys-devel/patch )" |
|
|
13 | RDEPEND="" |
| 15 | # sys-apps/shadow is needed for useradd, etc, bug #94745. |
14 | # sys-apps/shadow is needed for useradd, etc, bug #94745. |
| 16 | |
15 | |
| 17 | DESCRIPTION="Based on the ${ECLASS} eclass" |
16 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 18 | |
17 | |
| 19 | # Wait for the supplied number of seconds. If no argument is supplied, defaults |
18 | # Wait for the supplied number of seconds. If no argument is supplied, defaults |
| … | |
… | |
| 88 | # Default extension for patches |
87 | # Default extension for patches |
| 89 | EPATCH_SUFFIX="patch.bz2" |
88 | EPATCH_SUFFIX="patch.bz2" |
| 90 | # Default options for patch |
89 | # Default options for patch |
| 91 | # Set -g0 to keep RCS, ClearCase, Perforce and SCCS happy. Bug #24571 |
90 | # Set -g0 to keep RCS, ClearCase, Perforce and SCCS happy. Bug #24571 |
| 92 | # Set --no-backup-if-mismatch so we don't leave '.orig' files behind. |
91 | # Set --no-backup-if-mismatch so we don't leave '.orig' files behind. |
|
|
92 | # Set -E to automatically remove empty files. |
| 93 | EPATCH_OPTS="-g0 --no-backup-if-mismatch" |
93 | EPATCH_OPTS="-g0 -E --no-backup-if-mismatch" |
| 94 | # List of patches not to apply. Not this is only file names, |
94 | # List of patches not to apply. Not this is only file names, |
| 95 | # and not the full path .. |
95 | # and not the full path .. |
| 96 | EPATCH_EXCLUDE="" |
96 | EPATCH_EXCLUDE="" |
| 97 | # Change the printed message for a single patch. |
97 | # Change the printed message for a single patch. |
| 98 | EPATCH_SINGLE_MSG="" |
98 | EPATCH_SINGLE_MSG="" |
| … | |
… | |
| 137 | # |
137 | # |
| 138 | # <azarah@gentoo.org> (10 Nov 2002) |
138 | # <azarah@gentoo.org> (10 Nov 2002) |
| 139 | # |
139 | # |
| 140 | epatch() { |
140 | epatch() { |
| 141 | _epatch_draw_line() { |
141 | _epatch_draw_line() { |
| 142 | local i=0 str_length="" str_out="" |
142 | [[ -z $1 ]] && set "$(printf "%65s" '')" |
| 143 | |
143 | echo "${1//?/=}" |
| 144 | # Handle calls that do not have args, or wc not being installed ... |
|
|
| 145 | if [[ -z $1 ]] || ! type -p wc >/dev/null ; then |
|
|
| 146 | str_length=65 |
|
|
| 147 | else |
|
|
| 148 | str_length=$(echo -n "$*" | wc -m) |
|
|
| 149 | fi |
|
|
| 150 | |
|
|
| 151 | while ((i++ < ${str_length})) ; do |
|
|
| 152 | str_out="${str_out}=" |
|
|
| 153 | done |
|
|
| 154 | echo ${str_out} |
|
|
| 155 | |
|
|
| 156 | return 0 |
|
|
| 157 | } |
144 | } |
| 158 | _epatch_assert() { local _pipestatus=${PIPESTATUS[*]}; [[ ${_pipestatus// /} -eq 0 ]] ; } |
145 | _epatch_assert() { local _pipestatus=${PIPESTATUS[*]}; [[ ${_pipestatus// /} -eq 0 ]] ; } |
| 159 | local PIPE_CMD="" |
146 | local PIPE_CMD="" |
| 160 | local STDERR_TARGET="${T}/$$.out" |
147 | local STDERR_TARGET="${T}/$$.out" |
| 161 | local PATCH_TARGET="${T}/$$.patch" |
148 | local PATCH_TARGET="${T}/$$.patch" |
| … | |
… | |
| 383 | tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM} |
370 | tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM} |
| 384 | done |
371 | done |
| 385 | ${exe} "${tmp}" || ${exe} -p "${tmp}" |
372 | ${exe} "${tmp}" || ${exe} -p "${tmp}" |
| 386 | echo "${tmp}" |
373 | echo "${tmp}" |
| 387 | else |
374 | else |
| 388 | [[ ${exe} == "touch" ]] \ |
375 | if [[ ${exe} == "touch" ]] ; then |
| 389 | && exe="-p" \ |
376 | [[ ${USERLAND} == "GNU" ]] \ |
| 390 | || exe="-d" |
377 | && mktemp -p "${topdir}" \ |
| 391 | mktemp ${exe} "${topdir}" |
378 | || TMPDIR="${topdir}" mktemp -t tmp |
|
|
379 | else |
|
|
380 | [[ ${USERLAND} == "GNU" ]] \ |
|
|
381 | && mktemp -d "${topdir}" \ |
|
|
382 | || TMPDIR="${topdir}" mktemp -dt tmp |
|
|
383 | fi |
| 392 | fi |
384 | fi |
| 393 | } |
385 | } |
| 394 | |
386 | |
| 395 | # Small wrapper for getent (Linux), nidump (Mac OS X), |
387 | # Small wrapper for getent (Linux), nidump (Mac OS X), |
| 396 | # and pw (FreeBSD) used in enewuser()/enewgroup() |
388 | # and pw (FreeBSD) used in enewuser()/enewgroup() |
| … | |
… | |
| 443 | # shell: /bin/false |
435 | # shell: /bin/false |
| 444 | # homedir: /dev/null |
436 | # homedir: /dev/null |
| 445 | # groups: none |
437 | # groups: none |
| 446 | # extra: comment of 'added by portage for ${PN}' |
438 | # extra: comment of 'added by portage for ${PN}' |
| 447 | enewuser() { |
439 | enewuser() { |
|
|
440 | case ${EBUILD_PHASE} in |
|
|
441 | unpack|compile|test|install) |
|
|
442 | eerror "'enewuser()' called from '${EBUILD_PHASE}()' which is not a pkg_* function." |
|
|
443 | eerror "Package fails at QA and at life. Please file a bug." |
|
|
444 | die "Bad package! enewuser is only for use in pkg_* functions!" |
|
|
445 | esac |
|
|
446 | |
| 448 | # get the username |
447 | # get the username |
| 449 | local euser=$1; shift |
448 | local euser=$1; shift |
| 450 | if [[ -z ${euser} ]] ; then |
449 | if [[ -z ${euser} ]] ; then |
| 451 | eerror "No username specified !" |
450 | eerror "No username specified !" |
| 452 | die "Cannot call enewuser without a username" |
451 | die "Cannot call enewuser without a username" |
| … | |
… | |
| 638 | # Default values if you do not specify any: |
637 | # Default values if you do not specify any: |
| 639 | # groupname: REQUIRED ! |
638 | # groupname: REQUIRED ! |
| 640 | # gid: next available (see groupadd(8)) |
639 | # gid: next available (see groupadd(8)) |
| 641 | # extra: none |
640 | # extra: none |
| 642 | enewgroup() { |
641 | enewgroup() { |
|
|
642 | case ${EBUILD_PHASE} in |
|
|
643 | unpack|compile|test|install) |
|
|
644 | eerror "'enewgroup()' called from '${EBUILD_PHASE}()' which is not a pkg_* function." |
|
|
645 | eerror "Package fails at QA and at life. Please file a bug." |
|
|
646 | die "Bad package! enewgroup is only for use in pkg_* functions!" |
|
|
647 | esac |
|
|
648 | |
| 643 | # get the group |
649 | # get the group |
| 644 | local egroup="$1"; shift |
650 | local egroup="$1"; shift |
| 645 | if [ -z "${egroup}" ] |
651 | if [ -z "${egroup}" ] |
| 646 | then |
652 | then |
| 647 | eerror "No group specified !" |
653 | eerror "No group specified !" |
| … | |
… | |
| 883 | local desktop_name="${PN}" |
889 | local desktop_name="${PN}" |
| 884 | else |
890 | else |
| 885 | local desktop_name="${PN}-${SLOT}" |
891 | local desktop_name="${PN}-${SLOT}" |
| 886 | fi |
892 | fi |
| 887 | local desktop=${T}/${exec%% *}-${desktop_name}.desktop |
893 | local desktop=${T}/${exec%% *}-${desktop_name}.desktop |
|
|
894 | # local desktop=${T}/${exec%% *:-${desktop_name}}.desktop |
| 888 | |
895 | |
| 889 | echo "[Desktop Entry] |
896 | echo "[Desktop Entry] |
| 890 | Encoding=UTF-8 |
897 | Encoding=UTF-8 |
| 891 | Version=0.9.2 |
898 | Version=0.9.2 |
| 892 | Name=${name} |
899 | Name=${name} |
| 893 | Type=Application |
900 | Type=Application |
| 894 | Comment=${DESCRIPTION} |
901 | Comment=${DESCRIPTION} |
| 895 | Exec=${exec} |
902 | Exec=${exec} |
|
|
903 | TryExec=${exec} |
| 896 | Path=${path} |
904 | Path=${path} |
| 897 | Icon=${icon} |
905 | Icon=${icon} |
| 898 | Categories=Application;${type};" > "${desktop}" |
906 | Categories=Application;${type};" > "${desktop}" |
| 899 | |
907 | |
| 900 | ( |
908 | ( |
| … | |
… | |
| 1411 | echo |
1419 | echo |
| 1412 | einfo "If you are having trouble with the detection" |
1420 | einfo "If you are having trouble with the detection" |
| 1413 | einfo "of your CD, it is possible that you do not have" |
1421 | einfo "of your CD, it is possible that you do not have" |
| 1414 | einfo "Joliet support enabled in your kernel. Please" |
1422 | einfo "Joliet support enabled in your kernel. Please" |
| 1415 | einfo "check that CONFIG_JOLIET is enabled in your kernel." |
1423 | einfo "check that CONFIG_JOLIET is enabled in your kernel." |
| 1416 | read |
1424 | read || die "something is screwed with your system" |
| 1417 | done |
1425 | done |
| 1418 | } |
1426 | } |
| 1419 | |
1427 | |
| 1420 | # Make sure that LINGUAS only contains languages that |
1428 | # Make sure that LINGUAS only contains languages that |
| 1421 | # a package can support |
1429 | # a package can support |
| … | |
… | |
| 1431 | # directories and uses the union of the lists. |
1439 | # directories and uses the union of the lists. |
| 1432 | strip-linguas() { |
1440 | strip-linguas() { |
| 1433 | local ls newls |
1441 | local ls newls |
| 1434 | if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then |
1442 | if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then |
| 1435 | local op=$1; shift |
1443 | local op=$1; shift |
| 1436 | ls=" $(find "$1" -name '*.po' -printf '%f ') "; shift |
1444 | ls=$(find "$1" -name '*.po' -exec basename {} .po \;); shift |
| 1437 | local d f |
1445 | local d f |
| 1438 | for d in "$@" ; do |
1446 | for d in "$@" ; do |
| 1439 | if [[ ${op} == "-u" ]] ; then |
1447 | if [[ ${op} == "-u" ]] ; then |
| 1440 | newls=${ls} |
1448 | newls=${ls} |
| 1441 | else |
1449 | else |
| 1442 | newls="" |
1450 | newls="" |
| 1443 | fi |
1451 | fi |
| 1444 | for f in $(find "$d" -name '*.po' -printf '%f ') ; do |
1452 | for f in $(find "$d" -name '*.po' -exec basename {} .po \;) ; do |
| 1445 | if [[ ${op} == "-i" ]] ; then |
1453 | if [[ ${op} == "-i" ]] ; then |
| 1446 | [[ ${ls/ ${f} /} != ${ls} ]] && newls="${newls} ${f}" |
1454 | hasq ${f} ${ls} && newls="${newls} ${f}" |
| 1447 | else |
1455 | else |
| 1448 | [[ ${ls/ ${f} /} == ${ls} ]] && newls="${newls} ${f}" |
1456 | hasq ${f} ${ls} || newls="${newls} ${f}" |
| 1449 | fi |
1457 | fi |
| 1450 | done |
1458 | done |
| 1451 | ls=${newls} |
1459 | ls=${newls} |
| 1452 | done |
1460 | done |
| 1453 | ls=${ls//.po} |
|
|
| 1454 | else |
1461 | else |
| 1455 | ls=$@ |
1462 | ls="$@" |
| 1456 | fi |
1463 | fi |
| 1457 | |
1464 | |
| 1458 | ls=" ${ls} " |
|
|
| 1459 | newls="" |
1465 | newls="" |
| 1460 | for f in ${LINGUAS} ; do |
1466 | for f in ${LINGUAS} ; do |
| 1461 | if [[ ${ls/ ${f} /} != ${ls} ]] ; then |
1467 | if hasq ${f} ${ls} ; then |
| 1462 | newls="${newls} ${f}" |
1468 | newls="${newls} ${f}" |
| 1463 | else |
1469 | else |
| 1464 | ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" |
1470 | ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" |
| 1465 | fi |
1471 | fi |
| 1466 | done |
1472 | done |
| 1467 | if [[ -z ${newls} ]] ; then |
|
|
| 1468 | export LINGUAS="" |
|
|
| 1469 | else |
|
|
| 1470 | export LINGUAS=${newls:1} |
1473 | export LINGUAS=${newls:1} |
| 1471 | fi |
|
|
| 1472 | } |
1474 | } |
| 1473 | |
1475 | |
| 1474 | # moved from kernel.eclass since they are generally useful outside of |
1476 | # moved from kernel.eclass since they are generally useful outside of |
| 1475 | # kernel.eclass -iggy (20041002) |
1477 | # kernel.eclass -iggy (20041002) |
| 1476 | |
1478 | |
| … | |
… | |
| 1505 | |
1507 | |
| 1506 | # Jeremy Huddleston <eradicator@gentoo.org>: |
1508 | # Jeremy Huddleston <eradicator@gentoo.org>: |
| 1507 | # preserve_old_lib /path/to/libblah.so.0 |
1509 | # preserve_old_lib /path/to/libblah.so.0 |
| 1508 | # preserve_old_lib_notify /path/to/libblah.so.0 |
1510 | # preserve_old_lib_notify /path/to/libblah.so.0 |
| 1509 | # |
1511 | # |
| 1510 | # These functions are useful when a lib in your package changes --soname. Such |
1512 | # These functions are useful when a lib in your package changes --library. Such |
| 1511 | # an example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0 |
1513 | # an example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0 |
| 1512 | # would break packages that link against it. Most people get around this |
1514 | # would break packages that link against it. Most people get around this |
| 1513 | # by using the portage SLOT mechanism, but that is not always a relevant |
1515 | # by using the portage SLOT mechanism, but that is not always a relevant |
| 1514 | # solution, so instead you can add the following to your ebuilds: |
1516 | # solution, so instead you can add the following to your ebuilds: |
| 1515 | # |
1517 | # |
| … | |
… | |
| 1546 | |
1548 | |
| 1547 | ewarn "An old version of an installed library was detected on your system." |
1549 | ewarn "An old version of an installed library was detected on your system." |
| 1548 | ewarn "In order to avoid breaking packages that link against it, this older version" |
1550 | ewarn "In order to avoid breaking packages that link against it, this older version" |
| 1549 | ewarn "is not being removed. In order to make full use of this newer version," |
1551 | ewarn "is not being removed. In order to make full use of this newer version," |
| 1550 | ewarn "you will need to execute the following command:" |
1552 | ewarn "you will need to execute the following command:" |
| 1551 | ewarn " revdep-rebuild --soname ${SONAME}" |
1553 | ewarn " revdep-rebuild --library ${SONAME}" |
| 1552 | ewarn |
1554 | ewarn |
| 1553 | ewarn "After doing that, you can safely remove ${LIB}" |
1555 | ewarn "After doing that, you can safely remove ${LIB}" |
| 1554 | ewarn "Note: 'emerge gentoolkit' to get revdep-rebuild" |
1556 | ewarn "Note: 'emerge gentoolkit' to get revdep-rebuild" |
| 1555 | fi |
1557 | fi |
| 1556 | } |
1558 | } |