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

Diff of /eclass/eutils.eclass

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

Revision 1.97 Revision 1.108
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.97 2004/08/31 09:05:24 lv Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.108 2004/10/01 19:23:58 ka0ttic 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}
18 45
19# This function simply returns the desired lib directory. With portage 46# This function simply returns the desired lib directory. With portage
20# 2.0.51, we now have support for installing libraries to lib32/lib64 47# 2.0.51, we now have support for installing libraries to lib32/lib64
21# to accomidate the needs of multilib systems. It's no longer a good idea 48# to accomidate the needs of multilib systems. It's no longer a good idea
22# to assume all libraries will end up in lib. Replace any (sane) instances 49# to assume all libraries will end up in lib. Replace any (sane) instances
23# where lib is named directly with $(get_libdir) if possible. 50# where lib is named directly with $(get_libdir) if possible.
24# 51#
25# Travis Tilley <lv@gentoo.org> (24 Aug 2004) 52# Travis Tilley <lv@gentoo.org> (24 Aug 2004)
26get_libdir() { 53get_libdir() {
54 LIBDIR_TEST=$(type econf)
27 if [ ! -z "${CONF_LIBDIR_OVERRIDE}" ] ; then 55 if [ ! -z "${CONF_LIBDIR_OVERRIDE}" ] ; then
28 # if there is an override, we want to use that... always. 56 # if there is an override, we want to use that... always.
29 CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}" 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
30 elif portageq has_version / '<sys-apps/portage-2.0.51_pre20' ; then 61 #elif portageq has_version / '<sys-apps/portage-2.0.51_pre20' ; then
31 # and if there isnt an override, and we're using a version of 62 # # and if there isnt an override, and we're using a version of
32 # portage without CONF_LIBDIR support, force the use of lib. dolib 63 # # portage without CONF_LIBDIR support, force the use of lib. dolib
33 # and friends from portage 2.0.50 wont be too happy otherwise. 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
34 CONF_LIBDIR="lib" 69 CONF_LIBDIR="lib"
35 fi 70 fi
36 # and of course, default to lib if CONF_LIBDIR isnt set 71 # and of course, default to lib if CONF_LIBDIR isnt set
37 echo ${CONF_LIBDIR:=lib} 72 echo ${CONF_LIBDIR:=lib}
73 unset LIBDIR_TEST
38} 74}
75
76
77get_multilibdir() {
78 echo ${CONF_MULTILIBDIR:=lib32}
79}
80
39 81
40# Sometimes you need to override the value returned by get_libdir. A good 82# Sometimes you need to override the value returned by get_libdir. A good
41# example of this is xorg-x11, where lib32 isnt a supported configuration, 83# example of this is xorg-x11, where lib32 isnt a supported configuration,
42# and where lib64 -must- be used on amd64 (for applications that need lib 84# and where lib64 -must- be used on amd64 (for applications that need lib
43# to be 32bit, such as adobe acrobat). Note that this override also bypasses 85# to be 32bit, such as adobe acrobat). Note that this override also bypasses
73# 115#
74gen_usr_ldscript() { 116gen_usr_ldscript() {
75 # Just make sure it exists 117 # Just make sure it exists
76 dodir /usr/$(get_libdir) 118 dodir /usr/$(get_libdir)
77 119
78 cat > ${D}/usr/$(get_libdir)/$1 <<"END_LDSCRIPT" 120 cat > "${D}/usr/$(get_libdir)/$1" << END_LDSCRIPT
79/* GNU ld script 121/* GNU ld script
80 Because Gentoo have critical dynamic libraries 122 Because Gentoo have critical dynamic libraries
81 in /lib, and the static versions in /usr/lib, we 123 in /lib, and the static versions in /usr/lib, we
82 need to have a "fake" dynamic lib in /usr/lib, 124 need to have a "fake" dynamic lib in /usr/lib,
83 otherwise we run into linking problems. 125 otherwise we run into linking problems.
84 See bug #4411 on http://bugs.gentoo.org/ for 126 See bug #4411 on http://bugs.gentoo.org/ for
85 more info. */ 127 more info. */
128GROUP ( /$(get_libdir)/$1 )
86END_LDSCRIPT 129END_LDSCRIPT
87
88 echo "GROUP ( /$(get_libdir)/libxxx )" >> ${D}/usr/$(get_libdir)/$1
89 dosed "s:libxxx:$1:" /usr/$(get_libdir)/$1
90
91 return 0
92} 130}
93 131
94# 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 $*
95# 133#
96# <azarah@gentoo.org> (11 Nov 2002) 134# <azarah@gentoo.org> (11 Nov 2002)
376# This function return true if we are using the NPTL pthreads 414# This function return true if we are using the NPTL pthreads
377# implementation. 415# implementation.
378# 416#
379# <azarah@gentoo.org> (06 March 2003) 417# <azarah@gentoo.org> (06 March 2003)
380# 418#
381
382have_NPTL() { 419have_NPTL() {
383
384 cat > ${T}/test-nptl.c <<-"END" 420 cat > ${T}/test-nptl.c <<-"END"
385 #define _XOPEN_SOURCE 421 #define _XOPEN_SOURCE
386 #include <unistd.h> 422 #include <unistd.h>
387 #include <stdio.h> 423 #include <stdio.h>
388 424
506# vapier@gentoo.org 542# vapier@gentoo.org
507# 543#
508# Takes just 1 parameter (the directory to create tmpfile in) 544# Takes just 1 parameter (the directory to create tmpfile in)
509mymktemp() { 545mymktemp() {
510 local topdir="$1" 546 local topdir="$1"
511 547
512 [ -z "${topdir}" ] && topdir=/tmp 548 [ -z "${topdir}" ] && topdir=/tmp
513 if [ "`which mktemp 2>/dev/null`" ] 549 if [ "`which mktemp 2>/dev/null`" ]
514 then 550 then
515 mktemp -p ${topdir} 551 mktemp -p ${topdir}
516 else 552 else
518 touch ${tmp} 554 touch ${tmp}
519 echo ${tmp} 555 echo ${tmp}
520 fi 556 fi
521} 557}
522 558
523# Small wrapper for getent (Linux) and nidump (Mac OS X) 559# Small wrapper for getent (Linux), nidump (Mac OS X),
524# used in enewuser()/enewgroup() 560# and pw (FreeBSD) used in enewuser()/enewgroup()
525# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 561# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
562# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
526# 563#
527# egetent(database, key) 564# egetent(database, key)
528egetent() { 565egetent() {
529 if [ "${ARCH}" == "macos" ] ; then 566 if use macos || use ppc-macos ; then
530 case "$2" in 567 case "$2" in
531 *[!0-9]*) # Non numeric 568 *[!0-9]*) # Non numeric
532 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 569 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
533 ;; 570 ;;
534 *) # Numeric 571 *) # Numeric
535 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" 572 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
536 ;; 573 ;;
537 esac 574 esac
575 elif useq x86-fbsd ; then
576 local action
577 if [ "$1" == "passwd" ]
578 then
579 action="user"
538 else 580 else
581 action="group"
582 fi
583 pw show "${action}" "$2" -q
584 else
539 getent $1 $2 585 getent "$1" "$2"
540 fi 586 fi
541} 587}
542 588
543# Simplify/standardize adding users to the system 589# Simplify/standardize adding users to the system
544# vapier@gentoo.org 590# vapier@gentoo.org
590 euid="next" 636 euid="next"
591 fi 637 fi
592 if [ "${euid}" == "next" ] 638 if [ "${euid}" == "next" ]
593 then 639 then
594 local pwrange 640 local pwrange
595 if [ "${ARCH}" == "macos" ] ; then 641 if use macos || use ppc-macos || [ "${USERLAND}" == "BSD" ] ; then
596 pwrange="`jot 898 101`" 642 pwrange="`jot 898 101`"
597 else 643 else
598 pwrange="`seq 101 999`" 644 pwrange="`seq 101 999`"
599 fi 645 fi
600 for euid in ${pwrange} ; do 646 for euid in ${pwrange} ; do
612 then 658 then
613 eerror "A shell was specified but it does not exist !" 659 eerror "A shell was specified but it does not exist !"
614 die "${eshell} does not exist" 660 die "${eshell} does not exist"
615 fi 661 fi
616 else 662 else
663 if [ "${USERLAND}" == "BSD" ]
664 then
665 eshell="/usr/bin/false"
666 else
617 eshell="/bin/false" 667 eshell="/bin/false"
668 fi
618 fi 669 fi
619 einfo " - Shell: ${eshell}" 670 einfo " - Shell: ${eshell}"
620 opts="${opts} -s ${eshell}" 671 opts="${opts} -s ${eshell}"
621 672
622 # handle homedir 673 # handle homedir
631 # handle groups 682 # handle groups
632 local egroups="$1"; shift 683 local egroups="$1"; shift
633 if [ ! -z "${egroups}" ] 684 if [ ! -z "${egroups}" ]
634 then 685 then
635 local oldifs="${IFS}" 686 local oldifs="${IFS}"
687 local defgroup="" exgroups=""
688
636 export IFS="," 689 export IFS=","
637 for g in ${egroups} 690 for g in ${egroups}
638 do 691 do
639 if [ -z "`egetent group \"${g}\"`" ] 692 if [ -z "`egetent group \"${g}\"`" ]
640 then 693 then
641 eerror "You must add group ${g} to the system first" 694 eerror "You must add group ${g} to the system first"
642 die "${g} is not a valid GID" 695 die "${g} is not a valid GID"
643 fi 696 fi
697 if [ -z "${defgroup}" ]
698 then
699 defgroup="${g}"
700 else
701 exgroups="${exgroups},${g}"
702 fi
644 done 703 done
645 export IFS="${oldifs}" 704 export IFS="${oldifs}"
705
646 opts="${opts} -g ${egroups}" 706 opts="${opts} -g ${defgroup}"
707 if [ ! -z "${exgroups}" ]
708 then
709 opts="${opts} -G ${exgroups:1}"
710 fi
647 else 711 else
648 egroups="(none)" 712 egroups="(none)"
649 fi 713 fi
650 einfo " - Groups: ${egroups}" 714 einfo " - Groups: ${egroups}"
651 715
652 # handle extra and add the user 716 # handle extra and add the user
653 local eextra="$@" 717 local eextra="$@"
654 local oldsandbox="${SANDBOX_ON}" 718 local oldsandbox="${SANDBOX_ON}"
655 export SANDBOX_ON="0" 719 export SANDBOX_ON="0"
656 if [ "${ARCH}" == "macos" ]; 720 if use macos || use ppc-macos ;
657 then 721 then
658 ### Make the user 722 ### Make the user
659 if [ -z "${eextra}" ] 723 if [ -z "${eextra}" ]
660 then 724 then
661 dscl . create /users/${euser} uid ${euid} 725 dscl . create /users/${euser} uid ${euid}
663 dscl . create /users/${euser} home ${ehome} 727 dscl . create /users/${euser} home ${ehome}
664 dscl . create /users/${euser} realname "added by portage for ${PN}" 728 dscl . create /users/${euser} realname "added by portage for ${PN}"
665 ### Add the user to the groups specified 729 ### Add the user to the groups specified
666 for g in ${egroups} 730 for g in ${egroups}
667 do 731 do
732 # $egroups is , delimited, not space
733 ewarn "This is code is wrong; someone on the OS X team should fix it"
668 dscl . merge /groups/${g} users ${euser} 734 dscl . merge /groups/${g} users ${euser}
669 done 735 done
670 else 736 else
671 einfo "Extra options are not supported on macos yet" 737 einfo "Extra options are not supported on macos yet"
672 einfo "Please report the ebuild along with the info below" 738 einfo "Please report the ebuild along with the info below"
673 einfo "eextra: ${eextra}" 739 einfo "eextra: ${eextra}"
674 die "Required function missing" 740 die "Required function missing"
741 fi
742 elif use x86-fbsd ; then
743 if [ -z "${eextra}" ]
744 then
745 pw useradd ${euser} ${opts} \
746 -c "added by portage for ${PN}" \
747 die "enewuser failed"
748 else
749 einfo " - Extra: ${eextra}"
750 pw useradd ${euser} ${opts} \
751 -c ${eextra} || die "enewuser failed"
675 fi 752 fi
676 else 753 else
677 if [ -z "${eextra}" ] 754 if [ -z "${eextra}" ]
678 then 755 then
679 useradd ${opts} ${euser} \ 756 useradd ${opts} ${euser} \
730 then 807 then
731 if [ "${egid}" -gt 0 ] 808 if [ "${egid}" -gt 0 ]
732 then 809 then
733 if [ -z "`egetent group ${egid}`" ] 810 if [ -z "`egetent group ${egid}`" ]
734 then 811 then
735 if [ "${ARCH}" == "macos" ] ; then 812 if use macos || use ppc-macos ; then
736 opts="${opts} ${egid}" 813 opts="${opts} ${egid}"
737 else 814 else
738 opts="${opts} -g ${egid}" 815 opts="${opts} -g ${egid}"
739 fi 816 fi
740 else 817 else
754 opts="${opts} ${eextra}" 831 opts="${opts} ${eextra}"
755 832
756 # add the group 833 # add the group
757 local oldsandbox="${SANDBOX_ON}" 834 local oldsandbox="${SANDBOX_ON}"
758 export SANDBOX_ON="0" 835 export SANDBOX_ON="0"
759 if [ "${ARCH}" == "macos" ]; 836 if use macos || use ppc-macos ;
760 then 837 then
761 if [ ! -z "${eextra}" ]; 838 if [ ! -z "${eextra}" ];
762 then 839 then
763 einfo "Extra options are not supported on macos yet" 840 einfo "Extra options are not supported on macos yet"
764 einfo "Please report the ebuild along with the info below" 841 einfo "Please report the ebuild along with the info below"
765 einfo "eextra: ${eextra}" 842 einfo "eextra: ${eextra}"
766 die "Required function missing" 843 die "Required function missing"
767 fi 844 fi
768 845
769 # If we need the next available 846 # If we need the next available
770 case ${egid} in 847 case ${egid} in
771 *[!0-9]*) # Non numeric 848 *[!0-9]*) # Non numeric
772 for egid in `jot 898 101`; do 849 for egid in `jot 898 101`; do
773 [ -z "`egetent group ${egid}`" ] && break 850 [ -z "`egetent group ${egid}`" ] && break
774 done 851 done
775 esac 852 esac
776 dscl . create /groups/${egroup} gid ${egid} 853 dscl . create /groups/${egroup} gid ${egid}
777 dscl . create /groups/${egroup} passwd '*' 854 dscl . create /groups/${egroup} passwd '*'
855 elif use x86-fbsd ; then
856 case ${egid} in
857 *[!0-9]*) # Non numeric
858 for egid in `jot 898 101`; do
859 [ -z "`egetent group ${egid}`" ] && break
860 done
861 esac
862 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
778 else 863 else
779 groupadd ${opts} ${egroup} || die "enewgroup failed" 864 groupadd ${opts} ${egroup} || die "enewgroup failed"
780 fi 865 fi
781 export SANDBOX_ON="${oldsandbox}" 866 export SANDBOX_ON="${oldsandbox}"
782} 867}
816 local exec="${1}" 901 local exec="${1}"
817 local name="${2:-${PN}}" 902 local name="${2:-${PN}}"
818 local icon="${3:-${PN}.png}" 903 local icon="${3:-${PN}.png}"
819 local type="${4}" 904 local type="${4}"
820 local subdir="${6}" 905 local subdir="${6}"
821 local path="${5:-${GAMES_PREFIX}}" 906 local path="${5:-${GAMES_BINDIR}}"
822 if [ -z "${type}" ] 907 if [ -z "${type}" ]
823 then 908 then
824 case ${CATEGORY} in 909 case ${CATEGORY} in
825 "app-emulation") 910 "app-emulation")
826 type=Emulator 911 type=Emulator
849Type=Application 934Type=Application
850Comment=${DESCRIPTION} 935Comment=${DESCRIPTION}
851Exec=${exec} 936Exec=${exec}
852Path=${path} 937Path=${path}
853Icon=${icon} 938Icon=${icon}
854Categories=Application;${type};" > ${desktop} 939Categories=Application;${type};" > "${desktop}"
855 940
856 if [ -d "/usr/share/applications" ] 941 if [ -d "/usr/share/applications" ]
857 then 942 then
858 insinto /usr/share/applications 943 insinto /usr/share/applications
859 doins ${desktop} 944 doins "${desktop}"
860 fi 945 fi
861 946
862 #if [ -d "/usr/share/gnome/apps" ] 947 #if [ -d "/usr/share/gnome/apps" ]
863 #then 948 #then
864 # insinto /usr/share/gnome/apps/Games 949 # insinto /usr/share/gnome/apps/Games
875 #fi 960 #fi
876 961
877 if [ -d "/usr/share/applnk" ] 962 if [ -d "/usr/share/applnk" ]
878 then 963 then
879 insinto /usr/share/applnk/${subdir} 964 insinto /usr/share/applnk/${subdir}
880 doins ${desktop} 965 doins "${desktop}"
881 fi 966 fi
882 967
883 return 0 968 return 0
884} 969}
885 970
1089 [ ! -f "${lic}" ] && die "Could not find requested license ${src}" 1174 [ ! -f "${lic}" ] && die "Could not find requested license ${src}"
1090 local l="`basename ${lic}`" 1175 local l="`basename ${lic}`"
1091 1176
1092 # here is where we check for the licenses the user already 1177 # here is where we check for the licenses the user already
1093 # accepted ... if we don't find a match, we make the user accept 1178 # accepted ... if we don't find a match, we make the user accept
1179 local shopts=$-
1094 local alic 1180 local alic
1181 set -o noglob #so that bash doesn't expand "*"
1095 for alic in "${ACCEPT_LICENSE}" ; do 1182 for alic in ${ACCEPT_LICENSE} ; do
1096 [ "${alic}" == "*" ] && return 0 1183 if [[ ${alic} == * || ${alic} == ${l} ]]; then
1097 [ "${alic}" == "${l}" ] && return 0 1184 set +o noglob; set -${shopts} #reset old shell opts
1185 return 0
1186 fi
1098 done 1187 done
1188 set +o noglob; set -$shopts #reset old shell opts
1099 1189
1100 local licmsg="`mymktemp ${T}`" 1190 local licmsg="`mymktemp ${T}`"
1101 cat << EOF > ${licmsg} 1191 cat << EOF > ${licmsg}
1102********************************************************** 1192**********************************************************
1103The following license outlines the terms of use of this 1193The following license outlines the terms of use of this
1291 read 1381 read
1292 fi 1382 fi
1293 done 1383 done
1294} 1384}
1295 1385
1296# Make sure that LINGUAS only contains languages that 1386# Make sure that LINGUAS only contains languages that
1297# a package can support 1387# a package can support
1298# 1388#
1299# usage: strip-linguas <allow LINGUAS> 1389# usage: strip-linguas <allow LINGUAS>
1300# strip-linguas -i <directories of .po files> 1390# strip-linguas -i <directories of .po files>
1301# strip-linguas -u <directories of .po files> 1391# strip-linguas -u <directories of .po files>
1302# 1392#
1303# The first form allows you to specify a list of LINGUAS. 1393# The first form allows you to specify a list of LINGUAS.
1304# The -i builds a list of po files found in all the 1394# The -i builds a list of po files found in all the
1305# directories and uses the intersection of the lists. 1395# directories and uses the intersection of the lists.
1306# The -u builds a list of po files found in all the 1396# The -u builds a list of po files found in all the
1307# directories and uses the union of the lists. 1397# directories and uses the union of the lists.
1308strip-linguas() { 1398strip-linguas() {
1309 local ls newls 1399 local ls newls
1310 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1400 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then
1311 local op="$1"; shift 1401 local op="$1"; shift

Legend:
Removed from v.1.97  
changed lines
  Added in v.1.108

  ViewVC Help
Powered by ViewVC 1.1.20