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

Diff of /eclass/eutils.eclass

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

Revision 1.282 Revision 1.283
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 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.282 2007/06/16 07:11:43 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.283 2007/06/16 08:03:28 vapier Exp $
4# 4
5# This eclass is for general purpose functions that most ebuilds 5# @ECLASS: eutils.eclass
6# have to implement themselves. 6# @MAINTAINER:
7# 7# base-system@gentoo.org
8# NB: If you add anything, please comment it! 8# @BLURB: many extra (but common) functions that are used in ebuilds
9# 9# @DESCRIPTION:
10# Maintainer: see each individual function, base-system@gentoo.org as default 10# The eutils eclass contains a suite of functions that complement
11# the ones that ebuild.sh already contain. The idea is that the functions
12# are not required in all ebuilds but enough utilize them to have a common
13# home rather than having multiple ebuilds implementing the same thing.
14#
15# Due to the nature of this eclass, some functions may have maintainers
16# different from the overall eclass!
11 17
12inherit multilib portability 18inherit multilib portability
13 19
14DESCRIPTION="Based on the ${ECLASS} eclass" 20DESCRIPTION="Based on the ${ECLASS} eclass"
15 21
16# Wait for the supplied number of seconds. If no argument is supplied, defaults 22# @FUNCTION: epause
17# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not 23# @USAGE: [seconds]
18# outputting to a terminal, don't wait. For compatability purposes, the argument 24# @DESCRIPTION:
19# must be an integer greater than zero. 25# Sleep for the specified number of seconds (default of 5 seconds). Useful when
20# Bug 62950, Ciaran McCreesh <ciaranm@gentoo.org> (05 Sep 2004) 26# printing a message the user should probably be reading and often used in
27# conjunction with the ebeep function. If the EPAUSE_IGNORE env var is set,
28# don't wait at all.
21epause() { 29epause() {
22 [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5} 30 [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
23} 31}
24 32
25# Beep the specified number of times (defaults to five). If our output 33# @FUNCTION: ebeep
26# is not a terminal, don't beep. If the EBEEP_IGNORE env var is set, 34# @USAGE: [number of beeps]
35# @DESCRIPTION:
36# Issue the specified number of beeps (default of 5 beeps). Useful when
37# printing a message the user should probably be reading and often used in
38# conjunction with the epause function. If the EBEEP_IGNORE env var is set,
27# don't beep. 39# don't beep at all.
28# Bug 62950, Ciaran McCreesh <ciaranm@gentoo.org> (05 Sep 2004)
29ebeep() { 40ebeep() {
30 local n 41 local n
31 if [[ -z ${EBEEP_IGNORE} ]] ; then 42 if [[ -z ${EBEEP_IGNORE} ]] ; then
32 for ((n=1 ; n <= ${1:-5} ; n++)) ; do 43 for ((n=1 ; n <= ${1:-5} ; n++)) ; do
33 echo -ne "\a" 44 echo -ne "\a"
302 then 313 then
303 einfo "Done with patching" 314 einfo "Done with patching"
304 fi 315 fi
305} 316}
306 317
318# @FUNCTION: emktemp
319# @USAGE: [temp dir]
320# @DESCRIPTION:
307# Cheap replacement for when debianutils (and thus mktemp) 321# Cheap replacement for when debianutils (and thus mktemp)
308# does not exist on the users system 322# does not exist on the users system.
309# vapier@gentoo.org
310#
311# Takes just 1 optional parameter (the directory to create tmpfile in)
312emktemp() { 323emktemp() {
313 local exe="touch" 324 local exe="touch"
314 [[ $1 == -d ]] && exe="mkdir" && shift 325 [[ $1 == -d ]] && exe="mkdir" && shift
315 local topdir=$1 326 local topdir=$1
316 327
337 TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX 348 TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX
338 fi 349 fi
339 fi 350 fi
340} 351}
341 352
353# @FUNCTION: egetent
354# @USAGE: <database> <key>
355# @MAINTAINER:
356# base-system@gentoo.org (Linux)
357# Joe Jezak <josejx@gmail.com> (OS X)
358# usata@gentoo.org (OS X)
359# Aaron Walker <ka0ttic@gentoo.org> (FreeBSD)
360# @DESCRIPTION:
342# Small wrapper for getent (Linux), nidump (Mac OS X), 361# Small wrapper for getent (Linux), nidump (Mac OS X),
343# and pw (FreeBSD) used in enewuser()/enewgroup() 362# and pw (FreeBSD) used in enewuser()/enewgroup()
344# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
345# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
346#
347# egetent(database, key)
348egetent() { 363egetent() {
349 case ${CHOST} in 364 case ${CHOST} in
350 *-darwin*) 365 *-darwin*)
351 case "$2" in 366 case "$2" in
352 *[!0-9]*) # Non numeric 367 *[!0-9]*) # Non numeric
376 getent "$1" "$2" 391 getent "$1" "$2"
377 ;; 392 ;;
378 esac 393 esac
379} 394}
380 395
381# Simplify/standardize adding users to the system 396# @FUNCTION: enewuser
382# vapier@gentoo.org 397# @USAGE: <user> [uid] [shell] [homedir] [groups] [params]
383# 398# @DESCRIPTION:
384# enewuser(username, uid, shell, homedir, groups, extra options) 399# Same as enewgroup, you are not required to understand how to properly add
385# 400# a user to the system. The only required parameter is the username.
386# Default values if you do not specify any: 401# Default uid is (pass -1 for this) next available, default shell is
387# username: REQUIRED ! 402# /bin/false, default homedir is /dev/null, there are no default groups,
388# uid: next available (see useradd(8)) 403# and default params sets the comment as 'added by portage for ${PN}'.
389# note: pass -1 to get default behavior
390# shell: /bin/false
391# homedir: /dev/null
392# groups: none
393# extra: comment of 'added by portage for ${PN}'
394enewuser() { 404enewuser() {
395 case ${EBUILD_PHASE} in 405 case ${EBUILD_PHASE} in
396 unpack|compile|test|install) 406 unpack|compile|test|install)
397 eerror "'enewuser()' called from '${EBUILD_PHASE}()' which is not a pkg_* function." 407 eerror "'enewuser()' called from '${EBUILD_PHASE}()' which is not a pkg_* function."
398 eerror "Package fails at QA and at life. Please file a bug." 408 eerror "Package fails at QA and at life. Please file a bug."
587 fi 597 fi
588 598
589 export SANDBOX_ON=${oldsandbox} 599 export SANDBOX_ON=${oldsandbox}
590} 600}
591 601
592# Simplify/standardize adding groups to the system 602# @FUNCTION: enewgroup
593# vapier@gentoo.org 603# @USAGE: <group> [gid]
594# 604# @DESCRIPTION:
595# enewgroup(group, gid) 605# This function does not require you to understand how to properly add a
596# 606# group to the system. Just give it a group name to add and enewgroup will
597# Default values if you do not specify any: 607# do the rest. You may specify the gid for the group or allow the group to
598# groupname: REQUIRED ! 608# allocate the next available one.
599# gid: next available (see groupadd(8))
600# extra: none
601enewgroup() { 609enewgroup() {
602 case ${EBUILD_PHASE} in 610 case ${EBUILD_PHASE} in
603 unpack|compile|test|install) 611 unpack|compile|test|install)
604 eerror "'enewgroup()' called from '${EBUILD_PHASE}()' which is not a pkg_* function." 612 eerror "'enewgroup()' called from '${EBUILD_PHASE}()' which is not a pkg_* function."
605 eerror "Package fails at QA and at life. Please file a bug." 613 eerror "Package fails at QA and at life. Please file a bug."
701 ;; 709 ;;
702 esac 710 esac
703 export SANDBOX_ON="${oldsandbox}" 711 export SANDBOX_ON="${oldsandbox}"
704} 712}
705 713
706# Simple script to replace 'dos2unix' binaries 714# @FUNCTION: edos2unix
707# vapier@gentoo.org 715# @USAGE: <file> [more files ...]
708# 716# @DESCRIPTION:
709# edos2unix(file, <more files> ...) 717# A handy replacement for dos2unix, recode, fixdos, etc... This allows you
718# to remove all of these text utilities from DEPEND variables because this
719# is a script based solution. Just give it a list of files to convert and
720# they will all be changed from the DOS CRLF format to the UNIX LF format.
710edos2unix() { 721edos2unix() {
711 echo "$@" | xargs sed -i 's/\r$//' 722 echo "$@" | xargs sed -i 's/\r$//'
712} 723}
713
714
715##############################################################
716# START: Handle .desktop files and menu entries #
717# maybe this should be separated into a new eclass some time #
718# lanius@gentoo.org #
719##############################################################
720 724
721# Make a desktop file ! 725# Make a desktop file !
722# Great for making those icons in kde/gnome startmenu ! 726# Great for making those icons in kde/gnome startmenu !
723# Amaze your friends ! Get the women ! Join today ! 727# Amaze your friends ! Get the women ! Join today !
724# 728#
868 insinto /usr/share/applications 872 insinto /usr/share/applications
869 doins "${desktop}" 873 doins "${desktop}"
870 ) 874 )
871} 875}
872 876
873 877# @FUNCTION: validate_desktop_entries
878# @USAGE: [directories]
879# @MAINTAINER:
880# Carsten Lohrke <carlo@gentoo.org>
881# @DESCRIPTION:
874# Validate desktop entries using desktop-file-utils 882# Validate desktop entries using desktop-file-utils
875# Carsten Lohrke <carlo@gentoo.org>
876#
877# Usage: validate_desktop_entries [directory ...]
878
879validate_desktop_entries() { 883validate_desktop_entries() {
880 if [[ -x /usr/bin/desktop-file-validate ]] ; then 884 if [[ -x /usr/bin/desktop-file-validate ]] ; then
881 einfo "Checking desktop entry validity" 885 einfo "Checking desktop entry validity"
882 local directories="" 886 local directories=""
883 for d in /usr/share/applications $@ ; do 887 for d in /usr/share/applications $@ ; do
896 else 900 else
897 einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo." 901 einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo."
898 fi 902 fi
899} 903}
900 904
901 905# @FUNCTION: make_session_desktop
902# Make a GDM/KDM Session file 906# @USAGE: <title> <command>
903# 907# @DESCRIPTION:
904# make_session_desktop(<title>, <command>) 908# Make a GDM/KDM Session file. The title is the file to execute to start the
905# title: File to execute to start the Window Manager 909# Window Manager. The command is the name of the Window Manager.
906# command: Name of the Window Manager
907
908make_session_desktop() { 910make_session_desktop() {
909 [[ -z $1 ]] && eerror "make_session_desktop: You must specify the title" && return 1 911 [[ -z $1 ]] && eerror "make_session_desktop: You must specify the title" && return 1
910 [[ -z $2 ]] && eerror "make_session_desktop: You must specify the command" && return 1 912 [[ -z $2 ]] && eerror "make_session_desktop: You must specify the command" && return 1
911 913
912 local title=$1 914 local title=$1
929 insinto /usr/share/xsessions 931 insinto /usr/share/xsessions
930 doins "${desktop}" 932 doins "${desktop}"
931 ) 933 )
932} 934}
933 935
936# @FUNCTION: domenu
937# @USAGE: <menus>
938# @DESCRIPTION:
939# Install the list of .desktop menu files into the appropriate directory
940# (/usr/share/applications).
934domenu() { 941domenu() {
935 ( 942 (
936 # wrap the env here so that the 'insinto' call 943 # wrap the env here so that the 'insinto' call
937 # doesn't corrupt the env of the caller 944 # doesn't corrupt the env of the caller
938 local i j ret=0 945 local i j ret=0
949 fi 956 fi
950 done 957 done
951 exit ${ret} 958 exit ${ret}
952 ) 959 )
953} 960}
961
962# @FUNCTION: newmenu
963# @USAGE: <menu> <newname>
964# @DESCRIPTION:
965# Like all other new* functions, install the specified menu as newname.
954newmenu() { 966newmenu() {
955 ( 967 (
956 # wrap the env here so that the 'insinto' call 968 # wrap the env here so that the 'insinto' call
957 # doesn't corrupt the env of the caller 969 # doesn't corrupt the env of the caller
958 insinto /usr/share/applications 970 insinto /usr/share/applications
959 newins "$@" 971 newins "$@"
960 ) 972 )
961} 973}
962 974
975# @FUNCTION: doicon
976# @USAGE: <list of icons>
977# @DESCRIPTION:
978# Install the list of icons into the icon directory (/usr/share/pixmaps).
979# This is useful in conjunction with creating desktop/menu files.
963doicon() { 980doicon() {
964 ( 981 (
965 # wrap the env here so that the 'insinto' call 982 # wrap the env here so that the 'insinto' call
966 # doesn't corrupt the env of the caller 983 # doesn't corrupt the env of the caller
967 local i j ret 984 local i j ret
978 fi 995 fi
979 done 996 done
980 exit ${ret} 997 exit ${ret}
981 ) 998 )
982} 999}
1000
1001# @FUNCTION: newicon
1002# @USAGE: <icon> <newname>
1003# @DESCRIPTION:
1004# Like all other new* functions, install the specified icon as newname.
983newicon() { 1005newicon() {
984 ( 1006 (
985 # wrap the env here so that the 'insinto' call 1007 # wrap the env here so that the 'insinto' call
986 # doesn't corrupt the env of the caller 1008 # doesn't corrupt the env of the caller
987 insinto /usr/share/pixmaps 1009 insinto /usr/share/pixmaps
988 newins "$@" 1010 newins "$@"
989 ) 1011 )
990} 1012}
991
992##############################################################
993# END: Handle .desktop files and menu entries #
994##############################################################
995
996 1013
997# for internal use only (unpack_pdv and unpack_makeself) 1014# for internal use only (unpack_pdv and unpack_makeself)
998find_unpackable_file() { 1015find_unpackable_file() {
999 local src=$1 1016 local src=$1
1000 if [[ -z ${src} ]] ; then 1017 if [[ -z ${src} ]] ; then
1010 fi 1027 fi
1011 [[ ! -e ${src} ]] && return 1 1028 [[ ! -e ${src} ]] && return 1
1012 echo "${src}" 1029 echo "${src}"
1013} 1030}
1014 1031
1032# @FUNCTION: unpack_pdv
1033# @USAGE: <file to unpack> <size of off_t>
1034# @DESCRIPTION:
1015# Unpack those pesky pdv generated files ... 1035# Unpack those pesky pdv generated files ...
1016# They're self-unpacking programs with the binary package stuffed in 1036# They're self-unpacking programs with the binary package stuffed in
1017# the middle of the archive. Valve seems to use it a lot ... too bad 1037# the middle of the archive. Valve seems to use it a lot ... too bad
1018# it seems to like to segfault a lot :(. So lets take it apart ourselves. 1038# it seems to like to segfault a lot :(. So lets take it apart ourselves.
1019# 1039#
1020# Usage: unpack_pdv [file to unpack] [size of off_t]
1021# - you have to specify the off_t size ... i have no idea how to extract that 1040# You have to specify the off_t size ... I have no idea how to extract that
1022# information out of the binary executable myself. basically you pass in 1041# information out of the binary executable myself. Basically you pass in
1023# the size of the off_t type (in bytes) on the machine that built the pdv 1042# the size of the off_t type (in bytes) on the machine that built the pdv
1043# archive.
1044#
1024# archive. one way to determine this is by running the following commands: 1045# One way to determine this is by running the following commands:
1025# strings <pdv archive> | grep lseek 1046# strings <pdv archive> | grep lseek
1026# strace -elseek <pdv archive> 1047# strace -elseek <pdv archive>
1027# basically look for the first lseek command (we do the strings/grep because 1048# Basically look for the first lseek command (we do the strings/grep because
1028# sometimes the function call is _llseek or something) and steal the 2nd 1049# sometimes the function call is _llseek or something) and steal the 2nd
1029# parameter. here is an example: 1050# parameter. Here is an example:
1030# root@vapier 0 pdv_unpack # strings hldsupdatetool.bin | grep lseek 1051# vapier@vapier 0 pdv_unpack # strings hldsupdatetool.bin | grep lseek
1031# lseek 1052# lseek
1032# root@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin 1053# vapier@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin
1033# lseek(3, -4, SEEK_END) = 2981250 1054# lseek(3, -4, SEEK_END) = 2981250
1034# thus we would pass in the value of '4' as the second parameter. 1055# Thus we would pass in the value of '4' as the second parameter.
1035unpack_pdv() { 1056unpack_pdv() {
1036 local src=$(find_unpackable_file "$1") 1057 local src=$(find_unpackable_file "$1")
1037 local sizeoff_t=$2 1058 local sizeoff_t=$2
1038 1059
1039 [[ -z ${src} ]] && die "Could not locate source for '$1'" 1060 [[ -z ${src} ]] && die "Could not locate source for '$1'"
1101 true 1122 true
1102 #[ -s "${datafile}" ] || die "failure unpacking pdv ('${metaskip}' '${tailskip}' '${datafile}')" 1123 #[ -s "${datafile}" ] || die "failure unpacking pdv ('${metaskip}' '${tailskip}' '${datafile}')"
1103 #assert "failure unpacking pdv ('${metaskip}' '${tailskip}' '${datafile}')" 1124 #assert "failure unpacking pdv ('${metaskip}' '${tailskip}' '${datafile}')"
1104} 1125}
1105 1126
1127# @FUNCTION: unpack_makeself
1128# @USAGE: [file to unpack] [offset] [tail|dd]
1129# @DESCRIPTION:
1106# Unpack those pesky makeself generated files ... 1130# Unpack those pesky makeself generated files ...
1107# They're shell scripts with the binary package tagged onto 1131# They're shell scripts with the binary package tagged onto
1108# the end of the archive. Loki utilized the format as does 1132# the end of the archive. Loki utilized the format as does
1109# many other game companies. 1133# many other game companies.
1110# 1134#
1111# Usage: unpack_makeself [file to unpack] [offset] [tail|dd] 1135# If the file is not specified, then ${A} is used. If the
1112# - If the file is not specified then unpack will utilize ${A}.
1113# - If the offset is not specified then we will attempt to extract 1136# offset is not specified then we will attempt to extract
1114# the proper offset from the script itself. 1137# the proper offset from the script itself.
1115unpack_makeself() { 1138unpack_makeself() {
1116 local src_input=${1:-${A}} 1139 local src_input=${1:-${A}}
1117 local src=$(find_unpackable_file "${src_input}") 1140 local src=$(find_unpackable_file "${src_input}")
1118 local skip=$2 1141 local skip=$2
1119 local exe=$3 1142 local exe=$3
1189 ;; 1212 ;;
1190 esac 1213 esac
1191 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})" 1214 assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
1192} 1215}
1193 1216
1217# @FUNCTION: check_license
1218# @USAGE: [license]
1219# @DESCRIPTION:
1194# Display a license for user to accept. 1220# Display a license for user to accept. If no license is
1195#
1196# Usage: check_license [license]
1197# - If the file is not specified then ${LICENSE} is used. 1221# specified, then ${LICENSE} is used.
1198check_license() { 1222check_license() {
1199 local lic=$1 1223 local lic=$1
1200 if [ -z "${lic}" ] ; then 1224 if [ -z "${lic}" ] ; then
1201 lic="${PORTDIR}/licenses/${LICENSE}" 1225 lic="${PORTDIR}/licenses/${LICENSE}"
1202 else 1226 else
1248 die "Failed to accept license" 1272 die "Failed to accept license"
1249 ;; 1273 ;;
1250 esac 1274 esac
1251} 1275}
1252 1276
1277# @FUNCTION: cdrom_get_cds
1278# @USAGE: <file on cd1> [file on cd2] [file on cd3] [...]
1279# @DESCRIPTION:
1253# Aquire cd(s) for those lovely cd-based emerges. Yes, this violates 1280# Aquire cd(s) for those lovely cd-based emerges. Yes, this violates
1254# the whole 'non-interactive' policy, but damnit I want CD support ! 1281# the whole 'non-interactive' policy, but damnit I want CD support !
1255# 1282#
1256# with these cdrom functions we handle all the user interaction and 1283# With these cdrom functions we handle all the user interaction and
1257# standardize everything. all you have to do is call cdrom_get_cds() 1284# standardize everything. All you have to do is call cdrom_get_cds()
1258# and when the function returns, you can assume that the cd has been 1285# and when the function returns, you can assume that the cd has been
1259# found at CDROM_ROOT. 1286# found at CDROM_ROOT.
1260# 1287#
1288# The function will attempt to locate a cd based upon a file that is on
1289# the cd. The more files you give this function, the more cds
1290# the cdrom functions will handle.
1291#
1261# normally the cdrom functions will refer to the cds as 'cd #1', 'cd #2', 1292# Normally the cdrom functions will refer to the cds as 'cd #1', 'cd #2',
1262# etc... if you want to give the cds better names, then just export 1293# etc... If you want to give the cds better names, then just export
1263# the appropriate CDROM_NAME variable before calling cdrom_get_cds(). 1294# the appropriate CDROM_NAME variable before calling cdrom_get_cds().
1264# - CDROM_NAME="fooie cd" - for when you only want 1 cd 1295# Use CDROM_NAME for one cd, or CDROM_NAME_# for multiple cds. You can
1265# - CDROM_NAME_1="install cd" - for when you want more than 1 cd 1296# also use the CDROM_NAME_SET bash array.
1266# CDROM_NAME_2="data cd" 1297#
1267# - CDROM_NAME_SET=( "install cd" "data cd" ) - short hand for CDROM_NAME_#
1268#
1269# for those multi cd ebuilds, see the cdrom_load_next_cd() below. 1298# For those multi cd ebuilds, see the cdrom_load_next_cd() function.
1270#
1271# Usage: cdrom_get_cds <file on cd1> [file on cd2] [file on cd3] [...]
1272# - this will attempt to locate a cd based upon a file that is on
1273# the cd ... the more files you give this function, the more cds
1274# the cdrom functions will handle
1275cdrom_get_cds() { 1299cdrom_get_cds() {
1276 # first we figure out how many cds we're dealing with by 1300 # first we figure out how many cds we're dealing with by
1277 # the # of files they gave us 1301 # the # of files they gave us
1278 local cdcnt=0 1302 local cdcnt=0
1279 local f= 1303 local f=
1365 export CDROM_SET="" 1389 export CDROM_SET=""
1366 export CDROM_CURRENT_CD=0 1390 export CDROM_CURRENT_CD=0
1367 cdrom_load_next_cd 1391 cdrom_load_next_cd
1368} 1392}
1369 1393
1370# this is only used when you need access to more than one cd. 1394# @FUNCTION: cdrom_load_next_cd
1371# when you have finished using the first cd, just call this function. 1395# @DESCRIPTION:
1372# when it returns, CDROM_ROOT will be pointing to the second cd. 1396# Some packages are so big they come on multiple CDs. When you're done reading
1373# remember, you can only go forward in the cd chain, you can't go back. 1397# files off a CD and want access to the next one, just call this function.
1398# Again, all the messy details of user interaction are taken care of for you.
1399# Once this returns, just read the variable CDROM_ROOT for the location of the
1400# mounted CD. Note that you can only go forward in the CD list, so make sure
1401# you only call this function when you're done using the current CD.
1374cdrom_load_next_cd() { 1402cdrom_load_next_cd() {
1375 local var 1403 local var
1376 ((++CDROM_CURRENT_CD)) 1404 ((++CDROM_CURRENT_CD))
1377 1405
1378 unset CDROM_ROOT 1406 unset CDROM_ROOT
1504 [[ -n ${nols} ]] \ 1532 [[ -n ${nols} ]] \
1505 && ewarn "Sorry, but ${PN} does not support the LINGUAs:" ${nols} 1533 && ewarn "Sorry, but ${PN} does not support the LINGUAs:" ${nols}
1506 export LINGUAS=${newls:1} 1534 export LINGUAS=${newls:1}
1507} 1535}
1508 1536
1509# moved from kernel.eclass since they are generally useful outside of 1537# @FUNCTION: set_arch_to_kernel
1510# kernel.eclass -iggy (20041002) 1538# @DESCRIPTION:
1511
1512# the following functions are useful in kernel module ebuilds, etc.
1513# for an example see ivtv or drbd ebuilds
1514
1515# set's ARCH to match what the kernel expects 1539# Set the env ARCH to match what the kernel expects.
1516set_arch_to_kernel() { 1540set_arch_to_kernel() {
1517 i=10 1541 i=10
1518 while ((i--)) ; do 1542 while ((i--)) ; do
1519 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass" 1543 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1520 done 1544 done
1527 sparc) export ARCH="$(tc-arch-kernel)";; # Yeah this is ugly, but it's even WORSE if you don't do this. linux-info.eclass's set_arch_to_kernel is fixed, but won't get used over this one! 1551 sparc) export ARCH="$(tc-arch-kernel)";; # Yeah this is ugly, but it's even WORSE if you don't do this. linux-info.eclass's set_arch_to_kernel is fixed, but won't get used over this one!
1528 *) export ARCH="${ARCH}";; 1552 *) export ARCH="${ARCH}";;
1529 esac 1553 esac
1530} 1554}
1531 1555
1532# set's ARCH back to what portage expects 1556# @FUNCTION: set_arch_to_portage
1557# @DESCRIPTION:
1558# Set the env ARCH to match what portage expects.
1533set_arch_to_portage() { 1559set_arch_to_portage() {
1534 i=10 1560 i=10
1535 while ((i--)) ; do 1561 while ((i--)) ; do
1536 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass" 1562 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1537 done 1563 done
1538 export ARCH="${EUTILS_ECLASS_PORTAGE_ARCH}" 1564 export ARCH="${EUTILS_ECLASS_PORTAGE_ARCH}"
1539} 1565}
1540 1566
1541# Jeremy Huddleston <eradicator@gentoo.org>: 1567# @FUNCTION: preserve_old_lib
1542# preserve_old_lib /path/to/libblah.so.0 1568# @USAGE: <libs to preserve> [more libs]
1543# preserve_old_lib_notify /path/to/libblah.so.0 1569# @DESCRIPTION:
1544#
1545# These functions are useful when a lib in your package changes --library. Such 1570# These functions are useful when a lib in your package changes ABI SONAME.
1546# an example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0 1571# An example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0
1547# would break packages that link against it. Most people get around this 1572# would break packages that link against it. Most people get around this
1548# by using the portage SLOT mechanism, but that is not always a relevant 1573# by using the portage SLOT mechanism, but that is not always a relevant
1549# solution, so instead you can add the following to your ebuilds: 1574# solution, so instead you can call this from pkg_preinst. See also the
1550# 1575# preserve_old_lib_notify function.
1551# pkg_preinst() {
1552# ...
1553# preserve_old_lib /usr/$(get_libdir)/libogg.so.0
1554# ...
1555# }
1556#
1557# pkg_postinst() {
1558# ...
1559# preserve_old_lib_notify /usr/$(get_libdir)/libogg.so.0
1560# ...
1561# }
1562
1563preserve_old_lib() { 1576preserve_old_lib() {
1564 if [[ ${EBUILD_PHASE} != "preinst" ]] ; then 1577 if [[ ${EBUILD_PHASE} != "preinst" ]] ; then
1565 eerror "preserve_old_lib() must be called from pkg_preinst() only" 1578 eerror "preserve_old_lib() must be called from pkg_preinst() only"
1566 die "Invalid preserve_old_lib() usage" 1579 die "Invalid preserve_old_lib() usage"
1567 fi 1580 fi
1575 cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed" 1588 cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed"
1576 touch "${D}"/${lib} 1589 touch "${D}"/${lib}
1577 done 1590 done
1578} 1591}
1579 1592
1593# @FUNCTION: preserve_old_lib_notify
1594# @USAGE: <libs to notify> [more libs]
1595# @DESCRIPTION:
1596# Spit helpful messages about the libraries preserved by preserve_old_lib.
1580preserve_old_lib_notify() { 1597preserve_old_lib_notify() {
1581 if [[ ${EBUILD_PHASE} != "postinst" ]] ; then 1598 if [[ ${EBUILD_PHASE} != "postinst" ]] ; then
1582 eerror "preserve_old_lib_notify() must be called from pkg_postinst() only" 1599 eerror "preserve_old_lib_notify() must be called from pkg_postinst() only"
1583 die "Invalid preserve_old_lib_notify() usage" 1600 die "Invalid preserve_old_lib_notify() usage"
1584 fi 1601 fi
1597 fi 1614 fi
1598 ewarn " # revdep-rebuild --library ${lib##*/}" 1615 ewarn " # revdep-rebuild --library ${lib##*/}"
1599 done 1616 done
1600} 1617}
1601 1618
1602# Hack for people to figure out if a package was built with 1619# @FUNCTION: built_with_use
1603# certain USE flags
1604#
1605# Usage: built_with_use [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags> 1620# @USAGE: [--hidden] [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags>
1606# ex: built_with_use xchat gtk2 1621# @DESCRIPTION:
1607# 1622# A temporary hack until portage properly supports DEPENDing on USE
1608# Flags: -a all USE flags should be utilized 1623# flags being enabled in packages. This will check to see if the specified
1609# -o at least one USE flag should be utilized 1624# DEPEND atom was built with the specified list of USE flags. The
1610# --missing peform the specified action if the flag is not in IUSE (true/false/die) 1625# --missing option controls the behavior if called on a package that does
1611# --hidden USE flag we're checking is hidden expanded so it isnt in IUSE 1626# not actually support the defined USE flags (aka listed in IUSE).
1612# Note: the default flag is '-a' 1627# The default is to abort (call die). The -a and -o flags control
1628# the requirements of the USE flags. They correspond to "and" and "or"
1629# logic. So the -a flag means all listed USE flags must be enabled
1630# while the -o flag means at least one of the listed fIUSE flags must be
1631# enabled. The --hidden option is really for internal use only as it
1632# means the USE flag we're checking is hidden expanded, so it won't be found
1633# in IUSE like normal USE flags.
1634#
1635# Remember that this function isn't terribly intelligent so order of optional
1636# flags matter.
1613built_with_use() { 1637built_with_use() {
1614 local hidden="no" 1638 local hidden="no"
1615 if [[ $1 == "--hidden" ]] ; then 1639 if [[ $1 == "--hidden" ]] ; then
1616 hidden="yes" 1640 hidden="yes"
1617 shift 1641 shift
1678 shift 1702 shift
1679 done 1703 done
1680 [[ ${opt} = "-a" ]] 1704 [[ ${opt} = "-a" ]]
1681} 1705}
1682 1706
1707# @DESCRIPTION: epunt_cxx
1708# @USAGE: [dir to scan]
1709# @DESCRIPTION:
1683# Many configure scripts wrongly bail when a C++ compiler 1710# Many configure scripts wrongly bail when a C++ compiler could not be
1684# could not be detected. #73450 1711# detected. If dir is not specified, then it defaults to ${S}.
1712#
1713# http://bugs.gentoo.org/73450
1685epunt_cxx() { 1714epunt_cxx() {
1686 local dir=$1 1715 local dir=$1
1687 [[ -z ${dir} ]] && dir=${S} 1716 [[ -z ${dir} ]] && dir=${S}
1688 ebegin "Removing useless C++ checks" 1717 ebegin "Removing useless C++ checks"
1689 local f 1718 local f
1691 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null 1720 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null
1692 done 1721 done
1693 eend 0 1722 eend 0
1694} 1723}
1695 1724
1696# make a wrapper script ... 1725# @FUNCTION: make_wrapper
1697# NOTE: this was originally games_make_wrapper, but I noticed other places where 1726# @USAGE: <wrapper> <target> <chdir> [libpaths] [installpath]
1698# this could be used, so I have moved it here and made it not games-specific 1727# @DESCRIPTION:
1699# -- wolf31o2 1728# Create a shell wrapper script named wrapper in installpath
1700# $1 == wrapper name 1729# (defaults to the bindir) to execute target (default of wrapper) by
1701# $2 == binary to run 1730# first optionally setting LD_LIBRARY_PATH to the colon-delimited
1702# $3 == directory to chdir before running binary 1731# libpaths followed by optionally changing directory to chdir.
1703# $4 == extra LD_LIBRARY_PATH's (make it : delimited)
1704# $5 == path for wrapper
1705make_wrapper() { 1732make_wrapper() {
1706 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5 1733 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5
1707 local tmpwrapper=$(emktemp) 1734 local tmpwrapper=$(emktemp)
1708 # We don't want to quote ${bin} so that people can pass complex 1735 # We don't want to quote ${bin} so that people can pass complex
1709 # things as $bin ... "./someprog --args" 1736 # things as $bin ... "./someprog --args"
1719fi 1746fi
1720exec ${bin} "\$@" 1747exec ${bin} "\$@"
1721EOF 1748EOF
1722 chmod go+rx "${tmpwrapper}" 1749 chmod go+rx "${tmpwrapper}"
1723 if [[ -n ${path} ]] ; then 1750 if [[ -n ${path} ]] ; then
1751 (
1724 exeinto "${path}" 1752 exeinto "${path}"
1725 newexe "${tmpwrapper}" "${wrapper}" 1753 newexe "${tmpwrapper}" "${wrapper}"
1754 ) || die
1726 else 1755 else
1727 newbin "${tmpwrapper}" "${wrapper}" 1756 newbin "${tmpwrapper}" "${wrapper}" || die
1728 fi 1757 fi
1729} 1758}

Legend:
Removed from v.1.282  
changed lines
  Added in v.1.283

  ViewVC Help
Powered by ViewVC 1.1.20