/[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.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.92 2004/08/03 17:24:52 vapier 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}
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 if [ ! -z "${CONF_LIBDIR_OVERRIDE}" ] ; then
55 # if there is an override, we want to use that... always.
56 CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}"
57 elif portageq has_version / '<sys-apps/portage-2.0.51_pre20' ; then
58 # and if there isnt an override, and we're using a version of
59 # portage without CONF_LIBDIR support, force the use of lib. dolib
60 # and friends from portage 2.0.50 wont be too happy otherwise.
61 CONF_LIBDIR="lib"
62 fi
63 # and of course, default to lib if CONF_LIBDIR isnt set
64 echo ${CONF_LIBDIR:=lib}
65}
66
67
68get_multilibdir() {
69 echo ${CONF_MULTILIBDIR:=lib32}
70}
71
72
73# Sometimes you need to override the value returned by get_libdir. A good
74# example of this is xorg-x11, where lib32 isnt a supported configuration,
75# and where lib64 -must- be used on amd64 (for applications that need lib
76# to be 32bit, such as adobe acrobat). Note that this override also bypasses
77# portage version sanity checking.
78# get_libdir_override expects one argument, the result get_libdir should
79# return:
80#
81# get_libdir_override lib64
82#
83# Travis Tilley <lv@gentoo.org> (31 Aug 2004)
84get_libdir_override() {
85 CONF_LIBDIR="$1"
86 CONF_LIBDIR_OVERRIDE="$1"
87}
18 88
19# This function generate linker scripts in /usr/lib for dynamic 89# This function generate linker scripts in /usr/lib for dynamic
20# libs in /lib. This is to fix linking problems when you have 90# 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 91# 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 92# in some cases when linking dynamic, the .a in /usr/lib is used
33# to point to the latest version of the library present. 103# to point to the latest version of the library present.
34# 104#
35# <azarah@gentoo.org> (26 Oct 2002) 105# <azarah@gentoo.org> (26 Oct 2002)
36# 106#
37gen_usr_ldscript() { 107gen_usr_ldscript() {
38
39 # Just make sure it exists 108 # Just make sure it exists
40 dodir /usr/lib 109 dodir /usr/$(get_libdir)
41 110
42 cat > ${D}/usr/lib/$1 <<"END_LDSCRIPT" 111 cat > ${D}/usr/$(get_libdir)/$1 <<"END_LDSCRIPT"
43/* GNU ld script 112/* GNU ld script
44 Because Gentoo have critical dynamic libraries 113 Because Gentoo have critical dynamic libraries
45 in /lib, and the static versions in /usr/lib, we 114 in /lib, and the static versions in /usr/lib, we
46 need to have a "fake" dynamic lib in /usr/lib, 115 need to have a "fake" dynamic lib in /usr/lib,
47 otherwise we run into linking problems. 116 otherwise we run into linking problems.
48 See bug #4411 on http://bugs.gentoo.org/ for 117 See bug #4411 on http://bugs.gentoo.org/ for
49 more info. */ 118 more info. */
50GROUP ( /lib/libxxx )
51END_LDSCRIPT 119END_LDSCRIPT
52 120
121 echo "GROUP ( /$(get_libdir)/libxxx )" >> ${D}/usr/$(get_libdir)/$1
53 dosed "s:libxxx:$1:" /usr/lib/$1 122 dosed "s:libxxx:$1:" /usr/$(get_libdir)/$1
54 123
55 return 0 124 return 0
56} 125}
57 126
58# Simple function to draw a line consisting of '=' the same length as $* 127# Simple function to draw a line consisting of '=' the same length as $*
144 local SINGLE_PATCH="no" 213 local SINGLE_PATCH="no"
145 local x="" 214 local x=""
146 215
147 if [ "$#" -gt 1 ] 216 if [ "$#" -gt 1 ]
148 then 217 then
149 eerror "Invalid arguments to epatch()" 218 local m=""
150 die "Invalid arguments to epatch()" 219 einfo "${#} patches to apply..."
220 for m in "$@" ; do
221 epatch "${m}"
222 done
223 return 0
151 fi 224 fi
152 225
153 if [ -n "$1" -a -f "$1" ] 226 if [ -n "$1" -a -f "$1" ]
154 then 227 then
155 SINGLE_PATCH="yes" 228 SINGLE_PATCH="yes"
336# This function return true if we are using the NPTL pthreads 409# This function return true if we are using the NPTL pthreads
337# implementation. 410# implementation.
338# 411#
339# <azarah@gentoo.org> (06 March 2003) 412# <azarah@gentoo.org> (06 March 2003)
340# 413#
341
342have_NPTL() { 414have_NPTL() {
343
344 cat > ${T}/test-nptl.c <<-"END" 415 cat > ${T}/test-nptl.c <<-"END"
345 #define _XOPEN_SOURCE 416 #define _XOPEN_SOURCE
346 #include <unistd.h> 417 #include <unistd.h>
347 #include <stdio.h> 418 #include <stdio.h>
348 419
466# vapier@gentoo.org 537# vapier@gentoo.org
467# 538#
468# Takes just 1 parameter (the directory to create tmpfile in) 539# Takes just 1 parameter (the directory to create tmpfile in)
469mymktemp() { 540mymktemp() {
470 local topdir="$1" 541 local topdir="$1"
471 542
472 [ -z "${topdir}" ] && topdir=/tmp 543 [ -z "${topdir}" ] && topdir=/tmp
473 if [ "`which mktemp 2>/dev/null`" ] 544 if [ "`which mktemp 2>/dev/null`" ]
474 then 545 then
475 mktemp -p ${topdir} 546 mktemp -p ${topdir}
476 else 547 else
484# used in enewuser()/enewgroup() 555# used in enewuser()/enewgroup()
485# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 556# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
486# 557#
487# egetent(database, key) 558# egetent(database, key)
488egetent() { 559egetent() {
489 if [ "${ARCH}" == "macos" ] ; then 560 if [ "${ARCH}" == "macos" ] ; then
490 case "$2" in 561 case "$2" in
491 *[!0-9]*) # Non numeric 562 *[!0-9]*) # Non numeric
492 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 563 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
493 ;; 564 ;;
494 *) # Numeric 565 *) # Numeric
611 682
612 # handle extra and add the user 683 # handle extra and add the user
613 local eextra="$@" 684 local eextra="$@"
614 local oldsandbox="${SANDBOX_ON}" 685 local oldsandbox="${SANDBOX_ON}"
615 export SANDBOX_ON="0" 686 export SANDBOX_ON="0"
616 if [ "${ARCH}" == "macos" ]; 687 if [ "${ARCH}" == "macos" ];
617 then 688 then
618 ### Make the user 689 ### Make the user
619 if [ -z "${eextra}" ] 690 if [ -z "${eextra}" ]
620 then 691 then
621 dscl . create /users/${euser} uid ${euid} 692 dscl . create /users/${euser} uid ${euid}
714 opts="${opts} ${eextra}" 785 opts="${opts} ${eextra}"
715 786
716 # add the group 787 # add the group
717 local oldsandbox="${SANDBOX_ON}" 788 local oldsandbox="${SANDBOX_ON}"
718 export SANDBOX_ON="0" 789 export SANDBOX_ON="0"
719 if [ "${ARCH}" == "macos" ]; 790 if [ "${ARCH}" == "macos" ];
720 then 791 then
721 if [ ! -z "${eextra}" ]; 792 if [ ! -z "${eextra}" ];
722 then 793 then
723 einfo "Extra options are not supported on macos yet" 794 einfo "Extra options are not supported on macos yet"
724 einfo "Please report the ebuild along with the info below" 795 einfo "Please report the ebuild along with the info below"
725 einfo "eextra: ${eextra}" 796 einfo "eextra: ${eextra}"
726 die "Required function missing" 797 die "Required function missing"
727 fi 798 fi
728 799
729 # If we need the next available 800 # If we need the next available
730 case ${egid} in 801 case ${egid} in
731 *[!0-9]*) # Non numeric 802 *[!0-9]*) # Non numeric
732 for egid in `jot 898 101`; do 803 for egid in `jot 898 101`; do
733 [ -z "`egetent group ${egid}`" ] && break 804 [ -z "`egetent group ${egid}`" ] && break
734 done 805 done
735 esac 806 esac
736 dscl . create /groups/${egroup} gid ${egid} 807 dscl . create /groups/${egroup} gid ${egid}
737 dscl . create /groups/${egroup} passwd '*' 808 dscl . create /groups/${egroup} passwd '*'
738 else 809 else
739 groupadd ${opts} ${egroup} || die "enewgroup failed" 810 groupadd ${opts} ${egroup} || die "enewgroup failed"
740 fi 811 fi
741 export SANDBOX_ON="${oldsandbox}" 812 export SANDBOX_ON="${oldsandbox}"
742} 813}
776 local exec="${1}" 847 local exec="${1}"
777 local name="${2:-${PN}}" 848 local name="${2:-${PN}}"
778 local icon="${3:-${PN}.png}" 849 local icon="${3:-${PN}.png}"
779 local type="${4}" 850 local type="${4}"
780 local subdir="${6}" 851 local subdir="${6}"
781 local path="${5:-${GAMES_PREFIX}}" 852 local path="${5:-${GAMES_BINDIR}}"
782 if [ -z "${type}" ] 853 if [ -z "${type}" ]
783 then 854 then
784 case ${CATEGORY} in 855 case ${CATEGORY} in
785 "app-emulation") 856 "app-emulation")
786 type=Emulator 857 type=Emulator
809Type=Application 880Type=Application
810Comment=${DESCRIPTION} 881Comment=${DESCRIPTION}
811Exec=${exec} 882Exec=${exec}
812Path=${path} 883Path=${path}
813Icon=${icon} 884Icon=${icon}
814Categories=Application;${type};" > ${desktop} 885Categories=Application;${type};" > "${desktop}"
815 886
816 if [ -d "/usr/share/applications" ] 887 if [ -d "/usr/share/applications" ]
817 then 888 then
818 insinto /usr/share/applications 889 insinto /usr/share/applications
819 doins ${desktop} 890 doins "${desktop}"
820 fi 891 fi
821 892
822 #if [ -d "/usr/share/gnome/apps" ] 893 #if [ -d "/usr/share/gnome/apps" ]
823 #then 894 #then
824 # insinto /usr/share/gnome/apps/Games 895 # insinto /usr/share/gnome/apps/Games
835 #fi 906 #fi
836 907
837 if [ -d "/usr/share/applnk" ] 908 if [ -d "/usr/share/applnk" ]
838 then 909 then
839 insinto /usr/share/applnk/${subdir} 910 insinto /usr/share/applnk/${subdir}
840 doins ${desktop} 911 doins "${desktop}"
841 fi 912 fi
842 913
843 return 0 914 return 0
844} 915}
845 916
1016 tail -n +${skip} ${src} | bzip2 -dc | tar --no-same-owner -xf - 1087 tail -n +${skip} ${src} | bzip2 -dc | tar --no-same-owner -xf -
1017 ;; 1088 ;;
1018 gzip*) 1089 gzip*)
1019 tail -n +${skip} ${src} | tar --no-same-owner -xzf - 1090 tail -n +${skip} ${src} | tar --no-same-owner -xzf -
1020 ;; 1091 ;;
1092 compress*)
1093 tail -n +${skip} ${src} | gunzip | tar --no-same-owner -xf -
1094 ;;
1021 *) 1095 *)
1096 eerror "Unknown filetype \"${filetype}\" ?"
1022 false 1097 false
1023 ;; 1098 ;;
1024 esac 1099 esac
1025 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})" 1100 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
1026} 1101}
1247 read 1322 read
1248 fi 1323 fi
1249 done 1324 done
1250} 1325}
1251 1326
1252# Make sure that LINGUAS only contains languages that 1327# Make sure that LINGUAS only contains languages that
1253# a package can support 1328# a package can support
1254# 1329#
1255# usage: strip-linguas <allow LINGUAS> 1330# usage: strip-linguas <allow LINGUAS>
1256# strip-linguas -i <directories of .po files> 1331# strip-linguas -i <directories of .po files>
1257# strip-linguas -u <directories of .po files> 1332# strip-linguas -u <directories of .po files>
1258# 1333#
1259# The first form allows you to specify a list of LINGUAS. 1334# The first form allows you to specify a list of LINGUAS.
1260# 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
1261# directories and uses the intersection of the lists. 1336# directories and uses the intersection of the lists.
1262# 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
1263# directories and uses the union of the lists. 1338# directories and uses the union of the lists.
1264strip-linguas() { 1339strip-linguas() {
1265 local ls newls 1340 local ls newls
1266 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1341 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then
1267 local op="$1"; shift 1342 local op="$1"; shift

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

  ViewVC Help
Powered by ViewVC 1.1.20