/[gentoo-x86]/eclass/eutils.eclass
Gentoo

Diff of /eclass/eutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.219 Revision 1.237
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.219 2005/11/29 03:37:36 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
12inherit multilib portability 10inherit multilib portability
13 11
14DEPEND="!bootstrap? ( sys-devel/patch )" 12DEPEND="!bootstrap? ( sys-devel/patch )"
13RDEPEND=""
15# sys-apps/shadow is needed for useradd, etc, bug #94745. 14# sys-apps/shadow is needed for useradd, etc, bug #94745.
16 15
17DESCRIPTION="Based on the ${ECLASS} eclass" 16DESCRIPTION="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
89EPATCH_SUFFIX="patch.bz2" 88EPATCH_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.
93EPATCH_OPTS="-g0 --no-backup-if-mismatch" 93EPATCH_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 ..
96EPATCH_EXCLUDE="" 96EPATCH_EXCLUDE=""
97# Change the printed message for a single patch. 97# Change the printed message for a single patch.
98EPATCH_SINGLE_MSG="" 98EPATCH_SINGLE_MSG=""
137# 137#
138# <azarah@gentoo.org> (10 Nov 2002) 138# <azarah@gentoo.org> (10 Nov 2002)
139# 139#
140epatch() { 140epatch() {
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()
408 *) # Numeric 400 *) # Numeric
409 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" 401 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
410 ;; 402 ;;
411 esac 403 esac
412 ;; 404 ;;
413 *-freebsd*) 405 *-freebsd*|*-dragonfly*)
414 local opts action="user" 406 local opts action="user"
415 [[ $1 == "passwd" ]] || action="group" 407 [[ $1 == "passwd" ]] || action="group"
416 408
417 # lookup by uid/gid 409 # lookup by uid/gid
418 if [[ $2 == [[:digit:]]* ]] ; then 410 if [[ $2 == [[:digit:]]* ]] ; then
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}'
447enewuser() { 439enewuser() {
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"
484 einfo " - Userid: ${euid}" 483 einfo " - Userid: ${euid}"
485 484
486 # handle shell 485 # handle shell
487 local eshell=$1; shift 486 local eshell=$1; shift
488 if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then 487 if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then
489 if [[ ! -e ${eshell} ]] ; then 488 if [[ ! -e ${ROOT}${eshell} ]] ; then
490 eerror "A shell was specified but it does not exist !" 489 eerror "A shell was specified but it does not exist !"
491 die "${eshell} does not exist" 490 die "${eshell} does not exist in ${ROOT}"
491 fi
492 if [[ ${eshell} == */false || ${eshell} == */nologin ]] ; then
493 eerror "Do not specify ${eshell} yourself, use -1"
494 die "Pass '-1' as the shell parameter"
492 fi 495 fi
493 else 496 else
494 for shell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null ; do 497 for shell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null ; do
495 [[ -x ${ROOT}${shell} ]] && break 498 [[ -x ${ROOT}${shell} ]] && break
496 done 499 done
567 einfo "Please report the ebuild along with the info below" 570 einfo "Please report the ebuild along with the info below"
568 einfo "eextra: $@" 571 einfo "eextra: $@"
569 die "Required function missing" 572 die "Required function missing"
570 fi 573 fi
571 ;; 574 ;;
572 *-freebsd*) 575 *-freebsd*|*-dragonfly*)
573 if [[ -z $@ ]] ; then 576 if [[ -z $@ ]] ; then
574 pw useradd ${euser} ${opts} \ 577 pw useradd ${euser} ${opts} \
575 -c "added by portage for ${PN}" \ 578 -c "added by portage for ${PN}" \
576 die "enewuser failed" 579 die "enewuser failed"
577 else 580 else
634# Default values if you do not specify any: 637# Default values if you do not specify any:
635# groupname: REQUIRED ! 638# groupname: REQUIRED !
636# gid: next available (see groupadd(8)) 639# gid: next available (see groupadd(8))
637# extra: none 640# extra: none
638enewgroup() { 641enewgroup() {
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
639 # get the group 649 # get the group
640 local egroup="$1"; shift 650 local egroup="$1"; shift
641 if [ -z "${egroup}" ] 651 if [ -z "${egroup}" ]
642 then 652 then
643 eerror "No group specified !" 653 eerror "No group specified !"
705 esac 715 esac
706 dscl . create /groups/${egroup} gid ${egid} 716 dscl . create /groups/${egroup} gid ${egid}
707 dscl . create /groups/${egroup} passwd '*' 717 dscl . create /groups/${egroup} passwd '*'
708 ;; 718 ;;
709 719
710 *-freebsd*) 720 *-freebsd*|*-dragonfly*)
711 case ${egid} in 721 case ${egid} in
712 *[!0-9]*) # Non numeric 722 *[!0-9]*) # Non numeric
713 for egid in $(seq 101 999); do 723 for egid in $(seq 101 999); do
714 [ -z "`egetent group ${egid}`" ] && break 724 [ -z "`egetent group ${egid}`" ] && break
715 done 725 done
879 local desktop_name="${PN}" 889 local desktop_name="${PN}"
880 else 890 else
881 local desktop_name="${PN}-${SLOT}" 891 local desktop_name="${PN}-${SLOT}"
882 fi 892 fi
883 local desktop=${T}/${exec%% *}-${desktop_name}.desktop 893 local desktop=${T}/${exec%% *}-${desktop_name}.desktop
894# local desktop=${T}/${exec%% *:-${desktop_name}}.desktop
884 895
885echo "[Desktop Entry] 896echo "[Desktop Entry]
886Encoding=UTF-8 897Encoding=UTF-8
887Version=0.9.2 898Version=0.9.2
888Name=${name} 899Name=${name}
889Type=Application 900Type=Application
890Comment=${DESCRIPTION} 901Comment=${DESCRIPTION}
891Exec=${exec} 902Exec=${exec}
903TryExec=${exec}
892Path=${path} 904Path=${path}
893Icon=${icon} 905Icon=${icon}
894Categories=Application;${type};" > "${desktop}" 906Categories=Application;${type};" > "${desktop}"
895 907
896 ( 908 (
1407 echo 1419 echo
1408 einfo "If you are having trouble with the detection" 1420 einfo "If you are having trouble with the detection"
1409 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"
1410 einfo "Joliet support enabled in your kernel. Please" 1422 einfo "Joliet support enabled in your kernel. Please"
1411 einfo "check that CONFIG_JOLIET is enabled in your kernel." 1423 einfo "check that CONFIG_JOLIET is enabled in your kernel."
1412 read 1424 read || die "something is screwed with your system"
1413 done 1425 done
1414} 1426}
1415 1427
1416# Make sure that LINGUAS only contains languages that 1428# Make sure that LINGUAS only contains languages that
1417# a package can support 1429# a package can support
1427# directories and uses the union of the lists. 1439# directories and uses the union of the lists.
1428strip-linguas() { 1440strip-linguas() {
1429 local ls newls 1441 local ls newls
1430 if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then 1442 if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then
1431 local op=$1; shift 1443 local op=$1; shift
1432 ls=" $(find "$1" -name '*.po' -printf '%f ') "; shift 1444 ls=$(find "$1" -name '*.po' -exec basename {} .po \;); shift
1433 local d f 1445 local d f
1434 for d in "$@" ; do 1446 for d in "$@" ; do
1435 if [[ ${op} == "-u" ]] ; then 1447 if [[ ${op} == "-u" ]] ; then
1436 newls=${ls} 1448 newls=${ls}
1437 else 1449 else
1438 newls="" 1450 newls=""
1439 fi 1451 fi
1440 for f in $(find "$d" -name '*.po' -printf '%f ') ; do 1452 for f in $(find "$d" -name '*.po' -exec basename {} .po \;) ; do
1441 if [[ ${op} == "-i" ]] ; then 1453 if [[ ${op} == "-i" ]] ; then
1442 [[ ${ls/ ${f} /} != ${ls} ]] && newls="${newls} ${f}" 1454 hasq ${f} ${ls} && newls="${newls} ${f}"
1443 else 1455 else
1444 [[ ${ls/ ${f} /} == ${ls} ]] && newls="${newls} ${f}" 1456 hasq ${f} ${ls} || newls="${newls} ${f}"
1445 fi 1457 fi
1446 done 1458 done
1447 ls=${newls} 1459 ls=${newls}
1448 done 1460 done
1449 ls=${ls//.po}
1450 else 1461 else
1451 ls=$@ 1462 ls="$@"
1452 fi 1463 fi
1453 1464
1454 ls=" ${ls} "
1455 newls="" 1465 newls=""
1456 for f in ${LINGUAS} ; do 1466 for f in ${LINGUAS} ; do
1457 if [[ ${ls/ ${f} /} != ${ls} ]] ; then 1467 if hasq ${f} ${ls} ; then
1458 newls="${newls} ${f}" 1468 newls="${newls} ${f}"
1459 else 1469 else
1460 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" 1470 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA"
1461 fi 1471 fi
1462 done 1472 done
1463 if [[ -z ${newls} ]] ; then
1464 export LINGUAS=""
1465 else
1466 export LINGUAS=${newls:1} 1473 export LINGUAS=${newls:1}
1467 fi
1468} 1474}
1469 1475
1470# moved from kernel.eclass since they are generally useful outside of 1476# moved from kernel.eclass since they are generally useful outside of
1471# kernel.eclass -iggy (20041002) 1477# kernel.eclass -iggy (20041002)
1472 1478
1501 1507
1502# Jeremy Huddleston <eradicator@gentoo.org>: 1508# Jeremy Huddleston <eradicator@gentoo.org>:
1503# preserve_old_lib /path/to/libblah.so.0 1509# preserve_old_lib /path/to/libblah.so.0
1504# preserve_old_lib_notify /path/to/libblah.so.0 1510# preserve_old_lib_notify /path/to/libblah.so.0
1505# 1511#
1506# 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
1507# 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
1508# 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
1509# 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
1510# solution, so instead you can add the following to your ebuilds: 1516# solution, so instead you can add the following to your ebuilds:
1511# 1517#
1542 1548
1543 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."
1544 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"
1545 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,"
1546 ewarn "you will need to execute the following command:" 1552 ewarn "you will need to execute the following command:"
1547 ewarn " revdep-rebuild --soname ${SONAME}" 1553 ewarn " revdep-rebuild --library ${SONAME}"
1548 ewarn 1554 ewarn
1549 ewarn "After doing that, you can safely remove ${LIB}" 1555 ewarn "After doing that, you can safely remove ${LIB}"
1550 ewarn "Note: 'emerge gentoolkit' to get revdep-rebuild" 1556 ewarn "Note: 'emerge gentoolkit' to get revdep-rebuild"
1551 fi 1557 fi
1552} 1558}

Legend:
Removed from v.1.219  
changed lines
  Added in v.1.237

  ViewVC Help
Powered by ViewVC 1.1.20