/[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.101
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.101 2004/09/12 17:42:33 lv 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
34 CONF_LIBDIR="lib" 61 CONF_LIBDIR="lib"
35 fi 62 fi
36 # and of course, default to lib if CONF_LIBDIR isnt set 63 # and of course, default to lib if CONF_LIBDIR isnt set
37 echo ${CONF_LIBDIR:=lib} 64 echo ${CONF_LIBDIR:=lib}
38} 65}
66
67
68get_multilibdir() {
69 echo ${CONF_MULTILIBDIR:=lib32}
70}
71
39 72
40# Sometimes you need to override the value returned by get_libdir. A good 73# 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, 74# 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 75# 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 76# to be 32bit, such as adobe acrobat). Note that this override also bypasses
376# This function return true if we are using the NPTL pthreads 409# This function return true if we are using the NPTL pthreads
377# implementation. 410# implementation.
378# 411#
379# <azarah@gentoo.org> (06 March 2003) 412# <azarah@gentoo.org> (06 March 2003)
380# 413#
381
382have_NPTL() { 414have_NPTL() {
383
384 cat > ${T}/test-nptl.c <<-"END" 415 cat > ${T}/test-nptl.c <<-"END"
385 #define _XOPEN_SOURCE 416 #define _XOPEN_SOURCE
386 #include <unistd.h> 417 #include <unistd.h>
387 #include <stdio.h> 418 #include <stdio.h>
388 419
506# vapier@gentoo.org 537# vapier@gentoo.org
507# 538#
508# Takes just 1 parameter (the directory to create tmpfile in) 539# Takes just 1 parameter (the directory to create tmpfile in)
509mymktemp() { 540mymktemp() {
510 local topdir="$1" 541 local topdir="$1"
511 542
512 [ -z "${topdir}" ] && topdir=/tmp 543 [ -z "${topdir}" ] && topdir=/tmp
513 if [ "`which mktemp 2>/dev/null`" ] 544 if [ "`which mktemp 2>/dev/null`" ]
514 then 545 then
515 mktemp -p ${topdir} 546 mktemp -p ${topdir}
516 else 547 else
524# used in enewuser()/enewgroup() 555# used in enewuser()/enewgroup()
525# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 556# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
526# 557#
527# egetent(database, key) 558# egetent(database, key)
528egetent() { 559egetent() {
529 if [ "${ARCH}" == "macos" ] ; then 560 if [ "${ARCH}" == "macos" ] ; then
530 case "$2" in 561 case "$2" in
531 *[!0-9]*) # Non numeric 562 *[!0-9]*) # Non numeric
532 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 563 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
533 ;; 564 ;;
534 *) # Numeric 565 *) # Numeric
651 682
652 # handle extra and add the user 683 # handle extra and add the user
653 local eextra="$@" 684 local eextra="$@"
654 local oldsandbox="${SANDBOX_ON}" 685 local oldsandbox="${SANDBOX_ON}"
655 export SANDBOX_ON="0" 686 export SANDBOX_ON="0"
656 if [ "${ARCH}" == "macos" ]; 687 if [ "${ARCH}" == "macos" ];
657 then 688 then
658 ### Make the user 689 ### Make the user
659 if [ -z "${eextra}" ] 690 if [ -z "${eextra}" ]
660 then 691 then
661 dscl . create /users/${euser} uid ${euid} 692 dscl . create /users/${euser} uid ${euid}
754 opts="${opts} ${eextra}" 785 opts="${opts} ${eextra}"
755 786
756 # add the group 787 # add the group
757 local oldsandbox="${SANDBOX_ON}" 788 local oldsandbox="${SANDBOX_ON}"
758 export SANDBOX_ON="0" 789 export SANDBOX_ON="0"
759 if [ "${ARCH}" == "macos" ]; 790 if [ "${ARCH}" == "macos" ];
760 then 791 then
761 if [ ! -z "${eextra}" ]; 792 if [ ! -z "${eextra}" ];
762 then 793 then
763 einfo "Extra options are not supported on macos yet" 794 einfo "Extra options are not supported on macos yet"
764 einfo "Please report the ebuild along with the info below" 795 einfo "Please report the ebuild along with the info below"
765 einfo "eextra: ${eextra}" 796 einfo "eextra: ${eextra}"
766 die "Required function missing" 797 die "Required function missing"
767 fi 798 fi
768 799
769 # If we need the next available 800 # If we need the next available
770 case ${egid} in 801 case ${egid} in
771 *[!0-9]*) # Non numeric 802 *[!0-9]*) # Non numeric
772 for egid in `jot 898 101`; do 803 for egid in `jot 898 101`; do
773 [ -z "`egetent group ${egid}`" ] && break 804 [ -z "`egetent group ${egid}`" ] && break
774 done 805 done
775 esac 806 esac
776 dscl . create /groups/${egroup} gid ${egid} 807 dscl . create /groups/${egroup} gid ${egid}
777 dscl . create /groups/${egroup} passwd '*' 808 dscl . create /groups/${egroup} passwd '*'
778 else 809 else
779 groupadd ${opts} ${egroup} || die "enewgroup failed" 810 groupadd ${opts} ${egroup} || die "enewgroup failed"
780 fi 811 fi
781 export SANDBOX_ON="${oldsandbox}" 812 export SANDBOX_ON="${oldsandbox}"
782} 813}
816 local exec="${1}" 847 local exec="${1}"
817 local name="${2:-${PN}}" 848 local name="${2:-${PN}}"
818 local icon="${3:-${PN}.png}" 849 local icon="${3:-${PN}.png}"
819 local type="${4}" 850 local type="${4}"
820 local subdir="${6}" 851 local subdir="${6}"
821 local path="${5:-${GAMES_PREFIX}}" 852 local path="${5:-${GAMES_BINDIR}}"
822 if [ -z "${type}" ] 853 if [ -z "${type}" ]
823 then 854 then
824 case ${CATEGORY} in 855 case ${CATEGORY} in
825 "app-emulation") 856 "app-emulation")
826 type=Emulator 857 type=Emulator
849Type=Application 880Type=Application
850Comment=${DESCRIPTION} 881Comment=${DESCRIPTION}
851Exec=${exec} 882Exec=${exec}
852Path=${path} 883Path=${path}
853Icon=${icon} 884Icon=${icon}
854Categories=Application;${type};" > ${desktop} 885Categories=Application;${type};" > "${desktop}"
855 886
856 if [ -d "/usr/share/applications" ] 887 if [ -d "/usr/share/applications" ]
857 then 888 then
858 insinto /usr/share/applications 889 insinto /usr/share/applications
859 doins ${desktop} 890 doins "${desktop}"
860 fi 891 fi
861 892
862 #if [ -d "/usr/share/gnome/apps" ] 893 #if [ -d "/usr/share/gnome/apps" ]
863 #then 894 #then
864 # insinto /usr/share/gnome/apps/Games 895 # insinto /usr/share/gnome/apps/Games
875 #fi 906 #fi
876 907
877 if [ -d "/usr/share/applnk" ] 908 if [ -d "/usr/share/applnk" ]
878 then 909 then
879 insinto /usr/share/applnk/${subdir} 910 insinto /usr/share/applnk/${subdir}
880 doins ${desktop} 911 doins "${desktop}"
881 fi 912 fi
882 913
883 return 0 914 return 0
884} 915}
885 916
1291 read 1322 read
1292 fi 1323 fi
1293 done 1324 done
1294} 1325}
1295 1326
1296# Make sure that LINGUAS only contains languages that 1327# Make sure that LINGUAS only contains languages that
1297# a package can support 1328# a package can support
1298# 1329#
1299# usage: strip-linguas <allow LINGUAS> 1330# usage: strip-linguas <allow LINGUAS>
1300# strip-linguas -i <directories of .po files> 1331# strip-linguas -i <directories of .po files>
1301# strip-linguas -u <directories of .po files> 1332# strip-linguas -u <directories of .po files>
1302# 1333#
1303# The first form allows you to specify a list of LINGUAS. 1334# The first form allows you to specify a list of LINGUAS.
1304# The -i builds a list of po files found in all the 1335# The -i builds a list of po files found in all the
1305# directories and uses the intersection of the lists. 1336# directories and uses the intersection of the lists.
1306# The -u builds a list of po files found in all the 1337# The -u builds a list of po files found in all the
1307# directories and uses the union of the lists. 1338# directories and uses the union of the lists.
1308strip-linguas() { 1339strip-linguas() {
1309 local ls newls 1340 local ls newls
1310 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1341 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then
1311 local op="$1"; shift 1342 local op="$1"; shift

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

  ViewVC Help
Powered by ViewVC 1.1.20