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

Diff of /eclass/eutils.eclass

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

Revision 1.92 Revision 1.103
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.92 2004/08/03 17:24:52 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.103 2004/09/17 10:37:58 kugelfang 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
39 # Just make sure it exists 117 # Just make sure it exists
40 dodir /usr/lib 118 dodir /usr/$(get_libdir)
41 119
42 cat > ${D}/usr/lib/$1 <<"END_LDSCRIPT" 120 cat > ${D}/usr/$(get_libdir)/$1 <<"END_LDSCRIPT"
43/* GNU ld script 121/* GNU ld script
44 Because Gentoo have critical dynamic libraries 122 Because Gentoo have critical dynamic libraries
45 in /lib, and the static versions in /usr/lib, we 123 in /lib, and the static versions in /usr/lib, we
46 need to have a "fake" dynamic lib in /usr/lib, 124 need to have a "fake" dynamic lib in /usr/lib,
47 otherwise we run into linking problems. 125 otherwise we run into linking problems.
48 See bug #4411 on http://bugs.gentoo.org/ for 126 See bug #4411 on http://bugs.gentoo.org/ for
49 more info. */ 127 more info. */
50GROUP ( /lib/libxxx )
51END_LDSCRIPT 128END_LDSCRIPT
52 129
130 echo "GROUP ( /$(get_libdir)/libxxx )" >> ${D}/usr/$(get_libdir)/$1
53 dosed "s:libxxx:$1:" /usr/lib/$1 131 dosed "s:libxxx:$1:" /usr/$(get_libdir)/$1
54 132
55 return 0 133 return 0
56} 134}
57 135
58# Simple function to draw a line consisting of '=' the same length as $* 136# Simple function to draw a line consisting of '=' the same length as $*
144 local SINGLE_PATCH="no" 222 local SINGLE_PATCH="no"
145 local x="" 223 local x=""
146 224
147 if [ "$#" -gt 1 ] 225 if [ "$#" -gt 1 ]
148 then 226 then
149 eerror "Invalid arguments to epatch()" 227 local m=""
150 die "Invalid arguments to epatch()" 228 einfo "${#} patches to apply..."
229 for m in "$@" ; do
230 epatch "${m}"
231 done
232 return 0
151 fi 233 fi
152 234
153 if [ -n "$1" -a -f "$1" ] 235 if [ -n "$1" -a -f "$1" ]
154 then 236 then
155 SINGLE_PATCH="yes" 237 SINGLE_PATCH="yes"
336# This function return true if we are using the NPTL pthreads 418# This function return true if we are using the NPTL pthreads
337# implementation. 419# implementation.
338# 420#
339# <azarah@gentoo.org> (06 March 2003) 421# <azarah@gentoo.org> (06 March 2003)
340# 422#
341
342have_NPTL() { 423have_NPTL() {
343
344 cat > ${T}/test-nptl.c <<-"END" 424 cat > ${T}/test-nptl.c <<-"END"
345 #define _XOPEN_SOURCE 425 #define _XOPEN_SOURCE
346 #include <unistd.h> 426 #include <unistd.h>
347 #include <stdio.h> 427 #include <stdio.h>
348 428
466# vapier@gentoo.org 546# vapier@gentoo.org
467# 547#
468# Takes just 1 parameter (the directory to create tmpfile in) 548# Takes just 1 parameter (the directory to create tmpfile in)
469mymktemp() { 549mymktemp() {
470 local topdir="$1" 550 local topdir="$1"
471 551
472 [ -z "${topdir}" ] && topdir=/tmp 552 [ -z "${topdir}" ] && topdir=/tmp
473 if [ "`which mktemp 2>/dev/null`" ] 553 if [ "`which mktemp 2>/dev/null`" ]
474 then 554 then
475 mktemp -p ${topdir} 555 mktemp -p ${topdir}
476 else 556 else
484# used in enewuser()/enewgroup() 564# used in enewuser()/enewgroup()
485# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 565# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
486# 566#
487# egetent(database, key) 567# egetent(database, key)
488egetent() { 568egetent() {
489 if [ "${ARCH}" == "macos" ] ; then 569 if use macos || use ppc-macos ; then
490 case "$2" in 570 case "$2" in
491 *[!0-9]*) # Non numeric 571 *[!0-9]*) # Non numeric
492 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 572 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
493 ;; 573 ;;
494 *) # Numeric 574 *) # Numeric
550 euid="next" 630 euid="next"
551 fi 631 fi
552 if [ "${euid}" == "next" ] 632 if [ "${euid}" == "next" ]
553 then 633 then
554 local pwrange 634 local pwrange
555 if [ "${ARCH}" == "macos" ] ; then 635 if use macos || use ppc-macos ; then
556 pwrange="`jot 898 101`" 636 pwrange="`jot 898 101`"
557 else 637 else
558 pwrange="`seq 101 999`" 638 pwrange="`seq 101 999`"
559 fi 639 fi
560 for euid in ${pwrange} ; do 640 for euid in ${pwrange} ; do
611 691
612 # handle extra and add the user 692 # handle extra and add the user
613 local eextra="$@" 693 local eextra="$@"
614 local oldsandbox="${SANDBOX_ON}" 694 local oldsandbox="${SANDBOX_ON}"
615 export SANDBOX_ON="0" 695 export SANDBOX_ON="0"
616 if [ "${ARCH}" == "macos" ]; 696 if use macos || use ppc-macos ;
617 then 697 then
618 ### Make the user 698 ### Make the user
619 if [ -z "${eextra}" ] 699 if [ -z "${eextra}" ]
620 then 700 then
621 dscl . create /users/${euser} uid ${euid} 701 dscl . create /users/${euser} uid ${euid}
690 then 770 then
691 if [ "${egid}" -gt 0 ] 771 if [ "${egid}" -gt 0 ]
692 then 772 then
693 if [ -z "`egetent group ${egid}`" ] 773 if [ -z "`egetent group ${egid}`" ]
694 then 774 then
695 if [ "${ARCH}" == "macos" ] ; then 775 if use macos || use ppc-macos ; then
696 opts="${opts} ${egid}" 776 opts="${opts} ${egid}"
697 else 777 else
698 opts="${opts} -g ${egid}" 778 opts="${opts} -g ${egid}"
699 fi 779 fi
700 else 780 else
714 opts="${opts} ${eextra}" 794 opts="${opts} ${eextra}"
715 795
716 # add the group 796 # add the group
717 local oldsandbox="${SANDBOX_ON}" 797 local oldsandbox="${SANDBOX_ON}"
718 export SANDBOX_ON="0" 798 export SANDBOX_ON="0"
719 if [ "${ARCH}" == "macos" ]; 799 if use macos || use ppc-macos ;
720 then 800 then
721 if [ ! -z "${eextra}" ]; 801 if [ ! -z "${eextra}" ];
722 then 802 then
723 einfo "Extra options are not supported on macos yet" 803 einfo "Extra options are not supported on macos yet"
724 einfo "Please report the ebuild along with the info below" 804 einfo "Please report the ebuild along with the info below"
725 einfo "eextra: ${eextra}" 805 einfo "eextra: ${eextra}"
726 die "Required function missing" 806 die "Required function missing"
727 fi 807 fi
728 808
729 # If we need the next available 809 # If we need the next available
730 case ${egid} in 810 case ${egid} in
731 *[!0-9]*) # Non numeric 811 *[!0-9]*) # Non numeric
732 for egid in `jot 898 101`; do 812 for egid in `jot 898 101`; do
733 [ -z "`egetent group ${egid}`" ] && break 813 [ -z "`egetent group ${egid}`" ] && break
734 done 814 done
735 esac 815 esac
736 dscl . create /groups/${egroup} gid ${egid} 816 dscl . create /groups/${egroup} gid ${egid}
737 dscl . create /groups/${egroup} passwd '*' 817 dscl . create /groups/${egroup} passwd '*'
738 else 818 else
739 groupadd ${opts} ${egroup} || die "enewgroup failed" 819 groupadd ${opts} ${egroup} || die "enewgroup failed"
740 fi 820 fi
741 export SANDBOX_ON="${oldsandbox}" 821 export SANDBOX_ON="${oldsandbox}"
742} 822}
776 local exec="${1}" 856 local exec="${1}"
777 local name="${2:-${PN}}" 857 local name="${2:-${PN}}"
778 local icon="${3:-${PN}.png}" 858 local icon="${3:-${PN}.png}"
779 local type="${4}" 859 local type="${4}"
780 local subdir="${6}" 860 local subdir="${6}"
781 local path="${5:-${GAMES_PREFIX}}" 861 local path="${5:-${GAMES_BINDIR}}"
782 if [ -z "${type}" ] 862 if [ -z "${type}" ]
783 then 863 then
784 case ${CATEGORY} in 864 case ${CATEGORY} in
785 "app-emulation") 865 "app-emulation")
786 type=Emulator 866 type=Emulator
809Type=Application 889Type=Application
810Comment=${DESCRIPTION} 890Comment=${DESCRIPTION}
811Exec=${exec} 891Exec=${exec}
812Path=${path} 892Path=${path}
813Icon=${icon} 893Icon=${icon}
814Categories=Application;${type};" > ${desktop} 894Categories=Application;${type};" > "${desktop}"
815 895
816 if [ -d "/usr/share/applications" ] 896 if [ -d "/usr/share/applications" ]
817 then 897 then
818 insinto /usr/share/applications 898 insinto /usr/share/applications
819 doins ${desktop} 899 doins "${desktop}"
820 fi 900 fi
821 901
822 #if [ -d "/usr/share/gnome/apps" ] 902 #if [ -d "/usr/share/gnome/apps" ]
823 #then 903 #then
824 # insinto /usr/share/gnome/apps/Games 904 # insinto /usr/share/gnome/apps/Games
835 #fi 915 #fi
836 916
837 if [ -d "/usr/share/applnk" ] 917 if [ -d "/usr/share/applnk" ]
838 then 918 then
839 insinto /usr/share/applnk/${subdir} 919 insinto /usr/share/applnk/${subdir}
840 doins ${desktop} 920 doins "${desktop}"
841 fi 921 fi
842 922
843 return 0 923 return 0
844} 924}
845 925
1016 tail -n +${skip} ${src} | bzip2 -dc | tar --no-same-owner -xf - 1096 tail -n +${skip} ${src} | bzip2 -dc | tar --no-same-owner -xf -
1017 ;; 1097 ;;
1018 gzip*) 1098 gzip*)
1019 tail -n +${skip} ${src} | tar --no-same-owner -xzf - 1099 tail -n +${skip} ${src} | tar --no-same-owner -xzf -
1020 ;; 1100 ;;
1101 compress*)
1102 tail -n +${skip} ${src} | gunzip | tar --no-same-owner -xf -
1103 ;;
1021 *) 1104 *)
1105 eerror "Unknown filetype \"${filetype}\" ?"
1022 false 1106 false
1023 ;; 1107 ;;
1024 esac 1108 esac
1025 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})" 1109 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
1026} 1110}
1247 read 1331 read
1248 fi 1332 fi
1249 done 1333 done
1250} 1334}
1251 1335
1252# Make sure that LINGUAS only contains languages that 1336# Make sure that LINGUAS only contains languages that
1253# a package can support 1337# a package can support
1254# 1338#
1255# usage: strip-linguas <allow LINGUAS> 1339# usage: strip-linguas <allow LINGUAS>
1256# strip-linguas -i <directories of .po files> 1340# strip-linguas -i <directories of .po files>
1257# strip-linguas -u <directories of .po files> 1341# strip-linguas -u <directories of .po files>
1258# 1342#
1259# The first form allows you to specify a list of LINGUAS. 1343# The first form allows you to specify a list of LINGUAS.
1260# The -i builds a list of po files found in all the 1344# The -i builds a list of po files found in all the
1261# directories and uses the intersection of the lists. 1345# directories and uses the intersection of the lists.
1262# The -u builds a list of po files found in all the 1346# The -u builds a list of po files found in all the
1263# directories and uses the union of the lists. 1347# directories and uses the union of the lists.
1264strip-linguas() { 1348strip-linguas() {
1265 local ls newls 1349 local ls newls
1266 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1350 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then
1267 local op="$1"; shift 1351 local op="$1"; shift

Legend:
Removed from v.1.92  
changed lines
  Added in v.1.103

  ViewVC Help
Powered by ViewVC 1.1.20