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

Diff of /eclass/eutils.eclass

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

Revision 1.136 Revision 1.168
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2005 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.136 2005/01/07 11:13:38 eradicator Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.168 2005/04/29 03:59:15 vapier 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.
9# 9#
10# NB: If you add anything, please comment it! 10# NB: If you add anything, please comment it!
11 11
12inherit multilib
12ECLASS=eutils 13ECLASS=eutils
13INHERITED="$INHERITED $ECLASS" 14INHERITED="$INHERITED $ECLASS"
14 15
15DEPEND="!bootstrap? ( sys-devel/patch )" 16DEPEND="!bootstrap? ( sys-devel/patch )"
16 17
41 sleep 1 42 sleep 1
42 done 43 done
43 fi 44 fi
44} 45}
45 46
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)
53#
54# Jeremy Huddleston <eradicator@gentoo.org> (23 Dec 2004):
55# Added support for ${ABI} and ${DEFAULT_ABI}. If they're both not set,
56# fall back on old behavior. Any profile that has these set should also
57# depend on a newer version of portage (not yet released) which uses these
58# over CONF_LIBDIR in econf, dolib, etc...
59get_libdir() {
60 LIBDIR_TEST=$(type econf)
61 if [ ! -z "${CONF_LIBDIR_OVERRIDE}" ] ; then
62 # if there is an override, we want to use that... always.
63 CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}"
64 # We don't need to know the verison of portage. We only need to know
65 # if there is support for CONF_LIBDIR in econf and co.
66 # Danny van Dyk <kugelfang@gentoo.org> 2004/17/09
67 #elif portageq has_version / '<sys-apps/portage-2.0.51_pre20' ; then
68 # # and if there isnt an override, and we're using a version of
69 # # portage without CONF_LIBDIR support, force the use of lib. dolib
70 # # and friends from portage 2.0.50 wont be too happy otherwise.
71 # CONF_LIBDIR="lib"
72 #fi
73 elif [ -n "$(get_abi_LIBDIR)" ]; then # Using eradicator's LIBDIR_<abi> approach...
74 CONF_LIBDIR="$(get_abi_LIBDIR)"
75 elif [ "${LIBDIR_TEST/CONF_LIBDIR}" == "${LIBDIR_TEST}" ]; then # we don't have CONF_LIBDIR support
76 # will be <portage-2.0.51_pre20
77 CONF_LIBDIR="lib"
78 fi
79 # and of course, default to lib if CONF_LIBDIR isnt set
80 echo ${CONF_LIBDIR:=lib}
81 unset LIBDIR_TEST
82}
83
84get_multilibdir() {
85 [ -n "$(get_abi_LIBDIR)" ] && die "get_multilibdir called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org"
86 echo ${CONF_MULTILIBDIR:=lib32}
87}
88
89# Sometimes you need to override the value returned by get_libdir. A good
90# example of this is xorg-x11, where lib32 isnt a supported configuration,
91# and where lib64 -must- be used on amd64 (for applications that need lib
92# to be 32bit, such as adobe acrobat). Note that this override also bypasses
93# portage version sanity checking.
94# get_libdir_override expects one argument, the result get_libdir should
95# return:
96#
97# get_libdir_override lib64
98#
99# Travis Tilley <lv@gentoo.org> (31 Aug 2004)
100get_libdir_override() {
101 [ -n "$(get_abi_LIBDIR)" ] && die "get_libdir_override called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org"
102 CONF_LIBDIR="$1"
103 CONF_LIBDIR_OVERRIDE="$1"
104}
105
106# This function generate linker scripts in /usr/lib for dynamic 47# This function generate linker scripts in /usr/lib for dynamic
107# libs in /lib. This is to fix linking problems when you have 48# libs in /lib. This is to fix linking problems when you have
108# the .so in /lib, and the .a in /usr/lib. What happens is that 49# the .so in /lib, and the .a in /usr/lib. What happens is that
109# in some cases when linking dynamic, the .a in /usr/lib is used 50# in some cases when linking dynamic, the .a in /usr/lib is used
110# instead of the .so in /lib due to gcc/libtool tweaking ld's 51# instead of the .so in /lib due to gcc/libtool tweaking ld's
124gen_usr_ldscript() { 65gen_usr_ldscript() {
125 local libdir="$(get_libdir)" 66 local libdir="$(get_libdir)"
126 # Just make sure it exists 67 # Just make sure it exists
127 dodir /usr/${libdir} 68 dodir /usr/${libdir}
128 69
70 for lib in "${@}" ; do
129 cat > "${D}/usr/${libdir}/${1}" << END_LDSCRIPT 71 cat > "${D}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
130/* GNU ld script 72 /* GNU ld script
131 Because Gentoo have critical dynamic libraries 73 Since Gentoo has critical dynamic libraries
132 in /lib, and the static versions in /usr/lib, we 74 in /lib, and the static versions in /usr/lib,
133 need to have a "fake" dynamic lib in /usr/lib, 75 we need to have a "fake" dynamic lib in /usr/lib,
134 otherwise we run into linking problems. 76 otherwise we run into linking problems.
135 See bug #4411 on http://bugs.gentoo.org/ for 77
136 more info. */ 78 See bug http://bugs.gentoo.org/4411 for more info.
79 */
137GROUP ( /${libdir}/${1} ) 80 GROUP ( /${libdir}/${lib} )
138END_LDSCRIPT 81 END_LDSCRIPT
139 fperms a+x "/usr/${libdir}/${1}" 82 fperms a+x "/usr/${libdir}/${lib}"
83 done
140} 84}
141 85
142# Simple function to draw a line consisting of '=' the same length as $* 86# Simple function to draw a line consisting of '=' the same length as $*
87# - only to be used by epatch()
143# 88#
144# <azarah@gentoo.org> (11 Nov 2002) 89# <azarah@gentoo.org> (11 Nov 2002)
145# 90#
146draw_line() { 91draw_line() {
147 local i=0 92 local i=0
229 local x="" 174 local x=""
230 175
231 if [ "$#" -gt 1 ] 176 if [ "$#" -gt 1 ]
232 then 177 then
233 local m="" 178 local m=""
234 einfo "${#} patches to apply ..."
235 for m in "$@" ; do 179 for m in "$@" ; do
236 epatch "${m}" 180 epatch "${m}"
237 done 181 done
238 return 0 182 return 0
239 fi 183 fi
264 208
265 echo 209 echo
266 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:" 210 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:"
267 eerror 211 eerror
268 eerror " ${EPATCH_SOURCE}" 212 eerror " ${EPATCH_SOURCE}"
213 eerror " ( ${EPATCH_SOURCE##*/} )"
269 echo 214 echo
270 die "Cannot find \$EPATCH_SOURCE!" 215 die "Cannot find \$EPATCH_SOURCE!"
271 fi 216 fi
272 217
273 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" 218 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
306 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ 251 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \
307 [ "${EPATCH_FORCE}" = "yes" ]) 252 [ "${EPATCH_FORCE}" = "yes" ])
308 then 253 then
309 local count=0 254 local count=0
310 local popts="${EPATCH_OPTS}" 255 local popts="${EPATCH_OPTS}"
256 local patchname=${x##*/}
311 257
312 if [ -n "${EPATCH_EXCLUDE}" ] 258 if [ -n "${EPATCH_EXCLUDE}" ]
313 then 259 then
314 if [ "`eval echo \$\{EPATCH_EXCLUDE/${x##*/}\}`" != "${EPATCH_EXCLUDE}" ] 260 if [ "${EPATCH_EXCLUDE/${patchname}}" != "${EPATCH_EXCLUDE}" ]
315 then 261 then
316 continue 262 continue
317 fi 263 fi
318 fi 264 fi
319 265
321 then 267 then
322 if [ -n "${EPATCH_SINGLE_MSG}" ] 268 if [ -n "${EPATCH_SINGLE_MSG}" ]
323 then 269 then
324 einfo "${EPATCH_SINGLE_MSG}" 270 einfo "${EPATCH_SINGLE_MSG}"
325 else 271 else
326 einfo "Applying ${x##*/} ..." 272 einfo "Applying ${patchname} ..."
327 fi 273 fi
328 else 274 else
329 einfo " ${x##*/} ..." 275 einfo " ${patchname} ..."
330 fi 276 fi
331 277
332 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 278 echo "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
333 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 279 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
334 280
335 # Allow for prefix to differ ... im lazy, so shoot me :/ 281 # Allow for prefix to differ ... im lazy, so shoot me :/
336 while [ "${count}" -lt 5 ] 282 while [ "${count}" -lt 5 ]
337 do 283 do
338 # Generate some useful debug info ... 284 # Generate some useful debug info ...
339 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 285 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
340 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 286 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
341 287
342 if [ "${PATCH_SUFFIX}" != "patch" ] 288 if [ "${PATCH_SUFFIX}" != "patch" ]
343 then 289 then
344 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 290 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
345 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 291 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
346 else 292 else
347 PATCH_TARGET="${x}" 293 PATCH_TARGET="${x}"
348 fi 294 fi
349 295
350 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 296 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
351 echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 297 echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
352 298
353 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 299 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
354 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 300 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
355 301
356 if [ "${PATCH_SUFFIX}" != "patch" ] 302 if [ "${PATCH_SUFFIX}" != "patch" ]
357 then 303 then
358 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 304 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1
359 then 305 then
360 echo 306 echo
361 eerror "Could not extract patch!" 307 eerror "Could not extract patch!"
362 #die "Could not extract patch!" 308 #die "Could not extract patch!"
363 count=5 309 count=5
364 break 310 break
365 fi 311 fi
366 fi 312 fi
367 313
368 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 314 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1
369 then 315 then
370 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 316 draw_line "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
371 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 317 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
372 echo "ACTUALLY APPLYING ${x##*/} ..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 318 echo "ACTUALLY APPLYING ${patchname} ..." >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
373 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 319 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
374 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 320 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
375 321
376 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1 322 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real 2>&1
377 323
378 if [ "$?" -ne 0 ] 324 if [ "$?" -ne 0 ]
379 then 325 then
380 cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 326 cat ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
381 echo 327 echo
382 eerror "A dry-run of patch command succeeded, but actually" 328 eerror "A dry-run of patch command succeeded, but actually"
383 eerror "applying the patch failed!" 329 eerror "applying the patch failed!"
384 #die "Real world sux compared to the dreamworld!" 330 #die "Real world sux compared to the dreamworld!"
385 count=5 331 count=5
386 fi 332 fi
387 333
388 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 334 rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
389 335
390 break 336 break
391 fi 337 fi
392 338
393 count=$((count + 1)) 339 count=$((count + 1))
399 fi 345 fi
400 346
401 if [ "${count}" -eq 5 ] 347 if [ "${count}" -eq 5 ]
402 then 348 then
403 echo 349 echo
404 eerror "Failed Patch: ${x##*/}!" 350 eerror "Failed Patch: ${patchname} !"
351 eerror " ( ${PATCH_TARGET} )"
405 eerror 352 eerror
406 eerror "Include in your bugreport the contents of:" 353 eerror "Include in your bugreport the contents of:"
407 eerror 354 eerror
408 eerror " ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}" 355 eerror " ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}"
409 echo 356 echo
410 die "Failed Patch: ${x##*/}!" 357 die "Failed Patch: ${patchname}!"
411 fi 358 fi
412 359
413 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 360 rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
414 361
415 eend 0 362 eend 0
416 fi 363 fi
417 done 364 done
418 if [ "${SINGLE_PATCH}" = "no" ] 365 if [ "${SINGLE_PATCH}" = "no" ]
922# name: the name that will show up in the menu 869# name: the name that will show up in the menu
923# icon: give your little like a pretty little icon ... 870# icon: give your little like a pretty little icon ...
924# this can be relative (to /usr/share/pixmaps) or 871# this can be relative (to /usr/share/pixmaps) or
925# a full path to an icon 872# a full path to an icon
926# type: what kind of application is this ? for categories: 873# type: what kind of application is this ? for categories:
927# http://www.freedesktop.org/standards/menu-spec/ 874# http://www.freedesktop.org/wiki/Standards_2fmenu_2dspec
928# path: if your app needs to startup in a specific dir 875# path: if your app needs to startup in a specific dir
929make_desktop_entry() { 876make_desktop_entry() {
930 [ -z "$1" ] && eerror "make_desktop_entry: You must specify the executable" && return 1 877 [[ -z $1 ]] && eerror "make_desktop_entry: You must specify the executable" && return 1
931 878
932 local exec="${1}" 879 local exec=${1}
933 local name="${2:-${PN}}" 880 local name=${2:-${PN}}
934 local icon="${3:-${PN}.png}" 881 local icon=${3:-${PN}.png}
935 local type="${4}" 882 local type=${4}
936 local subdir="${6}" 883 local path=${5}
937 local path="${5:-${GAMES_BINDIR}}" 884
938 if [ -z "${type}" ] 885 if [[ -z ${type} ]] ; then
939 then 886 local catmaj=${CATEGORY%%-*}
940 case ${CATEGORY} in 887 local catmin=${CATEGORY##*-}
941 "app-emulation") 888 case ${catmaj} in
942 type=Emulator 889 app)
943 subdir="Emulation" 890 case ${catmin} in
891 admin) type=System;;
892 cdr) type=DiscBurning;;
893 dicts) type=Dictionary;;
894 editors) type=TextEditor;;
895 emacs) type=TextEditor;;
896 emulation) type=Emulator;;
897 laptop) type=HardwareSettings;;
898 office) type=Office;;
899 vim) type=TextEditor;;
900 xemacs) type=TextEditor;;
901 *) type=;;
902 esac
944 ;; 903 ;;
945 "games-"*) 904
946 type=Game 905 dev)
947 subdir="Games" 906 type="Development"
948 ;; 907 ;;
949 "net-"*) 908
950 type=Network 909 games)
951 subdir="${type}" 910 [[ -z ${path} ]] && path=${GAMES_BINDIR}
911
912 case ${catmin} in
913 action) type=ActionGame;;
914 arcade) type=ArcadeGame;;
915 board) type=BoardGame;;
916 kid) type=KidsGame;;
917 emulation) type=Emulator;;
918 puzzle) type=LogicGame;;
919 rpg) type=RolePlaying;;
920 roguelike) type=RolePlaying;;
921 simulation) type=Simulation;;
922 sports) type=SportsGame;;
923 strategy) type=StrategyGame;;
924 *) type=;;
925 esac
926 type="Game;${type}"
952 ;; 927 ;;
928
929 mail)
930 type="Network;Email"
931 ;;
932
933 media)
934 case ${catmin} in
935 gfx) type=Graphics;;
936 radio) type=Tuner;;
937 sound) type=Audio;;
938 tv) type=TV;;
939 video) type=Video;;
940 *) type=;;
941 esac
942 type="AudioVideo;${type}"
943 ;;
944
945 net)
946 case ${catmin} in
947 dialup) type=Dialup;;
948 ftp) type=FileTransfer;;
949 im) type=InstantMessaging;;
950 irc) type=IRCClient;;
951 mail) type=Email;;
952 news) type=News;;
953 nntp) type=News;;
954 p2p) type=FileTransfer;;
955 *) type=;;
956 esac
957 type="Network;${type}"
958 ;;
959
960 sci)
961 case ${catmin} in
962 astro*) type=Astronomoy;;
963 bio*) type=Biology;;
964 calc*) type=Calculator;;
965 chem*) type=Chemistry;;
966 geo*) type=Geology;;
967 math*) type=Math;;
968 *) type=;;
969 esac
970 type="Science;${type}"
971 ;;
972
973 www)
974 case ${catmin} in
975 client) type=WebBrowser;;
976 *) type=;;
977 esac
978 type="Network"
979 ;;
980
953 *) 981 *)
954 type= 982 type=
955 subdir=
956 ;; 983 ;;
957 esac 984 esac
958 fi 985 fi
986
959 local desktop="${T}/${exec}.desktop" 987 local desktop=${T}/${exec%% *}-${P}.desktop
960 988
961echo "[Desktop Entry] 989echo "[Desktop Entry]
962Encoding=UTF-8 990Encoding=UTF-8
963Version=0.9.2 991Version=0.9.2
964Name=${name} 992Name=${name}
980# make_desktop_entry(<title>, <command>) 1008# make_desktop_entry(<title>, <command>)
981# title: File to execute to start the Window Manager 1009# title: File to execute to start the Window Manager
982# command: Name of the Window Manager 1010# command: Name of the Window Manager
983 1011
984make_session_desktop() { 1012make_session_desktop() {
985
986 [ -z "$1" ] && eerror "make_session_desktop: You must specify the title" && return 1 1013 [[ -z $1 ]] && eerror "make_session_desktop: You must specify the title" && return 1
987 [ -z "$2" ] && eerror "make_session_desktop: You must specify the command" && return 1 1014 [[ -z $2 ]] && eerror "make_session_desktop: You must specify the command" && return 1
988 1015
989 local title="${1}" 1016 local title=$1
990 local command="${2}" 1017 local command=$2
991 local desktop="${T}/${wm}.desktop" 1018 local desktop=${T}/${wm}.desktop
992 1019
993echo "[Desktop Entry] 1020echo "[Desktop Entry]
994Encoding=UTF-8 1021Encoding=UTF-8
995Name=${title} 1022Name=${title}
996Comment=This session logs you into ${title} 1023Comment=This session logs you into ${title}
998TryExec=${command} 1025TryExec=${command}
999Type=Application" > "${desktop}" 1026Type=Application" > "${desktop}"
1000 1027
1001 insinto /usr/share/xsessions 1028 insinto /usr/share/xsessions
1002 doins "${desktop}" 1029 doins "${desktop}"
1003
1004 return 0
1005} 1030}
1006 1031
1007domenu() { 1032domenu() {
1008 local i 1033 local i j
1009 local j
1010 insinto /usr/share/applications 1034 insinto /usr/share/applications
1011 for i in ${@} 1035 for i in "$@" ; do
1012 do
1013 if [ -f "${i}" ]; 1036 if [[ -f ${i} ]] ; then
1014 then
1015 doins ${i} 1037 doins "${i}"
1016 elif [ -d "${i}" ]; 1038 elif [[ -d ${i} ]] ; then
1017 then
1018 for j in ${i}/*.desktop 1039 for j in "${i}"/*.desktop ; do
1019 do
1020 doins ${j} 1040 doins "${j}"
1021 done 1041 done
1022 fi 1042 fi
1023 done 1043 done
1024} 1044}
1045newmenu() {
1046 insinto /usr/share/applications
1047 newins "$1" "$2"
1048}
1025 1049
1026doicon() { 1050doicon() {
1027 local i 1051 local i j
1028 local j
1029 insinto /usr/share/pixmaps 1052 insinto /usr/share/pixmaps
1030 for i in ${@} 1053 for i in "$@" ; do
1031 do
1032 if [ -f "${i}" ]; 1054 if [[ -f ${i} ]] ; then
1033 then
1034 doins ${i} 1055 doins "${i}"
1035 elif [ -d "${i}" ]; 1056 elif [[ -d ${i} ]] ; then
1036 then
1037 for j in ${i}/*.png 1057 for j in "${i}"/*.png ; do
1038 do
1039 doins ${j} 1058 doins "${j}"
1040 done 1059 done
1041 fi 1060 fi
1042 done 1061 done
1062}
1063newicon() {
1064 insinto /usr/share/pixmaps
1065 newins "$1" "$2"
1043} 1066}
1044 1067
1045############################################################## 1068##############################################################
1046# END: Handle .desktop files and menu entries # 1069# END: Handle .desktop files and menu entries #
1047############################################################## 1070##############################################################
1492# directories and uses the intersection of the lists. 1515# directories and uses the intersection of the lists.
1493# The -u builds a list of po files found in all the 1516# The -u builds a list of po files found in all the
1494# directories and uses the union of the lists. 1517# directories and uses the union of the lists.
1495strip-linguas() { 1518strip-linguas() {
1496 local ls newls 1519 local ls newls
1497 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1520 if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then
1498 local op="$1"; shift 1521 local op=$1; shift
1499 ls=" $(find "$1" -name '*.po' -printf '%f ') "; shift 1522 ls=" $(find "$1" -name '*.po' -printf '%f ') "; shift
1500 local d f 1523 local d f
1501 for d in "$@" ; do 1524 for d in "$@" ; do
1502 if [ "${op}" == "-u" ] ; then 1525 if [[ ${op} == "-u" ]] ; then
1503 newls="${ls}" 1526 newls=${ls}
1504 else 1527 else
1505 newls="" 1528 newls=""
1506 fi 1529 fi
1507 for f in $(find "$d" -name '*.po' -printf '%f ') ; do 1530 for f in $(find "$d" -name '*.po' -printf '%f ') ; do
1508 if [ "${op}" == "-i" ] ; then 1531 if [[ ${op} == "-i" ]] ; then
1509 [ "${ls/ ${f} /}" != "${ls}" ] && newls="${newls} ${f}" 1532 [[ ${ls/ ${f} /} != ${ls} ]] && newls="${newls} ${f}"
1510 else 1533 else
1511 [ "${ls/ ${f} /}" == "${ls}" ] && newls="${newls} ${f}" 1534 [[ ${ls/ ${f} /} == ${ls} ]] && newls="${newls} ${f}"
1512 fi 1535 fi
1513 done 1536 done
1514 ls="${newls}" 1537 ls=${newls}
1515 done 1538 done
1516 ls="${ls//.po}" 1539 ls=${ls//.po}
1517 else 1540 else
1518 ls="$@" 1541 ls=$@
1519 fi 1542 fi
1520 1543
1521 ls=" ${ls} " 1544 ls=" ${ls} "
1522 newls="" 1545 newls=""
1523 for f in ${LINGUAS} ; do 1546 for f in ${LINGUAS} ; do
1524 if [ "${ls/ ${f} /}" != "${ls}" ] ; then 1547 if [[ ${ls/ ${f} /} != ${ls} ]] ; then
1525 newls="${newls} ${f}" 1548 newls="${newls} ${f}"
1526 else 1549 else
1527 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" 1550 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA"
1528 fi 1551 fi
1529 done 1552 done
1530 if [ -z "${newls}" ] ; then 1553 if [[ -z ${newls} ]] ; then
1531 unset LINGUAS 1554 export LINGUAS=""
1532 else 1555 else
1533 export LINGUAS="${newls}" 1556 export LINGUAS=${newls:1}
1534 fi 1557 fi
1535} 1558}
1536 1559
1537# moved from kernel.eclass since they are generally useful outside of 1560# moved from kernel.eclass since they are generally useful outside of
1538# kernel.eclass -iggy (20041002) 1561# kernel.eclass -iggy (20041002)
1540# the following functions are useful in kernel module ebuilds, etc. 1563# the following functions are useful in kernel module ebuilds, etc.
1541# for an example see ivtv or drbd ebuilds 1564# for an example see ivtv or drbd ebuilds
1542 1565
1543# set's ARCH to match what the kernel expects 1566# set's ARCH to match what the kernel expects
1544set_arch_to_kernel() { 1567set_arch_to_kernel() {
1568 i=10
1569 while ((i--)) ; do
1570 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1571 done
1545 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}" 1572 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}"
1546 case ${ARCH} in 1573 case ${ARCH} in
1547 x86) export ARCH="i386";; 1574 x86) export ARCH="i386";;
1548 amd64) export ARCH="x86_64";; 1575 amd64) export ARCH="x86_64";;
1549 hppa) export ARCH="parisc";; 1576 hppa) export ARCH="parisc";;
1550 mips) export ARCH="mips";; 1577 mips) export ARCH="mips";;
1578 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 *) export ARCH="${ARCH}";; 1579 *) export ARCH="${ARCH}";;
1552 esac 1580 esac
1553} 1581}
1554 1582
1555# set's ARCH back to what portage expects 1583# set's ARCH back to what portage expects
1556set_arch_to_portage() { 1584set_arch_to_portage() {
1585 i=10
1586 while ((i--)) ; do
1587 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1588 done
1557 export ARCH="${EUTILS_ECLASS_PORTAGE_ARCH}" 1589 export ARCH="${EUTILS_ECLASS_PORTAGE_ARCH}"
1558} 1590}
1559 1591
1560# Jeremy Huddleston <eradicator@gentoo.org>: 1592# Jeremy Huddleston <eradicator@gentoo.org>:
1561# preserve_old_lib /path/to/libblah.so.0 1593# preserve_old_lib /path/to/libblah.so.0
1607 einfo "After doing that, you can safely remove ${LIB}" 1639 einfo "After doing that, you can safely remove ${LIB}"
1608 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild" 1640 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild"
1609 fi 1641 fi
1610} 1642}
1611 1643
1612# Hack for people to figure out if a package was built with 1644# Hack for people to figure out if a package was built with
1613# certain USE flags 1645# certain USE flags
1614# 1646#
1615# Usage: built_with_use [-a|-o] <DEPEND ATOM> <List of USE flags> 1647# Usage: built_with_use [-a|-o] <DEPEND ATOM> <List of USE flags>
1616# ex: built_with_use xchat gtk2 1648# ex: built_with_use xchat gtk2
1617# 1649#
1638 shift 1670 shift
1639 done 1671 done
1640 [[ ${opt} = "-a" ]] 1672 [[ ${opt} = "-a" ]]
1641} 1673}
1642 1674
1643# Many configure scripts wrongly bail when a C++ compiler 1675# Many configure scripts wrongly bail when a C++ compiler
1644# could not be detected. #73450 1676# could not be detected. #73450
1645epunt_cxx() { 1677epunt_cxx() {
1646 local dir=$1 1678 local dir=$1
1647 [[ -z ${dir} ]] && dir=${S} 1679 [[ -z ${dir} ]] && dir=${S}
1648 ebegin "Removing useless C++ checks" 1680 ebegin "Removing useless C++ checks"
1651 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null 1683 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null
1652 done 1684 done
1653 eend 0 1685 eend 0
1654} 1686}
1655 1687
1656# get_abi_var <VAR> [<ABI>] 1688# dopamd <file> [more files]
1657# returns the value of ${<VAR>_<ABI>} which should be set in make.defaults
1658# 1689#
1659# ex: 1690# Install pam auth config file in /etc/pam.d
1660# CFLAGS=$(get_abi_var CFLAGS sparc32) # CFLAGS=-m32 1691dopamd() {
1661# 1692 [[ -z $1 ]] && die "dopamd requires at least one argument"
1662# Note that the prefered method is to set CC="$(tc-getCC) $(get_abi_CFLAGS)"
1663# This will hopefully be added to portage soon...
1664#
1665# If <ABI> is not specified, ${ABI} is used.
1666# If <ABI> is not specified and ${ABI} is not defined, ${DEFAULT_ABI} is used.
1667# If <ABI> is not specified and ${ABI} and ${DEFAULT_ABI} are not defined, we return an empty string.
1668#
1669# Jeremy Huddleston <eradicator@gentoo.org>
1670get_abi_var() {
1671 local flag=$1
1672 local abi
1673 if [ $# -gt 1 ]; then
1674 abi=$1
1675 elif [ -n "${ABI}" ]; then
1676 abi=${ABI}
1677 elif [ -n "${DEFAULT_ABI}" ]; then
1678 abi=${DEFAULT_ABI}
1679 else
1680 return 1
1681 fi
1682 1693
1683 local var="${flag}_${abi}" 1694 use pam || return 0
1684 echo ${!var}
1685}
1686 1695
1687get_abi_CFLAGS() { get_abi_var CFLAGS $1; } 1696 insinto /etc/pam.d
1688get_abi_CXXFLAGS() { get_abi_var CXXFLAGS $1; } 1697 doins "$@" || die "failed to install $@"
1689get_abi_ASFLAGS() { get_abi_var ASFLAGS $1; } 1698}
1690get_abi_LIBDIR() { get_abi_var LIBDIR $1; } 1699# newpamd <old name> <new name>
1700#
1701# Install pam file <old name> as <new name> in /etc/pam.d
1702newpamd() {
1703 [[ $# -ne 2 ]] && die "newpamd requires two arguements"
1691 1704
1705 use pam || return 0
1706
1707 insinto /etc/pam.d
1708 newins "$1" "$2" || die "failed to install $1 as $2"
1709}
1710
1711# make a wrapper script ...
1712# NOTE: this was originally games_make_wrapper, but I noticed other places where
1713# this could be used, so I have moved it here and made it not games-specific
1714# -- wolf31o2
1715# $1 == wrapper name
1716# $2 == binary to run
1717# $3 == directory to chdir before running binary
1718# $4 == extra LD_LIBRARY_PATH's (make it : delimited)
1719# $5 == path for wrapper
1720make_wrapper() {
1721 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5
1722 local tmpwrapper=$(emktemp)
1723 cat << EOF > "${tmpwrapper}"
1724#!/bin/sh
1725cd "${chdir}"
1726export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
1727exec ${bin} "\$@"
1728EOF
1729 chmod go+rx "${tmpwrapper}"
1730 if [ -n "${5}" ]
1731 then
1732 exeinto ${5}
1733 newexe "${tmpwrapper}" "${wrapper}"
1734 else
1735 newbin "${tmpwrapper}" "${wrapper}"
1736 fi
1737}

Legend:
Removed from v.1.136  
changed lines
  Added in v.1.168

  ViewVC Help
Powered by ViewVC 1.1.20