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

Diff of /eclass/eutils.eclass

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

Revision 1.135 Revision 1.182
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.135 2004/12/31 11:28:18 eradicator Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.182 2005/06/11 00:02:26 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 userland_GNU? ( sys-apps/shadow ) )"
17# sys-apps/shadow is needed for useradd, etc, bug #94745.
16 18
17DESCRIPTION="Based on the ${ECLASS} eclass" 19DESCRIPTION="Based on the ${ECLASS} eclass"
18 20
19# Wait for the supplied number of seconds. If no argument is supplied, defaults 21# 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 22# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not
41 sleep 1 43 sleep 1
42 done 44 done
43 fi 45 fi
44} 46}
45 47
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 48# This function generate linker scripts in /usr/lib for dynamic
107# libs in /lib. This is to fix linking problems when you have 49# 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 50# 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 51# 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 52# instead of the .so in /lib due to gcc/libtool tweaking ld's
124gen_usr_ldscript() { 66gen_usr_ldscript() {
125 local libdir="$(get_libdir)" 67 local libdir="$(get_libdir)"
126 # Just make sure it exists 68 # Just make sure it exists
127 dodir /usr/${libdir} 69 dodir /usr/${libdir}
128 70
71 for lib in "${@}" ; do
129 cat > "${D}/usr/${libdir}/${1}" << END_LDSCRIPT 72 cat > "${D}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
130/* GNU ld script 73 /* GNU ld script
131 Because Gentoo have critical dynamic libraries 74 Since Gentoo has critical dynamic libraries
132 in /lib, and the static versions in /usr/lib, we 75 in /lib, and the static versions in /usr/lib,
133 need to have a "fake" dynamic lib in /usr/lib, 76 we need to have a "fake" dynamic lib in /usr/lib,
134 otherwise we run into linking problems. 77 otherwise we run into linking problems.
135 See bug #4411 on http://bugs.gentoo.org/ for 78
136 more info. */ 79 See bug http://bugs.gentoo.org/4411 for more info.
80 */
137GROUP ( /${libdir}/${1} ) 81 GROUP ( /${libdir}/${lib} )
138END_LDSCRIPT 82 END_LDSCRIPT
139 fperms a+x "/usr/${libdir}/${1}" 83 fperms a+x "/usr/${libdir}/${lib}"
84 done
140} 85}
141 86
142# Simple function to draw a line consisting of '=' the same length as $* 87# Simple function to draw a line consisting of '=' the same length as $*
88# - only to be used by epatch()
143# 89#
144# <azarah@gentoo.org> (11 Nov 2002) 90# <azarah@gentoo.org> (11 Nov 2002)
145# 91#
146draw_line() { 92draw_line() {
147 local i=0 93 local i=0
173EPATCH_SOURCE="${WORKDIR}/patch" 119EPATCH_SOURCE="${WORKDIR}/patch"
174# Default extension for patches 120# Default extension for patches
175EPATCH_SUFFIX="patch.bz2" 121EPATCH_SUFFIX="patch.bz2"
176# Default options for patch 122# Default options for patch
177# Set -g0 to keep RCS, ClearCase, Perforce and SCCS happy. Bug #24571 123# Set -g0 to keep RCS, ClearCase, Perforce and SCCS happy. Bug #24571
178EPATCH_OPTS="-g0" 124# Set --no-backup-if-mismatch so we don't leave '.orig' files behind.
125EPATCH_OPTS="-g0 --no-backup-if-mismatch"
179# List of patches not to apply. Not this is only file names, 126# List of patches not to apply. Not this is only file names,
180# and not the full path .. 127# and not the full path ..
181EPATCH_EXCLUDE="" 128EPATCH_EXCLUDE=""
182# Change the printed message for a single patch. 129# Change the printed message for a single patch.
183EPATCH_SINGLE_MSG="" 130EPATCH_SINGLE_MSG=""
131# Change the printed message for multiple patches.
132EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
184# Force applying bulk patches even if not following the style: 133# Force applying bulk patches even if not following the style:
185# 134#
186# ??_${ARCH}_foo.${EPATCH_SUFFIX} 135# ??_${ARCH}_foo.${EPATCH_SUFFIX}
187# 136#
188EPATCH_FORCE="no" 137EPATCH_FORCE="no"
229 local x="" 178 local x=""
230 179
231 if [ "$#" -gt 1 ] 180 if [ "$#" -gt 1 ]
232 then 181 then
233 local m="" 182 local m=""
234 einfo "${#} patches to apply ..."
235 for m in "$@" ; do 183 for m in "$@" ; do
236 epatch "${m}" 184 epatch "${m}"
237 done 185 done
238 return 0 186 return 0
239 fi 187 fi
264 212
265 echo 213 echo
266 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:" 214 eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:"
267 eerror 215 eerror
268 eerror " ${EPATCH_SOURCE}" 216 eerror " ${EPATCH_SOURCE}"
217 eerror " ( ${EPATCH_SOURCE##*/} )"
269 echo 218 echo
270 die "Cannot find \$EPATCH_SOURCE!" 219 die "Cannot find \$EPATCH_SOURCE!"
271 fi 220 fi
272 221
273 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}" 222 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
292 ;; 241 ;;
293 esac 242 esac
294 243
295 if [ "${SINGLE_PATCH}" = "no" ] 244 if [ "${SINGLE_PATCH}" = "no" ]
296 then 245 then
297 einfo "Applying various patches (bugfixes/updates) ..." 246 einfo "${EPATCH_MULTI_MSG}"
298 fi 247 fi
299 for x in ${EPATCH_SOURCE} 248 for x in ${EPATCH_SOURCE}
300 do 249 do
301 # New ARCH dependant patch naming scheme ... 250 # New ARCH dependant patch naming scheme ...
302 # 251 #
303 # ???_arch_foo.patch 252 # ???_arch_foo.patch
304 # 253 #
305 if [ -f ${x} ] && \ 254 if [ -f ${x} ] && \
306 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ 255 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "${x/_${ARCH}_}" != "${x}" ] || \
307 [ "${EPATCH_FORCE}" = "yes" ]) 256 [ "${EPATCH_FORCE}" = "yes" ])
308 then 257 then
309 local count=0 258 local count=0
310 local popts="${EPATCH_OPTS}" 259 local popts="${EPATCH_OPTS}"
260 local patchname=${x##*/}
311 261
312 if [ -n "${EPATCH_EXCLUDE}" ] 262 if [ -n "${EPATCH_EXCLUDE}" ]
313 then 263 then
314 if [ "`eval echo \$\{EPATCH_EXCLUDE/${x##*/}\}`" != "${EPATCH_EXCLUDE}" ] 264 if [ "${EPATCH_EXCLUDE/${patchname}}" != "${EPATCH_EXCLUDE}" ]
315 then 265 then
316 continue 266 continue
317 fi 267 fi
318 fi 268 fi
319 269
321 then 271 then
322 if [ -n "${EPATCH_SINGLE_MSG}" ] 272 if [ -n "${EPATCH_SINGLE_MSG}" ]
323 then 273 then
324 einfo "${EPATCH_SINGLE_MSG}" 274 einfo "${EPATCH_SINGLE_MSG}"
325 else 275 else
326 einfo "Applying ${x##*/} ..." 276 einfo "Applying ${patchname} ..."
327 fi 277 fi
328 else 278 else
329 einfo " ${x##*/} ..." 279 einfo " ${patchname} ..."
330 fi 280 fi
331 281
332 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 282 echo "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
333 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 283 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
334 284
335 # Allow for prefix to differ ... im lazy, so shoot me :/ 285 # Allow for prefix to differ ... im lazy, so shoot me :/
336 while [ "${count}" -lt 5 ] 286 while [ "${count}" -lt 5 ]
337 do 287 do
338 # Generate some useful debug info ... 288 # Generate some useful debug info ...
339 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 289 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
340 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 290 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
341 291
342 if [ "${PATCH_SUFFIX}" != "patch" ] 292 if [ "${PATCH_SUFFIX}" != "patch" ]
343 then 293 then
344 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 294 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
345 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 295 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
346 else 296 else
347 PATCH_TARGET="${x}" 297 PATCH_TARGET="${x}"
348 fi 298 fi
349 299
350 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 300 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
351 echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 301 echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
352 302
353 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 303 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
354 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 304 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
355 305
356 if [ "${PATCH_SUFFIX}" != "patch" ] 306 if [ "${PATCH_SUFFIX}" != "patch" ]
357 then 307 then
358 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 308 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1
359 then 309 then
360 echo 310 echo
361 eerror "Could not extract patch!" 311 eerror "Could not extract patch!"
362 #die "Could not extract patch!" 312 #die "Could not extract patch!"
363 count=5 313 count=5
364 break 314 break
365 fi 315 fi
366 fi 316 fi
367 317
368 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 318 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1
369 then 319 then
370 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 320 draw_line "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
371 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 321 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
372 echo "ACTUALLY APPLYING ${x##*/} ..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 322 echo "ACTUALLY APPLYING ${patchname} ..." >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
373 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 323 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
374 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 324 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
375 325
376 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1 326 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real 2>&1
377 327
378 if [ "$?" -ne 0 ] 328 if [ "$?" -ne 0 ]
379 then 329 then
380 cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 330 cat ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
381 echo 331 echo
382 eerror "A dry-run of patch command succeeded, but actually" 332 eerror "A dry-run of patch command succeeded, but actually"
383 eerror "applying the patch failed!" 333 eerror "applying the patch failed!"
384 #die "Real world sux compared to the dreamworld!" 334 #die "Real world sux compared to the dreamworld!"
385 count=5 335 count=5
386 fi 336 fi
387 337
388 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 338 rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
389 339
390 break 340 break
391 fi 341 fi
392 342
393 count=$((count + 1)) 343 count=$((count + 1))
399 fi 349 fi
400 350
401 if [ "${count}" -eq 5 ] 351 if [ "${count}" -eq 5 ]
402 then 352 then
403 echo 353 echo
404 eerror "Failed Patch: ${x##*/}!" 354 eerror "Failed Patch: ${patchname} !"
355 eerror " ( ${PATCH_TARGET} )"
405 eerror 356 eerror
406 eerror "Include in your bugreport the contents of:" 357 eerror "Include in your bugreport the contents of:"
407 eerror 358 eerror
408 eerror " ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}" 359 eerror " ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}"
409 echo 360 echo
410 die "Failed Patch: ${x##*/}!" 361 die "Failed Patch: ${patchname}!"
411 fi 362 fi
412 363
413 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 364 rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
414 365
415 eend 0 366 eend 0
416 fi 367 fi
417 done 368 done
418 if [ "${SINGLE_PATCH}" = "no" ] 369 if [ "${SINGLE_PATCH}" = "no" ]
419 then 370 then
420 einfo "Done with patching" 371 einfo "Done with patching"
421 fi
422}
423
424# This function return true if we are using the NPTL pthreads
425# implementation.
426#
427# <azarah@gentoo.org> (06 March 2003)
428#
429have_NPTL() {
430 cat > ${T}/test-nptl.c <<-"END"
431 #define _XOPEN_SOURCE
432 #include <unistd.h>
433 #include <stdio.h>
434
435 int main()
436 {
437 char buf[255];
438 char *str = buf;
439
440 confstr(_CS_GNU_LIBPTHREAD_VERSION, str, 255);
441 if (NULL != str) {
442 printf("%s\n", str);
443 if (NULL != strstr(str, "NPTL"))
444 return 0;
445 }
446
447 return 1;
448 }
449 END
450
451 einfon "Checking for _CS_GNU_LIBPTHREAD_VERSION support in glibc ..."
452 if gcc -o ${T}/nptl ${T}/test-nptl.c &> /dev/null
453 then
454 echo "yes"
455 einfon "Checking what PTHREADS implementation we have ..."
456 if ${T}/nptl
457 then
458 return 0
459 else
460 return 1
461 fi
462 else
463 echo "no"
464 fi
465
466 return 1
467}
468
469# This function check how many cpu's are present, and then set
470# -j in MAKEOPTS accordingly.
471#
472# Thanks to nall <nall@gentoo.org> for this.
473#
474get_number_of_jobs() {
475 local jobs=0
476
477 if [ ! -r /proc/cpuinfo ]
478 then
479 return 1
480 fi
481
482 # This bit is from H?kan Wessberg <nacka-gentoo@refug.org>, bug #13565.
483 if [ "`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | wc -l`" -gt 0 ]
484 then
485 ADMINOPTS="`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | cut -d= -f2 | sed 's/\"//g'`"
486 ADMINPARAM="`echo ${ADMINOPTS} | gawk '{match($0, /-j *[0-9]*/, opt); print opt[0]}'`"
487 ADMINPARAM="${ADMINPARAM/-j}"
488 fi
489
490 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j *[0-9]*::g'`"
491
492 if [ "${ARCH}" = "amd64" -o "${ARCH}" = "x86" -o "${ARCH}" = "hppa" -o \
493 "${ARCH}" = "arm" -o "${ARCH}" = "mips" -o "${ARCH}" = "ia64" ]
494 then
495 # these archs will always have "[Pp]rocessor"
496 jobs="$((`grep -c ^[Pp]rocessor /proc/cpuinfo` * 2))"
497
498 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ]
499 then
500 # sparc always has "ncpus active"
501 jobs="$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
502
503 elif [ "${ARCH}" = "alpha" ]
504 then
505 # alpha has "cpus active", but only when compiled with SMP
506 if [ "`grep -c "^cpus active" /proc/cpuinfo`" -eq 1 ]
507 then
508 jobs="$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
509 else
510 jobs=2
511 fi
512
513 elif [ "${ARCH}" = "ppc" -o "${ARCH}" = "ppc64" ]
514 then
515 # ppc has "processor", but only when compiled with SMP
516 if [ "`grep -c "^processor" /proc/cpuinfo`" -eq 1 ]
517 then
518 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
519 else
520 jobs=2
521 fi
522 elif [ "${ARCH}" = "s390" ]
523 then
524 # s390 has "# processors : "
525 jobs="$((`grep "^\# processors" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
526 else
527 jobs="$((`grep -c ^cpu /proc/cpuinfo` * 2))"
528 die "Unknown ARCH -- ${ARCH}!"
529 fi
530
531 # Make sure the number is valid ...
532 if [ "${jobs}" -lt 1 ]
533 then
534 jobs=1
535 fi
536
537 if [ -n "${ADMINPARAM}" ]
538 then
539 if [ "${jobs}" -gt "${ADMINPARAM}" ]
540 then
541 einfo "Setting make jobs to \"-j${ADMINPARAM}\" to ensure successful merge ..."
542 export MAKEOPTS="${MAKEOPTS} -j${ADMINPARAM}"
543 else
544 einfo "Setting make jobs to \"-j${jobs}\" to ensure successful merge ..."
545 export MAKEOPTS="${MAKEOPTS} -j${jobs}"
546 fi
547 fi 372 fi
548} 373}
549 374
550# Cheap replacement for when debianutils (and thus mktemp) 375# Cheap replacement for when debianutils (and thus mktemp)
551# does not exist on the users system 376# does not exist on the users system
585# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 410# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
586# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> 411# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
587# 412#
588# egetent(database, key) 413# egetent(database, key)
589egetent() { 414egetent() {
590 if useq ppc-macos ; then 415 if [[ "${USERLAND}" == "Darwin" ]] ; then
591 case "$2" in 416 case "$2" in
592 *[!0-9]*) # Non numeric 417 *[!0-9]*) # Non numeric
593 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 418 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
594 ;; 419 ;;
595 *) # Numeric 420 *) # Numeric
596 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" 421 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
597 ;; 422 ;;
598 esac 423 esac
599 elif useq x86-fbsd ; then 424 elif [[ "${USERLAND}" == "BSD" ]] ; then
600 local action 425 local action
601 if [ "$1" == "passwd" ] 426 if [ "$1" == "passwd" ]
602 then 427 then
603 action="user" 428 action="user"
604 else 429 else
624# homedir: /dev/null 449# homedir: /dev/null
625# groups: none 450# groups: none
626# extra: comment of 'added by portage for ${PN}' 451# extra: comment of 'added by portage for ${PN}'
627enewuser() { 452enewuser() {
628 # get the username 453 # get the username
629 local euser="$1"; shift 454 local euser=$1; shift
630 if [ -z "${euser}" ] 455 if [[ -z ${euser} ]] ; then
631 then
632 eerror "No username specified !" 456 eerror "No username specified !"
633 die "Cannot call enewuser without a username" 457 die "Cannot call enewuser without a username"
634 fi 458 fi
635 459
636 # lets see if the username already exists 460 # lets see if the username already exists
637 if [ "${euser}" == "`egetent passwd \"${euser}\" | cut -d: -f1`" ] 461 if [[ ${euser} == $(egetent passwd "${euser}" | cut -d: -f1) ]] ; then
638 then
639 return 0 462 return 0
640 fi 463 fi
641 einfo "Adding user '${euser}' to your system ..." 464 einfo "Adding user '${euser}' to your system ..."
642 465
643 # options to pass to useradd 466 # options to pass to useradd
644 local opts= 467 local opts=
645 468
646 # handle uid 469 # handle uid
647 local euid="$1"; shift 470 local euid=$1; shift
648 if [ ! -z "${euid}" ] && [ "${euid}" != "-1" ] 471 if [[ ! -z ${euid} ]] && [[ ${euid} != "-1" ]] ; then
649 then
650 if [ "${euid}" -gt 0 ] 472 if [[ ${euid} -gt 0 ]] ; then
651 then
652 if [ ! -z "`egetent passwd ${euid}`" ] 473 if [[ ! -z $(egetent passwd ${euid}) ]] ; then
653 then
654 euid="next" 474 euid="next"
655 fi 475 fi
656 else 476 else
657 eerror "Userid given but is not greater than 0 !" 477 eerror "Userid given but is not greater than 0 !"
658 die "${euid} is not a valid UID" 478 die "${euid} is not a valid UID"
659 fi 479 fi
660 else 480 else
661 euid="next" 481 euid="next"
662 fi 482 fi
663 if [ "${euid}" == "next" ] 483 if [[ ${euid} == "next" ]] ; then
664 then
665 local pwrange 484 local pwrange
666 if [ "${USERLAND}" == "BSD" ] ; then 485 if [[ ${USERLAND} == "BSD" ]] ; then
667 pwrange="`jot 898 101`" 486 pwrange=$(jot 898 101)
668 else 487 else
669 pwrange="`seq 101 999`" 488 pwrange=$(seq 101 999)
670 fi 489 fi
671 for euid in ${pwrange} ; do 490 for euid in ${pwrange} ; do
672 [ -z "`egetent passwd ${euid}`" ] && break 491 [[ -z $(egetent passwd ${euid}) ]] && break
673 done 492 done
674 fi 493 fi
675 opts="${opts} -u ${euid}" 494 opts="${opts} -u ${euid}"
676 einfo " - Userid: ${euid}" 495 einfo " - Userid: ${euid}"
677 496
678 # handle shell 497 # handle shell
679 local eshell="$1"; shift 498 local eshell=$1; shift
680 if [ ! -z "${eshell}" ] && [ "${eshell}" != "-1" ] 499 if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then
681 then
682 if [ ! -e "${eshell}" ] 500 if [[ ! -e ${eshell} ]] ; then
683 then
684 eerror "A shell was specified but it does not exist !" 501 eerror "A shell was specified but it does not exist !"
685 die "${eshell} does not exist" 502 die "${eshell} does not exist"
686 fi 503 fi
687 else 504 else
688 if [ "${USERLAND}" == "BSD" ] 505 case ${USERLAND} in
689 then
690 eshell="/usr/bin/false" 506 Darwin) eshell="/usr/bin/false";;
691 else 507 BSD) eshell="/usr/sbin/nologin";;
692 eshell="/bin/false" 508 *) eshell="/bin/false";;
693 fi 509 esac
694 fi 510 fi
695 einfo " - Shell: ${eshell}" 511 einfo " - Shell: ${eshell}"
696 opts="${opts} -s ${eshell}" 512 opts="${opts} -s ${eshell}"
697 513
698 # handle homedir 514 # handle homedir
699 local ehome="$1"; shift 515 local ehome=$1; shift
700 if [ -z "${ehome}" ] && [ "${eshell}" != "-1" ] 516 if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]] ; then
701 then
702 ehome="/dev/null" 517 ehome="/dev/null"
703 fi 518 fi
704 einfo " - Home: ${ehome}" 519 einfo " - Home: ${ehome}"
705 opts="${opts} -d ${ehome}" 520 opts="${opts} -d ${ehome}"
706 521
707 # handle groups 522 # handle groups
708 local egroups="$1"; shift 523 local egroups=$1; shift
709 if [ ! -z "${egroups}" ] 524 if [[ ! -z ${egroups} ]] ; then
710 then
711 local oldifs="${IFS}" 525 local oldifs=${IFS}
712 local defgroup="" exgroups="" 526 local defgroup="" exgroups=""
713 527
714 export IFS="," 528 export IFS=","
715 for g in ${egroups} 529 for g in ${egroups} ; do
716 do
717 export IFS="${oldifs}" 530 export IFS=${oldifs}
718 if [ -z "`egetent group \"${g}\"`" ] 531 if [[ -z $(egetent group "${g}") ]] ; then
719 then
720 eerror "You must add group ${g} to the system first" 532 eerror "You must add group ${g} to the system first"
721 die "${g} is not a valid GID" 533 die "${g} is not a valid GID"
722 fi 534 fi
723 if [ -z "${defgroup}" ] 535 if [[ -z ${defgroup} ]] ; then
724 then
725 defgroup="${g}" 536 defgroup=${g}
726 else 537 else
727 exgroups="${exgroups},${g}" 538 exgroups="${exgroups},${g}"
728 fi 539 fi
729 export IFS="," 540 export IFS=","
730 done 541 done
731 export IFS="${oldifs}" 542 export IFS=${oldifs}
732 543
733 opts="${opts} -g ${defgroup}" 544 opts="${opts} -g ${defgroup}"
734 if [ ! -z "${exgroups}" ] 545 if [[ ! -z ${exgroups} ]] ; then
735 then
736 opts="${opts} -G ${exgroups:1}" 546 opts="${opts} -G ${exgroups:1}"
737 fi 547 fi
738 else 548 else
739 egroups="(none)" 549 egroups="(none)"
740 fi 550 fi
741 einfo " - Groups: ${egroups}" 551 einfo " - Groups: ${egroups}"
742 552
743 # handle extra and add the user 553 # handle extra and add the user
744 local eextra="$@"
745 local oldsandbox="${SANDBOX_ON}" 554 local oldsandbox=${SANDBOX_ON}
746 export SANDBOX_ON="0" 555 export SANDBOX_ON="0"
747 if useq ppc-macos 556 case ${USERLAND} in
748 then 557 Darwin)
749 ### Make the user 558 ### Make the user
750 if [ -z "${eextra}" ] 559 if [[ -z $@ ]] ; then
751 then
752 dscl . create /users/${euser} uid ${euid} 560 dscl . create /users/${euser} uid ${euid}
753 dscl . create /users/${euser} shell ${eshell} 561 dscl . create /users/${euser} shell ${eshell}
754 dscl . create /users/${euser} home ${ehome} 562 dscl . create /users/${euser} home ${ehome}
755 dscl . create /users/${euser} realname "added by portage for ${PN}" 563 dscl . create /users/${euser} realname "added by portage for ${PN}"
756 ### Add the user to the groups specified 564 ### Add the user to the groups specified
757 local oldifs="${IFS}" 565 local oldifs=${IFS}
758 export IFS="," 566 export IFS=","
759 for g in ${egroups} 567 for g in ${egroups} ; do
760 do
761 dscl . merge /groups/${g} users ${euser} 568 dscl . merge /groups/${g} users ${euser}
762 done 569 done
763 export IFS="${oldifs}" 570 export IFS=${oldifs}
764 else 571 else
765 einfo "Extra options are not supported on macos yet" 572 einfo "Extra options are not supported on Darwin yet"
766 einfo "Please report the ebuild along with the info below" 573 einfo "Please report the ebuild along with the info below"
767 einfo "eextra: ${eextra}" 574 einfo "eextra: $@"
768 die "Required function missing" 575 die "Required function missing"
769 fi 576 fi
770 elif use x86-fbsd ; then 577 ;;
771 if [ -z "${eextra}" ] 578 BSD)
772 then 579 if [[ -z $@ ]] ; then
773 pw useradd ${euser} ${opts} \ 580 pw useradd ${euser} ${opts} \
774 -c "added by portage for ${PN}" \ 581 -c "added by portage for ${PN}" \
775 die "enewuser failed" 582 die "enewuser failed"
776 else 583 else
777 einfo " - Extra: ${eextra}" 584 einfo " - Extra: $@"
778 pw useradd ${euser} ${opts} \ 585 pw useradd ${euser} ${opts} \
779 -c ${eextra} || die "enewuser failed" 586 "$@" || die "enewuser failed"
780 fi 587 fi
781 else 588 ;;
782 if [ -z "${eextra}" ] 589 *)
783 then 590 if [[ -z $@ ]] ; then
784 useradd ${opts} ${euser} \ 591 useradd ${opts} ${euser} \
785 -c "added by portage for ${PN}" \ 592 -c "added by portage for ${PN}" \
786 || die "enewuser failed" 593 || die "enewuser failed"
787 else 594 else
788 einfo " - Extra: ${eextra}" 595 einfo " - Extra: $@"
789 useradd ${opts} ${euser} ${eextra} \ 596 useradd ${opts} ${euser} "$@" \
790 || die "enewuser failed" 597 || die "enewuser failed"
791 fi 598 fi
792 fi 599 ;;
600 esac
793 export SANDBOX_ON="${oldsandbox}" 601 export SANDBOX_ON=${oldsandbox}
794 602
795 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ] 603 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ]
796 then 604 then
797 einfo " - Creating ${ehome} in ${D}" 605 einfo " - Creating ${ehome} in ${D}"
798 dodir ${ehome} 606 dodir ${ehome}
835 then 643 then
836 if [ "${egid}" -gt 0 ] 644 if [ "${egid}" -gt 0 ]
837 then 645 then
838 if [ -z "`egetent group ${egid}`" ] 646 if [ -z "`egetent group ${egid}`" ]
839 then 647 then
840 if useq ppc-macos ; then 648 if [[ "${USERLAND}" == "Darwin" ]]; then
841 opts="${opts} ${egid}" 649 opts="${opts} ${egid}"
842 else 650 else
843 opts="${opts} -g ${egid}" 651 opts="${opts} -g ${egid}"
844 fi 652 fi
845 else 653 else
859 opts="${opts} ${eextra}" 667 opts="${opts} ${eextra}"
860 668
861 # add the group 669 # add the group
862 local oldsandbox="${SANDBOX_ON}" 670 local oldsandbox="${SANDBOX_ON}"
863 export SANDBOX_ON="0" 671 export SANDBOX_ON="0"
864 if useq ppc-macos ; then 672 if [[ "${USERLAND}" == "Darwin" ]]; then
865 if [ ! -z "${eextra}" ]; 673 if [ ! -z "${eextra}" ];
866 then 674 then
867 einfo "Extra options are not supported on macos yet" 675 einfo "Extra options are not supported on Darwin/OS X yet"
868 einfo "Please report the ebuild along with the info below" 676 einfo "Please report the ebuild along with the info below"
869 einfo "eextra: ${eextra}" 677 einfo "eextra: ${eextra}"
870 die "Required function missing" 678 die "Required function missing"
871 fi 679 fi
872 680
877 [ -z "`egetent group ${egid}`" ] && break 685 [ -z "`egetent group ${egid}`" ] && break
878 done 686 done
879 esac 687 esac
880 dscl . create /groups/${egroup} gid ${egid} 688 dscl . create /groups/${egroup} gid ${egid}
881 dscl . create /groups/${egroup} passwd '*' 689 dscl . create /groups/${egroup} passwd '*'
882 elif use x86-fbsd ; then 690 elif [[ "${USERLAND}" == "BSD" ]] ; then
883 case ${egid} in 691 case ${egid} in
884 *[!0-9]*) # Non numeric 692 *[!0-9]*) # Non numeric
885 for egid in `jot 898 101`; do 693 for egid in `jot 898 101`; do
886 [ -z "`egetent group ${egid}`" ] && break 694 [ -z "`egetent group ${egid}`" ] && break
887 done 695 done
922# name: the name that will show up in the menu 730# name: the name that will show up in the menu
923# icon: give your little like a pretty little icon ... 731# icon: give your little like a pretty little icon ...
924# this can be relative (to /usr/share/pixmaps) or 732# this can be relative (to /usr/share/pixmaps) or
925# a full path to an icon 733# a full path to an icon
926# type: what kind of application is this ? for categories: 734# type: what kind of application is this ? for categories:
927# http://www.freedesktop.org/standards/menu-spec/ 735# http://www.freedesktop.org/wiki/Standards_2fmenu_2dspec
928# path: if your app needs to startup in a specific dir 736# path: if your app needs to startup in a specific dir
929make_desktop_entry() { 737make_desktop_entry() {
930 [ -z "$1" ] && eerror "make_desktop_entry: You must specify the executable" && return 1 738 [[ -z $1 ]] && eerror "make_desktop_entry: You must specify the executable" && return 1
931 739
932 local exec="${1}" 740 local exec=${1}
933 local name="${2:-${PN}}" 741 local name=${2:-${PN}}
934 local icon="${3:-${PN}.png}" 742 local icon=${3:-${PN}.png}
935 local type="${4}" 743 local type=${4}
936 local subdir="${6}" 744 local path=${5}
937 local path="${5:-${GAMES_BINDIR}}" 745
938 if [ -z "${type}" ] 746 if [[ -z ${type} ]] ; then
939 then 747 local catmaj=${CATEGORY%%-*}
940 case ${CATEGORY} in 748 local catmin=${CATEGORY##*-}
941 "app-emulation") 749 case ${catmaj} in
942 type=Emulator 750 app)
943 subdir="Emulation" 751 case ${catmin} in
752 admin) type=System;;
753 cdr) type=DiscBurning;;
754 dicts) type=Dictionary;;
755 editors) type=TextEditor;;
756 emacs) type=TextEditor;;
757 emulation) type=Emulator;;
758 laptop) type=HardwareSettings;;
759 office) type=Office;;
760 vim) type=TextEditor;;
761 xemacs) type=TextEditor;;
762 *) type=;;
763 esac
944 ;; 764 ;;
945 "games-"*) 765
946 type=Game 766 dev)
947 subdir="Games" 767 type="Development"
948 ;; 768 ;;
949 "net-"*) 769
950 type=Network 770 games)
951 subdir="${type}" 771 [[ -z ${path} ]] && path=${GAMES_BINDIR}
772
773 case ${catmin} in
774 action) type=ActionGame;;
775 arcade) type=ArcadeGame;;
776 board) type=BoardGame;;
777 kid) type=KidsGame;;
778 emulation) type=Emulator;;
779 puzzle) type=LogicGame;;
780 rpg) type=RolePlaying;;
781 roguelike) type=RolePlaying;;
782 simulation) type=Simulation;;
783 sports) type=SportsGame;;
784 strategy) type=StrategyGame;;
785 *) type=;;
786 esac
787 type="Game;${type}"
952 ;; 788 ;;
789
790 mail)
791 type="Network;Email"
792 ;;
793
794 media)
795 case ${catmin} in
796 gfx) type=Graphics;;
797 radio) type=Tuner;;
798 sound) type=Audio;;
799 tv) type=TV;;
800 video) type=Video;;
801 *) type=;;
802 esac
803 type="AudioVideo;${type}"
804 ;;
805
806 net)
807 case ${catmin} in
808 dialup) type=Dialup;;
809 ftp) type=FileTransfer;;
810 im) type=InstantMessaging;;
811 irc) type=IRCClient;;
812 mail) type=Email;;
813 news) type=News;;
814 nntp) type=News;;
815 p2p) type=FileTransfer;;
816 *) type=;;
817 esac
818 type="Network;${type}"
819 ;;
820
821 sci)
822 case ${catmin} in
823 astro*) type=Astronomoy;;
824 bio*) type=Biology;;
825 calc*) type=Calculator;;
826 chem*) type=Chemistry;;
827 geo*) type=Geology;;
828 math*) type=Math;;
829 *) type=;;
830 esac
831 type="Science;${type}"
832 ;;
833
834 www)
835 case ${catmin} in
836 client) type=WebBrowser;;
837 *) type=;;
838 esac
839 type="Network"
840 ;;
841
953 *) 842 *)
954 type= 843 type=
955 subdir=
956 ;; 844 ;;
957 esac 845 esac
958 fi 846 fi
847 if [ "${SLOT}" == "0" ] ; then
848 local desktop_name="${PN}"
849 else
850 local desktop_name="${PN}-${SLOT}"
851 fi
959 local desktop="${T}/${exec}.desktop" 852 local desktop=${T}/${exec%% *}-${desktop_name}.desktop
960 853
961echo "[Desktop Entry] 854echo "[Desktop Entry]
962Encoding=UTF-8 855Encoding=UTF-8
963Version=0.9.2 856Version=0.9.2
964Name=${name} 857Name=${name}
980# make_desktop_entry(<title>, <command>) 873# make_desktop_entry(<title>, <command>)
981# title: File to execute to start the Window Manager 874# title: File to execute to start the Window Manager
982# command: Name of the Window Manager 875# command: Name of the Window Manager
983 876
984make_session_desktop() { 877make_session_desktop() {
985
986 [ -z "$1" ] && eerror "make_session_desktop: You must specify the title" && return 1 878 [[ -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 879 [[ -z $2 ]] && eerror "make_session_desktop: You must specify the command" && return 1
988 880
989 local title="${1}" 881 local title=$1
990 local command="${2}" 882 local command=$2
991 local desktop="${T}/${wm}.desktop" 883 local desktop=${T}/${wm}.desktop
992 884
993echo "[Desktop Entry] 885echo "[Desktop Entry]
994Encoding=UTF-8 886Encoding=UTF-8
995Name=${title} 887Name=${title}
996Comment=This session logs you into ${title} 888Comment=This session logs you into ${title}
998TryExec=${command} 890TryExec=${command}
999Type=Application" > "${desktop}" 891Type=Application" > "${desktop}"
1000 892
1001 insinto /usr/share/xsessions 893 insinto /usr/share/xsessions
1002 doins "${desktop}" 894 doins "${desktop}"
1003
1004 return 0
1005} 895}
1006 896
1007domenu() { 897domenu() {
1008 local i 898 local i j
1009 local j
1010 insinto /usr/share/applications 899 insinto /usr/share/applications
1011 for i in ${@} 900 for i in "$@" ; do
1012 do
1013 if [ -f "${i}" ]; 901 if [[ -f ${i} ]] ; then
1014 then
1015 doins ${i} 902 doins "${i}"
1016 elif [ -d "${i}" ]; 903 elif [[ -d ${i} ]] ; then
1017 then
1018 for j in ${i}/*.desktop 904 for j in "${i}"/*.desktop ; do
1019 do
1020 doins ${j} 905 doins "${j}"
1021 done 906 done
1022 fi 907 fi
1023 done 908 done
1024} 909}
910newmenu() {
911 insinto /usr/share/applications
912 newins "$1" "$2"
913}
1025 914
1026doicon() { 915doicon() {
1027 local i 916 local i j
1028 local j
1029 insinto /usr/share/pixmaps 917 insinto /usr/share/pixmaps
1030 for i in ${@} 918 for i in "$@" ; do
1031 do
1032 if [ -f "${i}" ]; 919 if [[ -f ${i} ]] ; then
1033 then
1034 doins ${i} 920 doins "${i}"
1035 elif [ -d "${i}" ]; 921 elif [[ -d ${i} ]] ; then
1036 then
1037 for j in ${i}/*.png 922 for j in "${i}"/*.png ; do
1038 do
1039 doins ${j} 923 doins "${j}"
1040 done 924 done
1041 fi 925 fi
1042 done 926 done
927}
928newicon() {
929 insinto /usr/share/pixmaps
930 newins "$1" "$2"
1043} 931}
1044 932
1045############################################################## 933##############################################################
1046# END: Handle .desktop files and menu entries # 934# END: Handle .desktop files and menu entries #
1047############################################################## 935##############################################################
1448 local mline="" 1336 local mline=""
1449 local showedmsg=0 1337 local showedmsg=0
1450 1338
1451 for mline in $(mount | egrep -e '(iso|cdrom)' | awk '{print $3}') ; do 1339 for mline in $(mount | egrep -e '(iso|cdrom)' | awk '{print $3}') ; do
1452 [[ -d ${mline}/${dir} ]] || continue 1340 [[ -d ${mline}/${dir} ]] || continue
1453 [[ ! -z $(find ${mline}/${dir} -iname ${file} -maxdepth 1) ]] \ 1341 [[ ! -z $(find ${mline}/${dir} -maxdepth 1 -iname ${file}) ]] \
1454 && export CDROM_ROOT=${mline} 1342 && export CDROM_ROOT=${mline}
1455 done 1343 done
1456 1344
1457 if [[ -z ${CDROM_ROOT} ]] ; then 1345 if [[ -z ${CDROM_ROOT} ]] ; then
1458 echo 1346 echo
1492# directories and uses the intersection of the lists. 1380# directories and uses the intersection of the lists.
1493# The -u builds a list of po files found in all the 1381# The -u builds a list of po files found in all the
1494# directories and uses the union of the lists. 1382# directories and uses the union of the lists.
1495strip-linguas() { 1383strip-linguas() {
1496 local ls newls 1384 local ls newls
1497 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1385 if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then
1498 local op="$1"; shift 1386 local op=$1; shift
1499 ls=" $(find "$1" -name '*.po' -printf '%f ') "; shift 1387 ls=" $(find "$1" -name '*.po' -printf '%f ') "; shift
1500 local d f 1388 local d f
1501 for d in "$@" ; do 1389 for d in "$@" ; do
1502 if [ "${op}" == "-u" ] ; then 1390 if [[ ${op} == "-u" ]] ; then
1503 newls="${ls}" 1391 newls=${ls}
1504 else 1392 else
1505 newls="" 1393 newls=""
1506 fi 1394 fi
1507 for f in $(find "$d" -name '*.po' -printf '%f ') ; do 1395 for f in $(find "$d" -name '*.po' -printf '%f ') ; do
1508 if [ "${op}" == "-i" ] ; then 1396 if [[ ${op} == "-i" ]] ; then
1509 [ "${ls/ ${f} /}" != "${ls}" ] && newls="${newls} ${f}" 1397 [[ ${ls/ ${f} /} != ${ls} ]] && newls="${newls} ${f}"
1510 else 1398 else
1511 [ "${ls/ ${f} /}" == "${ls}" ] && newls="${newls} ${f}" 1399 [[ ${ls/ ${f} /} == ${ls} ]] && newls="${newls} ${f}"
1512 fi 1400 fi
1513 done 1401 done
1514 ls="${newls}" 1402 ls=${newls}
1515 done 1403 done
1516 ls="${ls//.po}" 1404 ls=${ls//.po}
1517 else 1405 else
1518 ls="$@" 1406 ls=$@
1519 fi 1407 fi
1520 1408
1521 ls=" ${ls} " 1409 ls=" ${ls} "
1522 newls="" 1410 newls=""
1523 for f in ${LINGUAS} ; do 1411 for f in ${LINGUAS} ; do
1524 if [ "${ls/ ${f} /}" != "${ls}" ] ; then 1412 if [[ ${ls/ ${f} /} != ${ls} ]] ; then
1525 newls="${newls} ${f}" 1413 newls="${newls} ${f}"
1526 else 1414 else
1527 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" 1415 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA"
1528 fi 1416 fi
1529 done 1417 done
1530 if [ -z "${newls}" ] ; then 1418 if [[ -z ${newls} ]] ; then
1531 unset LINGUAS 1419 export LINGUAS=""
1532 else 1420 else
1533 export LINGUAS="${newls}" 1421 export LINGUAS=${newls:1}
1534 fi 1422 fi
1535} 1423}
1536 1424
1537# moved from kernel.eclass since they are generally useful outside of 1425# moved from kernel.eclass since they are generally useful outside of
1538# kernel.eclass -iggy (20041002) 1426# kernel.eclass -iggy (20041002)
1540# the following functions are useful in kernel module ebuilds, etc. 1428# the following functions are useful in kernel module ebuilds, etc.
1541# for an example see ivtv or drbd ebuilds 1429# for an example see ivtv or drbd ebuilds
1542 1430
1543# set's ARCH to match what the kernel expects 1431# set's ARCH to match what the kernel expects
1544set_arch_to_kernel() { 1432set_arch_to_kernel() {
1433 i=10
1434 while ((i--)) ; do
1435 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1436 done
1545 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}" 1437 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}"
1546 case ${ARCH} in 1438 case ${ARCH} in
1547 x86) export ARCH="i386";; 1439 x86) export ARCH="i386";;
1548 amd64) export ARCH="x86_64";; 1440 amd64) export ARCH="x86_64";;
1549 hppa) export ARCH="parisc";; 1441 hppa) export ARCH="parisc";;
1550 mips) export ARCH="mips";; 1442 mips) export ARCH="mips";;
1443 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}";; 1444 *) export ARCH="${ARCH}";;
1552 esac 1445 esac
1553} 1446}
1554 1447
1555# set's ARCH back to what portage expects 1448# set's ARCH back to what portage expects
1556set_arch_to_portage() { 1449set_arch_to_portage() {
1450 i=10
1451 while ((i--)) ; do
1452 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1453 done
1557 export ARCH="${EUTILS_ECLASS_PORTAGE_ARCH}" 1454 export ARCH="${EUTILS_ECLASS_PORTAGE_ARCH}"
1558} 1455}
1559 1456
1560# Jeremy Huddleston <eradicator@gentoo.org>: 1457# Jeremy Huddleston <eradicator@gentoo.org>:
1561# preserve_old_lib /path/to/libblah.so.0 1458# preserve_old_lib /path/to/libblah.so.0
1607 einfo "After doing that, you can safely remove ${LIB}" 1504 einfo "After doing that, you can safely remove ${LIB}"
1608 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild" 1505 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild"
1609 fi 1506 fi
1610} 1507}
1611 1508
1612# Hack for people to figure out if a package was built with 1509# Hack for people to figure out if a package was built with
1613# certain USE flags 1510# certain USE flags
1614# 1511#
1615# Usage: built_with_use [-a|-o] <DEPEND ATOM> <List of USE flags> 1512# Usage: built_with_use [-a|-o] <DEPEND ATOM> <List of USE flags>
1616# ex: built_with_use xchat gtk2 1513# ex: built_with_use xchat gtk2
1617# 1514#
1638 shift 1535 shift
1639 done 1536 done
1640 [[ ${opt} = "-a" ]] 1537 [[ ${opt} = "-a" ]]
1641} 1538}
1642 1539
1643# Many configure scripts wrongly bail when a C++ compiler 1540# Many configure scripts wrongly bail when a C++ compiler
1644# could not be detected. #73450 1541# could not be detected. #73450
1645epunt_cxx() { 1542epunt_cxx() {
1646 local dir=$1 1543 local dir=$1
1647 [[ -z ${dir} ]] && dir=${S} 1544 [[ -z ${dir} ]] && dir=${S}
1648 ebegin "Removing useless C++ checks" 1545 ebegin "Removing useless C++ checks"
1651 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null 1548 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null
1652 done 1549 done
1653 eend 0 1550 eend 0
1654} 1551}
1655 1552
1656# get_abi_var <VAR> [<ABI>] 1553# dopamd <file> [more files]
1657# returns the value of ${<VAR>_<ABI>} which should be set in make.defaults
1658# 1554#
1659# ex: 1555# Install pam auth config file in /etc/pam.d
1660# CFLAGS=$(get_abi_var CFLAGS sparc32) # CFLAGS=-m32 1556dopamd() {
1661# 1557 [[ -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 eval echo \${${flag}_${abi}}
1683}
1684 1558
1685get_abi_CFLAGS() { get_abi_var CFLAGS $1; } 1559 use pam || return 0
1686get_abi_CXXFLAGS() { get_abi_var CXXFLAGS $1; }
1687get_abi_ASFLAGS() { get_abi_var ASFLAGS $1; }
1688get_abi_LIBDIR() { get_abi_var LIBDIR $1; }
1689 1560
1561 INSDESTTREE=/etc/pam.d \
1562 doins "$@" || die "failed to install $@"
1563}
1564# newpamd <old name> <new name>
1565#
1566# Install pam file <old name> as <new name> in /etc/pam.d
1567newpamd() {
1568 [[ $# -ne 2 ]] && die "newpamd requires two arguements"
1569
1570 use pam || return 0
1571
1572 INSDESTTREE=/etc/pam.d \
1573 newins "$1" "$2" || die "failed to install $1 as $2"
1574}
1575
1576# make a wrapper script ...
1577# NOTE: this was originally games_make_wrapper, but I noticed other places where
1578# this could be used, so I have moved it here and made it not games-specific
1579# -- wolf31o2
1580# $1 == wrapper name
1581# $2 == binary to run
1582# $3 == directory to chdir before running binary
1583# $4 == extra LD_LIBRARY_PATH's (make it : delimited)
1584# $5 == path for wrapper
1585make_wrapper() {
1586 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5
1587 local tmpwrapper=$(emktemp)
1588 cat << EOF > "${tmpwrapper}"
1589#!/bin/sh
1590cd "${chdir}"
1591export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
1592exec ${bin} "\$@"
1593EOF
1594 chmod go+rx "${tmpwrapper}"
1595 if [ -n "${5}" ]
1596 then
1597 exeinto ${5}
1598 newexe "${tmpwrapper}" "${wrapper}"
1599 else
1600 newbin "${tmpwrapper}" "${wrapper}"
1601 fi
1602}

Legend:
Removed from v.1.135  
changed lines
  Added in v.1.182

  ViewVC Help
Powered by ViewVC 1.1.20