| 1 | # Copyright 1999-2006 Gentoo Foundation |
1 | # Copyright 1999-2007 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.275 2007/02/17 00:17:39 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.282 2007/06/16 07:11:43 vapier Exp $ |
| 4 | # |
4 | # |
| 5 | # This eclass is for general purpose functions that most ebuilds |
5 | # This eclass is for general purpose functions that most ebuilds |
| 6 | # have to implement themselves. |
6 | # have to implement themselves. |
| 7 | # |
7 | # |
| 8 | # NB: If you add anything, please comment it! |
8 | # NB: If you add anything, please comment it! |
| … | |
… | |
| 35 | echo -ne "\a" |
35 | echo -ne "\a" |
| 36 | sleep 1 |
36 | sleep 1 |
| 37 | done |
37 | done |
| 38 | fi |
38 | fi |
| 39 | } |
39 | } |
| 40 | |
|
|
| 41 | # This function generate linker scripts in /usr/lib for dynamic |
|
|
| 42 | # libs in /lib. This is to fix linking problems when you have |
|
|
| 43 | # the .so in /lib, and the .a in /usr/lib. What happens is that |
|
|
| 44 | # in some cases when linking dynamic, the .a in /usr/lib is used |
|
|
| 45 | # instead of the .so in /lib due to gcc/libtool tweaking ld's |
|
|
| 46 | # library search path. This cause many builds to fail. |
|
|
| 47 | # See bug #4411 for more info. |
|
|
| 48 | # |
|
|
| 49 | # To use, simply call: |
|
|
| 50 | # |
|
|
| 51 | # gen_usr_ldscript libfoo.so |
|
|
| 52 | # |
|
|
| 53 | # Note that you should in general use the unversioned name of |
|
|
| 54 | # the library, as ldconfig should usually update it correctly |
|
|
| 55 | # to point to the latest version of the library present. |
|
|
| 56 | # |
|
|
| 57 | # <azarah@gentoo.org> (26 Oct 2002) |
|
|
| 58 | # |
|
|
| 59 | gen_usr_ldscript() { |
|
|
| 60 | if [[ $(type -t _tc_gen_usr_ldscript) == "function" ]] ; then |
|
|
| 61 | _tc_gen_usr_ldscript "$@" |
|
|
| 62 | return $? |
|
|
| 63 | fi |
|
|
| 64 | |
|
|
| 65 | ewarn "QA Notice: Please upgrade your ebuild to use toolchain-funcs" |
|
|
| 66 | ewarn "QA Notice: rather than gen_usr_ldscript() from eutils" |
|
|
| 67 | |
|
|
| 68 | local lib libdir=$(get_libdir) |
|
|
| 69 | # Just make sure it exists |
|
|
| 70 | dodir /usr/${libdir} |
|
|
| 71 | |
|
|
| 72 | for lib in "${@}" ; do |
|
|
| 73 | cat > "${D}/usr/${libdir}/${lib}" <<-END_LDSCRIPT |
|
|
| 74 | /* GNU ld script |
|
|
| 75 | Since Gentoo has critical dynamic libraries |
|
|
| 76 | in /lib, and the static versions in /usr/lib, |
|
|
| 77 | we need to have a "fake" dynamic lib in /usr/lib, |
|
|
| 78 | otherwise we run into linking problems. |
|
|
| 79 | |
|
|
| 80 | See bug http://bugs.gentoo.org/4411 for more info. |
|
|
| 81 | */ |
|
|
| 82 | GROUP ( /${libdir}/${lib} ) |
|
|
| 83 | END_LDSCRIPT |
|
|
| 84 | fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}" |
|
|
| 85 | done |
|
|
| 86 | } |
|
|
| 87 | |
|
|
| 88 | |
40 | |
| 89 | # Default directory where patches are located |
41 | # Default directory where patches are located |
| 90 | EPATCH_SOURCE="${WORKDIR}/patch" |
42 | EPATCH_SOURCE="${WORKDIR}/patch" |
| 91 | # Default extension for patches |
43 | # Default extension for patches |
| 92 | EPATCH_SUFFIX="patch.bz2" |
44 | EPATCH_SUFFIX="patch.bz2" |
| … | |
… | |
| 366 | [[ -z ${T} ]] \ |
318 | [[ -z ${T} ]] \ |
| 367 | && topdir="/tmp" \ |
319 | && topdir="/tmp" \ |
| 368 | || topdir=${T} |
320 | || topdir=${T} |
| 369 | fi |
321 | fi |
| 370 | |
322 | |
| 371 | if [[ -z $(type -p mktemp) ]] ; then |
323 | if ! type -P mktemp > /dev/null ; then |
|
|
324 | # system lacks `mktemp` so we have to fake it |
| 372 | local tmp=/ |
325 | local tmp=/ |
| 373 | while [[ -e ${tmp} ]] ; do |
326 | while [[ -e ${tmp} ]] ; do |
| 374 | tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM} |
327 | tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM} |
| 375 | done |
328 | done |
| 376 | ${exe} "${tmp}" || ${exe} -p "${tmp}" |
329 | ${exe} "${tmp}" || ${exe} -p "${tmp}" |
| 377 | echo "${tmp}" |
330 | echo "${tmp}" |
| 378 | else |
331 | else |
|
|
332 | # the args here will give slightly wierd names on BSD, |
|
|
333 | # but should produce a usable file on all userlands |
| 379 | if [[ ${exe} == "touch" ]] ; then |
334 | if [[ ${exe} == "touch" ]] ; then |
| 380 | [[ ${USERLAND} == "GNU" ]] \ |
|
|
| 381 | && mktemp -p "${topdir}" \ |
|
|
| 382 | || TMPDIR="${topdir}" mktemp -t tmp |
335 | TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX |
| 383 | else |
336 | else |
| 384 | [[ ${USERLAND} == "GNU" ]] \ |
|
|
| 385 | && mktemp -d "${topdir}" \ |
|
|
| 386 | || TMPDIR="${topdir}" mktemp -dt tmp |
337 | TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX |
| 387 | fi |
338 | fi |
| 388 | fi |
339 | fi |
| 389 | } |
340 | } |
| 390 | |
341 | |
| 391 | # Small wrapper for getent (Linux), nidump (Mac OS X), |
342 | # Small wrapper for getent (Linux), nidump (Mac OS X), |
| … | |
… | |
| 916 | # doesn't corrupt the env of the caller |
867 | # doesn't corrupt the env of the caller |
| 917 | insinto /usr/share/applications |
868 | insinto /usr/share/applications |
| 918 | doins "${desktop}" |
869 | doins "${desktop}" |
| 919 | ) |
870 | ) |
| 920 | } |
871 | } |
|
|
872 | |
|
|
873 | |
|
|
874 | # Validate desktop entries using desktop-file-utils |
|
|
875 | # Carsten Lohrke <carlo@gentoo.org> |
|
|
876 | # |
|
|
877 | # Usage: validate_desktop_entries [directory ...] |
|
|
878 | |
|
|
879 | validate_desktop_entries() { |
|
|
880 | if [[ -x /usr/bin/desktop-file-validate ]] ; then |
|
|
881 | einfo "Checking desktop entry validity" |
|
|
882 | local directories="" |
|
|
883 | for d in /usr/share/applications $@ ; do |
|
|
884 | [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}" |
|
|
885 | done |
|
|
886 | if [[ -n ${directories} ]] ; then |
|
|
887 | for FILE in $(find ${directories} -name "*\.desktop" \ |
|
|
888 | -not -path '*.hidden*' | sort -u 2>/dev/null) |
|
|
889 | do |
|
|
890 | local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | \ |
|
|
891 | sed -e "s|error: ||" -e "s|${FILE}:|--|g" ) |
|
|
892 | [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:} |
|
|
893 | done |
|
|
894 | fi |
|
|
895 | echo "" |
|
|
896 | else |
|
|
897 | einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo." |
|
|
898 | fi |
|
|
899 | } |
|
|
900 | |
| 921 | |
901 | |
| 922 | # Make a GDM/KDM Session file |
902 | # Make a GDM/KDM Session file |
| 923 | # |
903 | # |
| 924 | # make_session_desktop(<title>, <command>) |
904 | # make_session_desktop(<title>, <command>) |
| 925 | # title: File to execute to start the Window Manager |
905 | # title: File to execute to start the Window Manager |
| … | |
… | |
| 1430 | local dir=$(dirname ${cdset[${i}]}) |
1410 | local dir=$(dirname ${cdset[${i}]}) |
| 1431 | local file=$(basename ${cdset[${i}]}) |
1411 | local file=$(basename ${cdset[${i}]}) |
| 1432 | |
1412 | |
| 1433 | local point= node= fs= foo= |
1413 | local point= node= fs= foo= |
| 1434 | while read point node fs foo ; do |
1414 | while read point node fs foo ; do |
| 1435 | [[ " cd9660 iso9660 " != *" ${fs} "* ]] && \ |
1415 | [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && \ |
| 1436 | ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \ |
1416 | ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \ |
| 1437 | && continue |
1417 | && continue |
| 1438 | point=${point//\040/ } |
1418 | point=${point//\040/ } |
| 1439 | [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue |
1419 | [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue |
| 1440 | export CDROM_ROOT=${point} |
1420 | export CDROM_ROOT=${point} |
| … | |
… | |
| 1581 | # } |
1561 | # } |
| 1582 | |
1562 | |
| 1583 | preserve_old_lib() { |
1563 | preserve_old_lib() { |
| 1584 | if [[ ${EBUILD_PHASE} != "preinst" ]] ; then |
1564 | if [[ ${EBUILD_PHASE} != "preinst" ]] ; then |
| 1585 | eerror "preserve_old_lib() must be called from pkg_preinst() only" |
1565 | eerror "preserve_old_lib() must be called from pkg_preinst() only" |
| 1586 | # die "Invalid preserve_old_lib() usage" |
1566 | die "Invalid preserve_old_lib() usage" |
| 1587 | fi |
1567 | fi |
| 1588 | [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]" |
1568 | [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]" |
| 1589 | |
1569 | |
| 1590 | local lib dir |
1570 | local lib dir |
| 1591 | for lib in "$@" ; do |
1571 | for lib in "$@" ; do |
| … | |
… | |
| 1598 | } |
1578 | } |
| 1599 | |
1579 | |
| 1600 | preserve_old_lib_notify() { |
1580 | preserve_old_lib_notify() { |
| 1601 | if [[ ${EBUILD_PHASE} != "postinst" ]] ; then |
1581 | if [[ ${EBUILD_PHASE} != "postinst" ]] ; then |
| 1602 | eerror "preserve_old_lib_notify() must be called from pkg_postinst() only" |
1582 | eerror "preserve_old_lib_notify() must be called from pkg_postinst() only" |
| 1603 | # die "Invalid preserve_old_lib_notify() usage" |
1583 | die "Invalid preserve_old_lib_notify() usage" |
| 1604 | fi |
1584 | fi |
| 1605 | |
1585 | |
| 1606 | local lib notice=0 |
1586 | local lib notice=0 |
| 1607 | for lib in "$@" ; do |
1587 | for lib in "$@" ; do |
| 1608 | [[ -e ${ROOT}/${lib} ]] || continue |
1588 | [[ -e ${ROOT}/${lib} ]] || continue |