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

Diff of /eclass/eutils.eclass

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

Revision 1.95 Revision 1.107
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 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.95 2004/08/15 03:25:19 lv Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.107 2004/09/29 15:16:42 vapier Exp $
4# 4#
5# Author: Martin Schlemmer <azarah@gentoo.org> 5# Author: Martin Schlemmer <azarah@gentoo.org>
6# 6#
7# This eclass is for general purpose functions that most ebuilds 7# This eclass is for general purpose functions that most ebuilds
8# have to implement themselves. 8# have to implement themselves.
13INHERITED="$INHERITED $ECLASS" 13INHERITED="$INHERITED $ECLASS"
14 14
15DEPEND="!bootstrap? ( sys-devel/patch )" 15DEPEND="!bootstrap? ( sys-devel/patch )"
16 16
17DESCRIPTION="Based on the ${ECLASS} eclass" 17DESCRIPTION="Based on the ${ECLASS} eclass"
18
19# Wait for the supplied number of seconds. If no argument is supplied, defaults
20# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not
21# outputting to a terminal, don't wait. For compatability purposes, the argument
22# must be an integer greater than zero.
23# Bug 62950, Ciaran McCreesh <ciaranm@gentoo.org> (05 Sep 2004)
24epause() {
25 if [ -z "$EPAUSE_IGNORE" ] && [ -t 1 ] ; then
26 sleep ${1:-5}
27 fi
28}
29
30# Beep the specified number of times (defaults to five). If our output
31# is not a terminal, don't beep. If the EBEEP_IGNORE env var is set,
32# don't beep.
33# Bug 62950, Ciaran McCreesh <ciaranm@gentoo.org> (05 Sep 2004)
34ebeep() {
35 local n
36 if [ -z "$EBEEP_IGNORE" ] && [ -t 1 ] ; then
37 for ((n=1 ; n <= ${1:-5} ; n++)) ; do
38 echo -ne "\a"
39 sleep 0.1 &>/dev/null ; sleep 0,1 &>/dev/null
40 echo -ne "\a"
41 sleep 1
42 done
43 fi
44}
45
46# This function simply returns the desired lib directory. With portage
47# 2.0.51, we now have support for installing libraries to lib32/lib64
48# to accomidate the needs of multilib systems. It's no longer a good idea
49# to assume all libraries will end up in lib. Replace any (sane) instances
50# where lib is named directly with $(get_libdir) if possible.
51#
52# Travis Tilley <lv@gentoo.org> (24 Aug 2004)
53get_libdir() {
54 LIBDIR_TEST=$(type econf)
55 if [ ! -z "${CONF_LIBDIR_OVERRIDE}" ] ; then
56 # if there is an override, we want to use that... always.
57 CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}"
58 # We don't need to know the verison of portage. We only need to know
59 # if there is support for CONF_LIBDIR in econf and co.
60 # Danny van Dyk <kugelfang@gentoo.org> 2004/17/09
61 #elif portageq has_version / '<sys-apps/portage-2.0.51_pre20' ; then
62 # # and if there isnt an override, and we're using a version of
63 # # portage without CONF_LIBDIR support, force the use of lib. dolib
64 # # and friends from portage 2.0.50 wont be too happy otherwise.
65 # CONF_LIBDIR="lib"
66 #fi
67 elif [ "${LIBDIR_TEST/CONF_LIBDIR}" == "${LIBDIR_TEST}" ]; then # we don't have CONF_LIBDIR support
68 # will be <portage-2.0.51_pre20
69 CONF_LIBDIR="lib"
70 fi
71 # and of course, default to lib if CONF_LIBDIR isnt set
72 echo ${CONF_LIBDIR:=lib}
73 unset LIBDIR_TEST
74}
75
76
77get_multilibdir() {
78 echo ${CONF_MULTILIBDIR:=lib32}
79}
80
81
82# Sometimes you need to override the value returned by get_libdir. A good
83# example of this is xorg-x11, where lib32 isnt a supported configuration,
84# and where lib64 -must- be used on amd64 (for applications that need lib
85# to be 32bit, such as adobe acrobat). Note that this override also bypasses
86# portage version sanity checking.
87# get_libdir_override expects one argument, the result get_libdir should
88# return:
89#
90# get_libdir_override lib64
91#
92# Travis Tilley <lv@gentoo.org> (31 Aug 2004)
93get_libdir_override() {
94 CONF_LIBDIR="$1"
95 CONF_LIBDIR_OVERRIDE="$1"
96}
18 97
19# This function generate linker scripts in /usr/lib for dynamic 98# This function generate linker scripts in /usr/lib for dynamic
20# libs in /lib. This is to fix linking problems when you have 99# libs in /lib. This is to fix linking problems when you have
21# the .so in /lib, and the .a in /usr/lib. What happens is that 100# the .so in /lib, and the .a in /usr/lib. What happens is that
22# in some cases when linking dynamic, the .a in /usr/lib is used 101# in some cases when linking dynamic, the .a in /usr/lib is used
33# to point to the latest version of the library present. 112# to point to the latest version of the library present.
34# 113#
35# <azarah@gentoo.org> (26 Oct 2002) 114# <azarah@gentoo.org> (26 Oct 2002)
36# 115#
37gen_usr_ldscript() { 116gen_usr_ldscript() {
38 # this adds support for installing to lib64/lib32. since only portage
39 # 2.0.51 will have this functionality supported in dolib and friends,
40 # and since it isnt expected that many profiles will define it, we need
41 # to make this variable default to lib.
42 [ -z "${CONF_LIBDIR}" ] && CONF_LIBDIR="lib"
43
44 # Just make sure it exists 117 # Just make sure it exists
45 dodir /usr/${CONF_LIBDIR} 118 dodir /usr/$(get_libdir)
46 119
47 cat > ${D}/usr/${CONF_LIBDIR}/$1 <<"END_LDSCRIPT" 120 cat > "${D}/usr/$(get_libdir)/$1" << END_LDSCRIPT
48/* GNU ld script 121/* GNU ld script
49 Because Gentoo have critical dynamic libraries 122 Because Gentoo have critical dynamic libraries
50 in /lib, and the static versions in /usr/lib, we 123 in /lib, and the static versions in /usr/lib, we
51 need to have a "fake" dynamic lib in /usr/lib, 124 need to have a "fake" dynamic lib in /usr/lib,
52 otherwise we run into linking problems. 125 otherwise we run into linking problems.
53 See bug #4411 on http://bugs.gentoo.org/ for 126 See bug #4411 on http://bugs.gentoo.org/ for
54 more info. */ 127 more info. */
128GROUP ( /$(get_libdir)/$1 )
55END_LDSCRIPT 129END_LDSCRIPT
56
57 echo "GROUP ( /${CONF_LIBDIR}/libxxx )" >> ${D}/usr/${CONF_LIBDIR}/$1
58 dosed "s:libxxx:$1:" /usr/${CONF_LIBDIR}/$1
59
60 return 0
61} 130}
62 131
63# Simple function to draw a line consisting of '=' the same length as $* 132# Simple function to draw a line consisting of '=' the same length as $*
64# 133#
65# <azarah@gentoo.org> (11 Nov 2002) 134# <azarah@gentoo.org> (11 Nov 2002)
345# This function return true if we are using the NPTL pthreads 414# This function return true if we are using the NPTL pthreads
346# implementation. 415# implementation.
347# 416#
348# <azarah@gentoo.org> (06 March 2003) 417# <azarah@gentoo.org> (06 March 2003)
349# 418#
350
351have_NPTL() { 419have_NPTL() {
352
353 cat > ${T}/test-nptl.c <<-"END" 420 cat > ${T}/test-nptl.c <<-"END"
354 #define _XOPEN_SOURCE 421 #define _XOPEN_SOURCE
355 #include <unistd.h> 422 #include <unistd.h>
356 #include <stdio.h> 423 #include <stdio.h>
357 424
475# vapier@gentoo.org 542# vapier@gentoo.org
476# 543#
477# Takes just 1 parameter (the directory to create tmpfile in) 544# Takes just 1 parameter (the directory to create tmpfile in)
478mymktemp() { 545mymktemp() {
479 local topdir="$1" 546 local topdir="$1"
480 547
481 [ -z "${topdir}" ] && topdir=/tmp 548 [ -z "${topdir}" ] && topdir=/tmp
482 if [ "`which mktemp 2>/dev/null`" ] 549 if [ "`which mktemp 2>/dev/null`" ]
483 then 550 then
484 mktemp -p ${topdir} 551 mktemp -p ${topdir}
485 else 552 else
493# used in enewuser()/enewgroup() 560# used in enewuser()/enewgroup()
494# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 561# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
495# 562#
496# egetent(database, key) 563# egetent(database, key)
497egetent() { 564egetent() {
498 if [ "${ARCH}" == "macos" ] ; then 565 if use macos || use ppc-macos ; then
499 case "$2" in 566 case "$2" in
500 *[!0-9]*) # Non numeric 567 *[!0-9]*) # Non numeric
501 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 568 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
502 ;; 569 ;;
503 *) # Numeric 570 *) # Numeric
504 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" 571 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
505 ;; 572 ;;
506 esac 573 esac
507 else 574 else
508 getent $1 $2 575 getent "$1" "$2"
509 fi 576 fi
510} 577}
511 578
512# Simplify/standardize adding users to the system 579# Simplify/standardize adding users to the system
513# vapier@gentoo.org 580# vapier@gentoo.org
559 euid="next" 626 euid="next"
560 fi 627 fi
561 if [ "${euid}" == "next" ] 628 if [ "${euid}" == "next" ]
562 then 629 then
563 local pwrange 630 local pwrange
564 if [ "${ARCH}" == "macos" ] ; then 631 if use macos || use ppc-macos ; then
565 pwrange="`jot 898 101`" 632 pwrange="`jot 898 101`"
566 else 633 else
567 pwrange="`seq 101 999`" 634 pwrange="`seq 101 999`"
568 fi 635 fi
569 for euid in ${pwrange} ; do 636 for euid in ${pwrange} ; do
600 # handle groups 667 # handle groups
601 local egroups="$1"; shift 668 local egroups="$1"; shift
602 if [ ! -z "${egroups}" ] 669 if [ ! -z "${egroups}" ]
603 then 670 then
604 local oldifs="${IFS}" 671 local oldifs="${IFS}"
672 local defgroup="" exgroups=""
673
605 export IFS="," 674 export IFS=","
606 for g in ${egroups} 675 for g in ${egroups}
607 do 676 do
608 if [ -z "`egetent group \"${g}\"`" ] 677 if [ -z "`egetent group \"${g}\"`" ]
609 then 678 then
610 eerror "You must add group ${g} to the system first" 679 eerror "You must add group ${g} to the system first"
611 die "${g} is not a valid GID" 680 die "${g} is not a valid GID"
612 fi 681 fi
682 if [ -z "${defgroup}" ]
683 then
684 defgroup="${g}"
685 else
686 exgroups="${exgroups},${g}"
687 fi
613 done 688 done
614 export IFS="${oldifs}" 689 export IFS="${oldifs}"
690
615 opts="${opts} -g ${egroups}" 691 opts="${opts} -g ${defgroup}"
692 if [ ! -z "${exgroups}" ]
693 then
694 opts="${opts} -G ${exgroups:1}"
695 fi
616 else 696 else
617 egroups="(none)" 697 egroups="(none)"
618 fi 698 fi
619 einfo " - Groups: ${egroups}" 699 einfo " - Groups: ${egroups}"
620 700
621 # handle extra and add the user 701 # handle extra and add the user
622 local eextra="$@" 702 local eextra="$@"
623 local oldsandbox="${SANDBOX_ON}" 703 local oldsandbox="${SANDBOX_ON}"
624 export SANDBOX_ON="0" 704 export SANDBOX_ON="0"
625 if [ "${ARCH}" == "macos" ]; 705 if use macos || use ppc-macos ;
626 then 706 then
627 ### Make the user 707 ### Make the user
628 if [ -z "${eextra}" ] 708 if [ -z "${eextra}" ]
629 then 709 then
630 dscl . create /users/${euser} uid ${euid} 710 dscl . create /users/${euser} uid ${euid}
632 dscl . create /users/${euser} home ${ehome} 712 dscl . create /users/${euser} home ${ehome}
633 dscl . create /users/${euser} realname "added by portage for ${PN}" 713 dscl . create /users/${euser} realname "added by portage for ${PN}"
634 ### Add the user to the groups specified 714 ### Add the user to the groups specified
635 for g in ${egroups} 715 for g in ${egroups}
636 do 716 do
717 # $egroups is , delimited, not space
718 ewarn "This is code is wrong; someone on the OS X team should fix it"
637 dscl . merge /groups/${g} users ${euser} 719 dscl . merge /groups/${g} users ${euser}
638 done 720 done
639 else 721 else
640 einfo "Extra options are not supported on macos yet" 722 einfo "Extra options are not supported on macos yet"
641 einfo "Please report the ebuild along with the info below" 723 einfo "Please report the ebuild along with the info below"
699 then 781 then
700 if [ "${egid}" -gt 0 ] 782 if [ "${egid}" -gt 0 ]
701 then 783 then
702 if [ -z "`egetent group ${egid}`" ] 784 if [ -z "`egetent group ${egid}`" ]
703 then 785 then
704 if [ "${ARCH}" == "macos" ] ; then 786 if use macos || use ppc-macos ; then
705 opts="${opts} ${egid}" 787 opts="${opts} ${egid}"
706 else 788 else
707 opts="${opts} -g ${egid}" 789 opts="${opts} -g ${egid}"
708 fi 790 fi
709 else 791 else
723 opts="${opts} ${eextra}" 805 opts="${opts} ${eextra}"
724 806
725 # add the group 807 # add the group
726 local oldsandbox="${SANDBOX_ON}" 808 local oldsandbox="${SANDBOX_ON}"
727 export SANDBOX_ON="0" 809 export SANDBOX_ON="0"
728 if [ "${ARCH}" == "macos" ]; 810 if use macos || use ppc-macos ;
729 then 811 then
730 if [ ! -z "${eextra}" ]; 812 if [ ! -z "${eextra}" ];
731 then 813 then
732 einfo "Extra options are not supported on macos yet" 814 einfo "Extra options are not supported on macos yet"
733 einfo "Please report the ebuild along with the info below" 815 einfo "Please report the ebuild along with the info below"
734 einfo "eextra: ${eextra}" 816 einfo "eextra: ${eextra}"
735 die "Required function missing" 817 die "Required function missing"
736 fi 818 fi
737 819
738 # If we need the next available 820 # If we need the next available
739 case ${egid} in 821 case ${egid} in
740 *[!0-9]*) # Non numeric 822 *[!0-9]*) # Non numeric
741 for egid in `jot 898 101`; do 823 for egid in `jot 898 101`; do
742 [ -z "`egetent group ${egid}`" ] && break 824 [ -z "`egetent group ${egid}`" ] && break
743 done 825 done
744 esac 826 esac
745 dscl . create /groups/${egroup} gid ${egid} 827 dscl . create /groups/${egroup} gid ${egid}
746 dscl . create /groups/${egroup} passwd '*' 828 dscl . create /groups/${egroup} passwd '*'
747 else 829 else
748 groupadd ${opts} ${egroup} || die "enewgroup failed" 830 groupadd ${opts} ${egroup} || die "enewgroup failed"
749 fi 831 fi
750 export SANDBOX_ON="${oldsandbox}" 832 export SANDBOX_ON="${oldsandbox}"
751} 833}
785 local exec="${1}" 867 local exec="${1}"
786 local name="${2:-${PN}}" 868 local name="${2:-${PN}}"
787 local icon="${3:-${PN}.png}" 869 local icon="${3:-${PN}.png}"
788 local type="${4}" 870 local type="${4}"
789 local subdir="${6}" 871 local subdir="${6}"
790 local path="${5:-${GAMES_PREFIX}}" 872 local path="${5:-${GAMES_BINDIR}}"
791 if [ -z "${type}" ] 873 if [ -z "${type}" ]
792 then 874 then
793 case ${CATEGORY} in 875 case ${CATEGORY} in
794 "app-emulation") 876 "app-emulation")
795 type=Emulator 877 type=Emulator
818Type=Application 900Type=Application
819Comment=${DESCRIPTION} 901Comment=${DESCRIPTION}
820Exec=${exec} 902Exec=${exec}
821Path=${path} 903Path=${path}
822Icon=${icon} 904Icon=${icon}
823Categories=Application;${type};" > ${desktop} 905Categories=Application;${type};" > "${desktop}"
824 906
825 if [ -d "/usr/share/applications" ] 907 if [ -d "/usr/share/applications" ]
826 then 908 then
827 insinto /usr/share/applications 909 insinto /usr/share/applications
828 doins ${desktop} 910 doins "${desktop}"
829 fi 911 fi
830 912
831 #if [ -d "/usr/share/gnome/apps" ] 913 #if [ -d "/usr/share/gnome/apps" ]
832 #then 914 #then
833 # insinto /usr/share/gnome/apps/Games 915 # insinto /usr/share/gnome/apps/Games
844 #fi 926 #fi
845 927
846 if [ -d "/usr/share/applnk" ] 928 if [ -d "/usr/share/applnk" ]
847 then 929 then
848 insinto /usr/share/applnk/${subdir} 930 insinto /usr/share/applnk/${subdir}
849 doins ${desktop} 931 doins "${desktop}"
850 fi 932 fi
851 933
852 return 0 934 return 0
853} 935}
854 936
1058 [ ! -f "${lic}" ] && die "Could not find requested license ${src}" 1140 [ ! -f "${lic}" ] && die "Could not find requested license ${src}"
1059 local l="`basename ${lic}`" 1141 local l="`basename ${lic}`"
1060 1142
1061 # here is where we check for the licenses the user already 1143 # here is where we check for the licenses the user already
1062 # accepted ... if we don't find a match, we make the user accept 1144 # accepted ... if we don't find a match, we make the user accept
1145 local shopts=$-
1063 local alic 1146 local alic
1147 set -o noglob #so that bash doesn't expand "*"
1064 for alic in "${ACCEPT_LICENSE}" ; do 1148 for alic in ${ACCEPT_LICENSE} ; do
1065 [ "${alic}" == "*" ] && return 0 1149 if [[ ${alic} == * || ${alic} == ${l} ]]; then
1066 [ "${alic}" == "${l}" ] && return 0 1150 set +o noglob; set -${shopts} #reset old shell opts
1151 return 0
1152 fi
1067 done 1153 done
1154 set +o noglob; set -$shopts #reset old shell opts
1068 1155
1069 local licmsg="`mymktemp ${T}`" 1156 local licmsg="`mymktemp ${T}`"
1070 cat << EOF > ${licmsg} 1157 cat << EOF > ${licmsg}
1071********************************************************** 1158**********************************************************
1072The following license outlines the terms of use of this 1159The following license outlines the terms of use of this
1260 read 1347 read
1261 fi 1348 fi
1262 done 1349 done
1263} 1350}
1264 1351
1265# Make sure that LINGUAS only contains languages that 1352# Make sure that LINGUAS only contains languages that
1266# a package can support 1353# a package can support
1267# 1354#
1268# usage: strip-linguas <allow LINGUAS> 1355# usage: strip-linguas <allow LINGUAS>
1269# strip-linguas -i <directories of .po files> 1356# strip-linguas -i <directories of .po files>
1270# strip-linguas -u <directories of .po files> 1357# strip-linguas -u <directories of .po files>
1271# 1358#
1272# The first form allows you to specify a list of LINGUAS. 1359# The first form allows you to specify a list of LINGUAS.
1273# The -i builds a list of po files found in all the 1360# The -i builds a list of po files found in all the
1274# directories and uses the intersection of the lists. 1361# directories and uses the intersection of the lists.
1275# The -u builds a list of po files found in all the 1362# The -u builds a list of po files found in all the
1276# directories and uses the union of the lists. 1363# directories and uses the union of the lists.
1277strip-linguas() { 1364strip-linguas() {
1278 local ls newls 1365 local ls newls
1279 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1366 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then
1280 local op="$1"; shift 1367 local op="$1"; shift

Legend:
Removed from v.1.95  
changed lines
  Added in v.1.107

  ViewVC Help
Powered by ViewVC 1.1.20