/[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.100
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.100 2004/09/12 07:16:45 mr_bones_ 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# Sometimes you need to override the value returned by get_libdir. A good
68# example of this is xorg-x11, where lib32 isnt a supported configuration,
69# and where lib64 -must- be used on amd64 (for applications that need lib
70# to be 32bit, such as adobe acrobat). Note that this override also bypasses
71# portage version sanity checking.
72# get_libdir_override expects one argument, the result get_libdir should
73# return:
74#
75# get_libdir_override lib64
76#
77# Travis Tilley <lv@gentoo.org> (31 Aug 2004)
78get_libdir_override() {
79 CONF_LIBDIR="$1"
80 CONF_LIBDIR_OVERRIDE="$1"
81}
18 82
19# This function generate linker scripts in /usr/lib for dynamic 83# This function generate linker scripts in /usr/lib for dynamic
20# libs in /lib. This is to fix linking problems when you have 84# 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 85# 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 86# in some cases when linking dynamic, the .a in /usr/lib is used
33# to point to the latest version of the library present. 97# to point to the latest version of the library present.
34# 98#
35# <azarah@gentoo.org> (26 Oct 2002) 99# <azarah@gentoo.org> (26 Oct 2002)
36# 100#
37gen_usr_ldscript() { 101gen_usr_ldscript() {
38
39 # Just make sure it exists 102 # Just make sure it exists
40 dodir /usr/lib 103 dodir /usr/$(get_libdir)
41 104
42 cat > ${D}/usr/lib/$1 <<"END_LDSCRIPT" 105 cat > ${D}/usr/$(get_libdir)/$1 <<"END_LDSCRIPT"
43/* GNU ld script 106/* GNU ld script
44 Because Gentoo have critical dynamic libraries 107 Because Gentoo have critical dynamic libraries
45 in /lib, and the static versions in /usr/lib, we 108 in /lib, and the static versions in /usr/lib, we
46 need to have a "fake" dynamic lib in /usr/lib, 109 need to have a "fake" dynamic lib in /usr/lib,
47 otherwise we run into linking problems. 110 otherwise we run into linking problems.
48 See bug #4411 on http://bugs.gentoo.org/ for 111 See bug #4411 on http://bugs.gentoo.org/ for
49 more info. */ 112 more info. */
50GROUP ( /lib/libxxx )
51END_LDSCRIPT 113END_LDSCRIPT
52 114
115 echo "GROUP ( /$(get_libdir)/libxxx )" >> ${D}/usr/$(get_libdir)/$1
53 dosed "s:libxxx:$1:" /usr/lib/$1 116 dosed "s:libxxx:$1:" /usr/$(get_libdir)/$1
54 117
55 return 0 118 return 0
56} 119}
57 120
58# Simple function to draw a line consisting of '=' the same length as $* 121# Simple function to draw a line consisting of '=' the same length as $*
144 local SINGLE_PATCH="no" 207 local SINGLE_PATCH="no"
145 local x="" 208 local x=""
146 209
147 if [ "$#" -gt 1 ] 210 if [ "$#" -gt 1 ]
148 then 211 then
149 eerror "Invalid arguments to epatch()" 212 local m=""
150 die "Invalid arguments to epatch()" 213 einfo "${#} patches to apply..."
214 for m in "$@" ; do
215 epatch "${m}"
216 done
217 return 0
151 fi 218 fi
152 219
153 if [ -n "$1" -a -f "$1" ] 220 if [ -n "$1" -a -f "$1" ]
154 then 221 then
155 SINGLE_PATCH="yes" 222 SINGLE_PATCH="yes"
336# This function return true if we are using the NPTL pthreads 403# This function return true if we are using the NPTL pthreads
337# implementation. 404# implementation.
338# 405#
339# <azarah@gentoo.org> (06 March 2003) 406# <azarah@gentoo.org> (06 March 2003)
340# 407#
341
342have_NPTL() { 408have_NPTL() {
343
344 cat > ${T}/test-nptl.c <<-"END" 409 cat > ${T}/test-nptl.c <<-"END"
345 #define _XOPEN_SOURCE 410 #define _XOPEN_SOURCE
346 #include <unistd.h> 411 #include <unistd.h>
347 #include <stdio.h> 412 #include <stdio.h>
348 413
466# vapier@gentoo.org 531# vapier@gentoo.org
467# 532#
468# Takes just 1 parameter (the directory to create tmpfile in) 533# Takes just 1 parameter (the directory to create tmpfile in)
469mymktemp() { 534mymktemp() {
470 local topdir="$1" 535 local topdir="$1"
471 536
472 [ -z "${topdir}" ] && topdir=/tmp 537 [ -z "${topdir}" ] && topdir=/tmp
473 if [ "`which mktemp 2>/dev/null`" ] 538 if [ "`which mktemp 2>/dev/null`" ]
474 then 539 then
475 mktemp -p ${topdir} 540 mktemp -p ${topdir}
476 else 541 else
484# used in enewuser()/enewgroup() 549# used in enewuser()/enewgroup()
485# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 550# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
486# 551#
487# egetent(database, key) 552# egetent(database, key)
488egetent() { 553egetent() {
489 if [ "${ARCH}" == "macos" ] ; then 554 if [ "${ARCH}" == "macos" ] ; then
490 case "$2" in 555 case "$2" in
491 *[!0-9]*) # Non numeric 556 *[!0-9]*) # Non numeric
492 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 557 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
493 ;; 558 ;;
494 *) # Numeric 559 *) # Numeric
611 676
612 # handle extra and add the user 677 # handle extra and add the user
613 local eextra="$@" 678 local eextra="$@"
614 local oldsandbox="${SANDBOX_ON}" 679 local oldsandbox="${SANDBOX_ON}"
615 export SANDBOX_ON="0" 680 export SANDBOX_ON="0"
616 if [ "${ARCH}" == "macos" ]; 681 if [ "${ARCH}" == "macos" ];
617 then 682 then
618 ### Make the user 683 ### Make the user
619 if [ -z "${eextra}" ] 684 if [ -z "${eextra}" ]
620 then 685 then
621 dscl . create /users/${euser} uid ${euid} 686 dscl . create /users/${euser} uid ${euid}
714 opts="${opts} ${eextra}" 779 opts="${opts} ${eextra}"
715 780
716 # add the group 781 # add the group
717 local oldsandbox="${SANDBOX_ON}" 782 local oldsandbox="${SANDBOX_ON}"
718 export SANDBOX_ON="0" 783 export SANDBOX_ON="0"
719 if [ "${ARCH}" == "macos" ]; 784 if [ "${ARCH}" == "macos" ];
720 then 785 then
721 if [ ! -z "${eextra}" ]; 786 if [ ! -z "${eextra}" ];
722 then 787 then
723 einfo "Extra options are not supported on macos yet" 788 einfo "Extra options are not supported on macos yet"
724 einfo "Please report the ebuild along with the info below" 789 einfo "Please report the ebuild along with the info below"
725 einfo "eextra: ${eextra}" 790 einfo "eextra: ${eextra}"
726 die "Required function missing" 791 die "Required function missing"
727 fi 792 fi
728 793
729 # If we need the next available 794 # If we need the next available
730 case ${egid} in 795 case ${egid} in
731 *[!0-9]*) # Non numeric 796 *[!0-9]*) # Non numeric
732 for egid in `jot 898 101`; do 797 for egid in `jot 898 101`; do
733 [ -z "`egetent group ${egid}`" ] && break 798 [ -z "`egetent group ${egid}`" ] && break
734 done 799 done
735 esac 800 esac
736 dscl . create /groups/${egroup} gid ${egid} 801 dscl . create /groups/${egroup} gid ${egid}
737 dscl . create /groups/${egroup} passwd '*' 802 dscl . create /groups/${egroup} passwd '*'
738 else 803 else
739 groupadd ${opts} ${egroup} || die "enewgroup failed" 804 groupadd ${opts} ${egroup} || die "enewgroup failed"
740 fi 805 fi
741 export SANDBOX_ON="${oldsandbox}" 806 export SANDBOX_ON="${oldsandbox}"
742} 807}
776 local exec="${1}" 841 local exec="${1}"
777 local name="${2:-${PN}}" 842 local name="${2:-${PN}}"
778 local icon="${3:-${PN}.png}" 843 local icon="${3:-${PN}.png}"
779 local type="${4}" 844 local type="${4}"
780 local subdir="${6}" 845 local subdir="${6}"
781 local path="${5:-${GAMES_PREFIX}}" 846 local path="${5:-${GAMES_BINDIR}}"
782 if [ -z "${type}" ] 847 if [ -z "${type}" ]
783 then 848 then
784 case ${CATEGORY} in 849 case ${CATEGORY} in
785 "app-emulation") 850 "app-emulation")
786 type=Emulator 851 type=Emulator
809Type=Application 874Type=Application
810Comment=${DESCRIPTION} 875Comment=${DESCRIPTION}
811Exec=${exec} 876Exec=${exec}
812Path=${path} 877Path=${path}
813Icon=${icon} 878Icon=${icon}
814Categories=Application;${type};" > ${desktop} 879Categories=Application;${type};" > "${desktop}"
815 880
816 if [ -d "/usr/share/applications" ] 881 if [ -d "/usr/share/applications" ]
817 then 882 then
818 insinto /usr/share/applications 883 insinto /usr/share/applications
819 doins ${desktop} 884 doins "${desktop}"
820 fi 885 fi
821 886
822 #if [ -d "/usr/share/gnome/apps" ] 887 #if [ -d "/usr/share/gnome/apps" ]
823 #then 888 #then
824 # insinto /usr/share/gnome/apps/Games 889 # insinto /usr/share/gnome/apps/Games
835 #fi 900 #fi
836 901
837 if [ -d "/usr/share/applnk" ] 902 if [ -d "/usr/share/applnk" ]
838 then 903 then
839 insinto /usr/share/applnk/${subdir} 904 insinto /usr/share/applnk/${subdir}
840 doins ${desktop} 905 doins "${desktop}"
841 fi 906 fi
842 907
843 return 0 908 return 0
844} 909}
845 910
1016 tail -n +${skip} ${src} | bzip2 -dc | tar --no-same-owner -xf - 1081 tail -n +${skip} ${src} | bzip2 -dc | tar --no-same-owner -xf -
1017 ;; 1082 ;;
1018 gzip*) 1083 gzip*)
1019 tail -n +${skip} ${src} | tar --no-same-owner -xzf - 1084 tail -n +${skip} ${src} | tar --no-same-owner -xzf -
1020 ;; 1085 ;;
1086 compress*)
1087 tail -n +${skip} ${src} | gunzip | tar --no-same-owner -xf -
1088 ;;
1021 *) 1089 *)
1090 eerror "Unknown filetype \"${filetype}\" ?"
1022 false 1091 false
1023 ;; 1092 ;;
1024 esac 1093 esac
1025 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})" 1094 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
1026} 1095}
1247 read 1316 read
1248 fi 1317 fi
1249 done 1318 done
1250} 1319}
1251 1320
1252# Make sure that LINGUAS only contains languages that 1321# Make sure that LINGUAS only contains languages that
1253# a package can support 1322# a package can support
1254# 1323#
1255# usage: strip-linguas <allow LINGUAS> 1324# usage: strip-linguas <allow LINGUAS>
1256# strip-linguas -i <directories of .po files> 1325# strip-linguas -i <directories of .po files>
1257# strip-linguas -u <directories of .po files> 1326# strip-linguas -u <directories of .po files>
1258# 1327#
1259# The first form allows you to specify a list of LINGUAS. 1328# The first form allows you to specify a list of LINGUAS.
1260# The -i builds a list of po files found in all the 1329# The -i builds a list of po files found in all the
1261# directories and uses the intersection of the lists. 1330# directories and uses the intersection of the lists.
1262# The -u builds a list of po files found in all the 1331# The -u builds a list of po files found in all the
1263# directories and uses the union of the lists. 1332# directories and uses the union of the lists.
1264strip-linguas() { 1333strip-linguas() {
1265 local ls newls 1334 local ls newls
1266 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1335 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then
1267 local op="$1"; shift 1336 local op="$1"; shift

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

  ViewVC Help
Powered by ViewVC 1.1.20