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

Diff of /eclass/eutils.eclass

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

Revision 1.166 Revision 1.191
1# Copyright 1999-2005 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.166 2005/04/15 22:01:42 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.191 2005/07/13 19:15:05 eradicator 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 12inherit multilib
13ECLASS=eutils
14INHERITED="$INHERITED $ECLASS"
15 13
16DEPEND="!bootstrap? ( sys-devel/patch )" 14DEPEND="!bootstrap? ( sys-devel/patch )"
15# sys-apps/shadow is needed for useradd, etc, bug #94745.
17 16
18DESCRIPTION="Based on the ${ECLASS} eclass" 17DESCRIPTION="Based on the ${ECLASS} eclass"
19 18
20# Wait for the supplied number of seconds. If no argument is supplied, defaults 19# Wait for the supplied number of seconds. If no argument is supplied, defaults
21# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not 20# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not
68 dodir /usr/${libdir} 67 dodir /usr/${libdir}
69 68
70 for lib in "${@}" ; do 69 for lib in "${@}" ; do
71 cat > "${D}/usr/${libdir}/${lib}" <<-END_LDSCRIPT 70 cat > "${D}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
72 /* GNU ld script 71 /* GNU ld script
73 Since Gentoo has critical dynamic libraries 72 Since Gentoo has critical dynamic libraries
74 in /lib, and the static versions in /usr/lib, 73 in /lib, and the static versions in /usr/lib,
75 we need to have a "fake" dynamic lib in /usr/lib, 74 we need to have a "fake" dynamic lib in /usr/lib,
76 otherwise we run into linking problems. 75 otherwise we run into linking problems.
77 76
78 See bug http://bugs.gentoo.org/4411 for more info. 77 See bug http://bugs.gentoo.org/4411 for more info.
79 */ 78 */
80 GROUP ( /${libdir}/${lib} ) 79 GROUP ( /${libdir}/${lib} )
81 END_LDSCRIPT 80 END_LDSCRIPT
82 fperms a+x "/usr/${libdir}/${lib}" 81 fperms a+x "/usr/${libdir}/${lib}"
118EPATCH_SOURCE="${WORKDIR}/patch" 117EPATCH_SOURCE="${WORKDIR}/patch"
119# Default extension for patches 118# Default extension for patches
120EPATCH_SUFFIX="patch.bz2" 119EPATCH_SUFFIX="patch.bz2"
121# Default options for patch 120# Default options for patch
122# Set -g0 to keep RCS, ClearCase, Perforce and SCCS happy. Bug #24571 121# Set -g0 to keep RCS, ClearCase, Perforce and SCCS happy. Bug #24571
123EPATCH_OPTS="-g0" 122# Set --no-backup-if-mismatch so we don't leave '.orig' files behind.
123EPATCH_OPTS="-g0 --no-backup-if-mismatch"
124# List of patches not to apply. Not this is only file names, 124# List of patches not to apply. Not this is only file names,
125# and not the full path .. 125# and not the full path ..
126EPATCH_EXCLUDE="" 126EPATCH_EXCLUDE=""
127# Change the printed message for a single patch. 127# Change the printed message for a single patch.
128EPATCH_SINGLE_MSG="" 128EPATCH_SINGLE_MSG=""
129# Change the printed message for multiple patches.
130EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
129# Force applying bulk patches even if not following the style: 131# Force applying bulk patches even if not following the style:
130# 132#
131# ??_${ARCH}_foo.${EPATCH_SUFFIX} 133# ??_${ARCH}_foo.${EPATCH_SUFFIX}
132# 134#
133EPATCH_FORCE="no" 135EPATCH_FORCE="no"
174 local x="" 176 local x=""
175 177
176 if [ "$#" -gt 1 ] 178 if [ "$#" -gt 1 ]
177 then 179 then
178 local m="" 180 local m=""
179 einfo "${#} patches to apply ..."
180 for m in "$@" ; do 181 for m in "$@" ; do
181 epatch "${m}" 182 epatch "${m}"
182 done 183 done
183 return 0 184 return 0
184 fi 185 fi
238 ;; 239 ;;
239 esac 240 esac
240 241
241 if [ "${SINGLE_PATCH}" = "no" ] 242 if [ "${SINGLE_PATCH}" = "no" ]
242 then 243 then
243 einfo "Applying various patches (bugfixes/updates) ..." 244 einfo "${EPATCH_MULTI_MSG}"
244 fi 245 fi
245 for x in ${EPATCH_SOURCE} 246 for x in ${EPATCH_SOURCE}
246 do 247 do
247 # New ARCH dependant patch naming scheme ... 248 # New ARCH dependant patch naming scheme ...
248 # 249 #
249 # ???_arch_foo.patch 250 # ???_arch_foo.patch
250 # 251 #
251 if [ -f ${x} ] && \ 252 if [ -f ${x} ] && \
252 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ 253 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "${x/_${ARCH}_}" != "${x}" ] || \
253 [ "${EPATCH_FORCE}" = "yes" ]) 254 [ "${EPATCH_FORCE}" = "yes" ])
254 then 255 then
255 local count=0 256 local count=0
256 local popts="${EPATCH_OPTS}" 257 local popts="${EPATCH_OPTS}"
257 local patchname=${x##*/} 258 local patchname=${x##*/}
367 then 368 then
368 einfo "Done with patching" 369 einfo "Done with patching"
369 fi 370 fi
370} 371}
371 372
372# This function return true if we are using the NPTL pthreads
373# implementation.
374#
375# <azarah@gentoo.org> (06 March 2003)
376#
377have_NPTL() {
378 cat > ${T}/test-nptl.c <<-"END"
379 #define _XOPEN_SOURCE
380 #include <unistd.h>
381 #include <stdio.h>
382
383 int main()
384 {
385 char buf[255];
386 char *str = buf;
387
388 confstr(_CS_GNU_LIBPTHREAD_VERSION, str, 255);
389 if (NULL != str) {
390 printf("%s\n", str);
391 if (NULL != strstr(str, "NPTL"))
392 return 0;
393 }
394
395 return 1;
396 }
397 END
398
399 einfon "Checking for _CS_GNU_LIBPTHREAD_VERSION support in glibc ..."
400 if gcc -o ${T}/nptl ${T}/test-nptl.c &> /dev/null
401 then
402 echo "yes"
403 einfon "Checking what PTHREADS implementation we have ..."
404 if ${T}/nptl
405 then
406 return 0
407 else
408 return 1
409 fi
410 else
411 echo "no"
412 fi
413
414 return 1
415}
416
417# This function check how many cpu's are present, and then set
418# -j in MAKEOPTS accordingly.
419#
420# Thanks to nall <nall@gentoo.org> for this.
421#
422get_number_of_jobs() {
423 local jobs=0
424
425 if [ ! -r /proc/cpuinfo ]
426 then
427 return 1
428 fi
429
430 # This bit is from H?kan Wessberg <nacka-gentoo@refug.org>, bug #13565.
431 if [ "`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | wc -l`" -gt 0 ]
432 then
433 ADMINOPTS="`egrep "^[[:space:]]*MAKEOPTS=" /etc/make.conf | cut -d= -f2 | sed 's/\"//g'`"
434 ADMINPARAM="`echo ${ADMINOPTS} | gawk '{match($0, /-j *[0-9]*/, opt); print opt[0]}'`"
435 ADMINPARAM="${ADMINPARAM/-j}"
436 fi
437
438 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j *[0-9]*::g'`"
439
440 if [ "${ARCH}" = "amd64" -o "${ARCH}" = "x86" -o "${ARCH}" = "hppa" -o \
441 "${ARCH}" = "arm" -o "${ARCH}" = "mips" -o "${ARCH}" = "ia64" ]
442 then
443 # these archs will always have "[Pp]rocessor"
444 jobs="$((`grep -c ^[Pp]rocessor /proc/cpuinfo` * 2))"
445
446 elif [ "${ARCH}" = "sparc" -o "${ARCH}" = "sparc64" ]
447 then
448 # sparc always has "ncpus active"
449 jobs="$((`grep "^ncpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
450
451 elif [ "${ARCH}" = "alpha" ]
452 then
453 # alpha has "cpus active", but only when compiled with SMP
454 if [ "`grep -c "^cpus active" /proc/cpuinfo`" -eq 1 ]
455 then
456 jobs="$((`grep "^cpus active" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
457 else
458 jobs=2
459 fi
460
461 elif [ "${ARCH}" = "ppc" -o "${ARCH}" = "ppc64" ]
462 then
463 # ppc has "processor", but only when compiled with SMP
464 if [ "`grep -c "^processor" /proc/cpuinfo`" -eq 1 ]
465 then
466 jobs="$((`grep -c ^processor /proc/cpuinfo` * 2))"
467 else
468 jobs=2
469 fi
470 elif [ "${ARCH}" = "s390" ]
471 then
472 # s390 has "# processors : "
473 jobs="$((`grep "^\# processors" /proc/cpuinfo | sed -e "s/^.*: //"` * 2))"
474 else
475 jobs="$((`grep -c ^cpu /proc/cpuinfo` * 2))"
476 die "Unknown ARCH -- ${ARCH}!"
477 fi
478
479 # Make sure the number is valid ...
480 if [ "${jobs}" -lt 1 ]
481 then
482 jobs=1
483 fi
484
485 if [ -n "${ADMINPARAM}" ]
486 then
487 if [ "${jobs}" -gt "${ADMINPARAM}" ]
488 then
489 einfo "Setting make jobs to \"-j${ADMINPARAM}\" to ensure successful merge ..."
490 export MAKEOPTS="${MAKEOPTS} -j${ADMINPARAM}"
491 else
492 einfo "Setting make jobs to \"-j${jobs}\" to ensure successful merge ..."
493 export MAKEOPTS="${MAKEOPTS} -j${jobs}"
494 fi
495 fi
496}
497
498# Cheap replacement for when debianutils (and thus mktemp) 373# Cheap replacement for when debianutils (and thus mktemp)
499# does not exist on the users system 374# does not exist on the users system
500# vapier@gentoo.org 375# vapier@gentoo.org
501# 376#
502# Takes just 1 optional parameter (the directory to create tmpfile in) 377# Takes just 1 optional parameter (the directory to create tmpfile in)
533# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 408# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
534# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> 409# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
535# 410#
536# egetent(database, key) 411# egetent(database, key)
537egetent() { 412egetent() {
538 if useq ppc-macos ; then 413 if [[ "${USERLAND}" == "Darwin" ]] ; then
539 case "$2" in 414 case "$2" in
540 *[!0-9]*) # Non numeric 415 *[!0-9]*) # Non numeric
541 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 416 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
542 ;; 417 ;;
543 *) # Numeric 418 *) # Numeric
544 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" 419 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
545 ;; 420 ;;
546 esac 421 esac
547 elif useq x86-fbsd ; then 422 elif [[ "${USERLAND}" == "BSD" ]] ; then
548 local action 423 local action
549 if [ "$1" == "passwd" ] 424 if [ "$1" == "passwd" ]
550 then 425 then
551 action="user" 426 action="user"
552 else 427 else
572# homedir: /dev/null 447# homedir: /dev/null
573# groups: none 448# groups: none
574# extra: comment of 'added by portage for ${PN}' 449# extra: comment of 'added by portage for ${PN}'
575enewuser() { 450enewuser() {
576 # get the username 451 # get the username
577 local euser="$1"; shift 452 local euser=$1; shift
578 if [ -z "${euser}" ] 453 if [[ -z ${euser} ]] ; then
579 then
580 eerror "No username specified !" 454 eerror "No username specified !"
581 die "Cannot call enewuser without a username" 455 die "Cannot call enewuser without a username"
582 fi 456 fi
583 457
584 # lets see if the username already exists 458 # lets see if the username already exists
585 if [ "${euser}" == "`egetent passwd \"${euser}\" | cut -d: -f1`" ] 459 if [[ ${euser} == $(egetent passwd "${euser}" | cut -d: -f1) ]] ; then
586 then
587 return 0 460 return 0
588 fi 461 fi
589 einfo "Adding user '${euser}' to your system ..." 462 einfo "Adding user '${euser}' to your system ..."
590 463
591 # options to pass to useradd 464 # options to pass to useradd
592 local opts= 465 local opts=
593 466
594 # handle uid 467 # handle uid
595 local euid="$1"; shift 468 local euid=$1; shift
596 if [ ! -z "${euid}" ] && [ "${euid}" != "-1" ] 469 if [[ ! -z ${euid} ]] && [[ ${euid} != "-1" ]] ; then
597 then
598 if [ "${euid}" -gt 0 ] 470 if [[ ${euid} -gt 0 ]] ; then
599 then
600 if [ ! -z "`egetent passwd ${euid}`" ] 471 if [[ ! -z $(egetent passwd ${euid}) ]] ; then
601 then
602 euid="next" 472 euid="next"
603 fi 473 fi
604 else 474 else
605 eerror "Userid given but is not greater than 0 !" 475 eerror "Userid given but is not greater than 0 !"
606 die "${euid} is not a valid UID" 476 die "${euid} is not a valid UID"
607 fi 477 fi
608 else 478 else
609 euid="next" 479 euid="next"
610 fi 480 fi
611 if [ "${euid}" == "next" ] 481 if [[ ${euid} == "next" ]] ; then
612 then
613 local pwrange 482 local pwrange
614 if [ "${USERLAND}" == "BSD" ] ; then 483 if [[ ${USERLAND} == "BSD" ]] ; then
615 pwrange="`jot 898 101`" 484 pwrange=$(jot 898 101)
616 else 485 else
617 pwrange="`seq 101 999`" 486 pwrange=$(seq 101 999)
618 fi 487 fi
619 for euid in ${pwrange} ; do 488 for euid in ${pwrange} ; do
620 [ -z "`egetent passwd ${euid}`" ] && break 489 [[ -z $(egetent passwd ${euid}) ]] && break
621 done 490 done
622 fi 491 fi
623 opts="${opts} -u ${euid}" 492 opts="${opts} -u ${euid}"
624 einfo " - Userid: ${euid}" 493 einfo " - Userid: ${euid}"
625 494
626 # handle shell 495 # handle shell
627 local eshell="$1"; shift 496 local eshell=$1; shift
628 if [ ! -z "${eshell}" ] && [ "${eshell}" != "-1" ] 497 if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then
629 then
630 if [ ! -e "${eshell}" ] 498 if [[ ! -e ${eshell} ]] ; then
631 then
632 eerror "A shell was specified but it does not exist !" 499 eerror "A shell was specified but it does not exist !"
633 die "${eshell} does not exist" 500 die "${eshell} does not exist"
634 fi 501 fi
635 else 502 else
636 if [ "${USERLAND}" == "BSD" ] 503 case ${USERLAND} in
637 then
638 eshell="/usr/bin/false" 504 Darwin) eshell="/usr/bin/false";;
639 else 505 BSD) eshell="/usr/sbin/nologin";;
640 eshell="/bin/false" 506 *) eshell="/bin/false";;
641 fi 507 esac
642 fi 508 fi
643 einfo " - Shell: ${eshell}" 509 einfo " - Shell: ${eshell}"
644 opts="${opts} -s ${eshell}" 510 opts="${opts} -s ${eshell}"
645 511
646 # handle homedir 512 # handle homedir
647 local ehome="$1"; shift 513 local ehome=$1; shift
648 if [ -z "${ehome}" ] && [ "${eshell}" != "-1" ] 514 if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]] ; then
649 then
650 ehome="/dev/null" 515 ehome="/dev/null"
651 fi 516 fi
652 einfo " - Home: ${ehome}" 517 einfo " - Home: ${ehome}"
653 opts="${opts} -d ${ehome}" 518 opts="${opts} -d ${ehome}"
654 519
655 # handle groups 520 # handle groups
656 local egroups="$1"; shift 521 local egroups=$1; shift
657 if [ ! -z "${egroups}" ] 522 if [[ ! -z ${egroups} ]] ; then
658 then
659 local oldifs="${IFS}" 523 local oldifs=${IFS}
660 local defgroup="" exgroups="" 524 local defgroup="" exgroups=""
661 525
662 export IFS="," 526 export IFS=","
663 for g in ${egroups} 527 for g in ${egroups} ; do
664 do
665 export IFS="${oldifs}" 528 export IFS=${oldifs}
666 if [ -z "`egetent group \"${g}\"`" ] 529 if [[ -z $(egetent group "${g}") ]] ; then
667 then
668 eerror "You must add group ${g} to the system first" 530 eerror "You must add group ${g} to the system first"
669 die "${g} is not a valid GID" 531 die "${g} is not a valid GID"
670 fi 532 fi
671 if [ -z "${defgroup}" ] 533 if [[ -z ${defgroup} ]] ; then
672 then
673 defgroup="${g}" 534 defgroup=${g}
674 else 535 else
675 exgroups="${exgroups},${g}" 536 exgroups="${exgroups},${g}"
676 fi 537 fi
677 export IFS="," 538 export IFS=","
678 done 539 done
679 export IFS="${oldifs}" 540 export IFS=${oldifs}
680 541
681 opts="${opts} -g ${defgroup}" 542 opts="${opts} -g ${defgroup}"
682 if [ ! -z "${exgroups}" ] 543 if [[ ! -z ${exgroups} ]] ; then
683 then
684 opts="${opts} -G ${exgroups:1}" 544 opts="${opts} -G ${exgroups:1}"
685 fi 545 fi
686 else 546 else
687 egroups="(none)" 547 egroups="(none)"
688 fi 548 fi
689 einfo " - Groups: ${egroups}" 549 einfo " - Groups: ${egroups}"
690 550
691 # handle extra and add the user 551 # handle extra and add the user
692 local eextra="$@"
693 local oldsandbox="${SANDBOX_ON}" 552 local oldsandbox=${SANDBOX_ON}
694 export SANDBOX_ON="0" 553 export SANDBOX_ON="0"
695 if useq ppc-macos 554 case ${USERLAND} in
696 then 555 Darwin)
697 ### Make the user 556 ### Make the user
698 if [ -z "${eextra}" ] 557 if [[ -z $@ ]] ; then
699 then
700 dscl . create /users/${euser} uid ${euid} 558 dscl . create /users/${euser} uid ${euid}
701 dscl . create /users/${euser} shell ${eshell} 559 dscl . create /users/${euser} shell ${eshell}
702 dscl . create /users/${euser} home ${ehome} 560 dscl . create /users/${euser} home ${ehome}
703 dscl . create /users/${euser} realname "added by portage for ${PN}" 561 dscl . create /users/${euser} realname "added by portage for ${PN}"
704 ### Add the user to the groups specified 562 ### Add the user to the groups specified
705 local oldifs="${IFS}" 563 local oldifs=${IFS}
706 export IFS="," 564 export IFS=","
707 for g in ${egroups} 565 for g in ${egroups} ; do
708 do
709 dscl . merge /groups/${g} users ${euser} 566 dscl . merge /groups/${g} users ${euser}
710 done 567 done
711 export IFS="${oldifs}" 568 export IFS=${oldifs}
712 else 569 else
713 einfo "Extra options are not supported on macos yet" 570 einfo "Extra options are not supported on Darwin yet"
714 einfo "Please report the ebuild along with the info below" 571 einfo "Please report the ebuild along with the info below"
715 einfo "eextra: ${eextra}" 572 einfo "eextra: $@"
716 die "Required function missing" 573 die "Required function missing"
717 fi 574 fi
718 elif use x86-fbsd ; then 575 ;;
719 if [ -z "${eextra}" ] 576 BSD)
720 then 577 if [[ -z $@ ]] ; then
721 pw useradd ${euser} ${opts} \ 578 pw useradd ${euser} ${opts} \
722 -c "added by portage for ${PN}" \ 579 -c "added by portage for ${PN}" \
723 die "enewuser failed" 580 die "enewuser failed"
724 else 581 else
725 einfo " - Extra: ${eextra}" 582 einfo " - Extra: $@"
726 pw useradd ${euser} ${opts} \ 583 pw useradd ${euser} ${opts} \
727 -c ${eextra} || die "enewuser failed" 584 "$@" || die "enewuser failed"
728 fi 585 fi
729 else 586 ;;
730 if [ -z "${eextra}" ] 587 *)
731 then 588 if [[ -z $@ ]] ; then
732 useradd ${opts} ${euser} \ 589 useradd ${opts} ${euser} \
733 -c "added by portage for ${PN}" \ 590 -c "added by portage for ${PN}" \
734 || die "enewuser failed" 591 || die "enewuser failed"
735 else 592 else
736 einfo " - Extra: ${eextra}" 593 einfo " - Extra: $@"
737 useradd ${opts} ${euser} ${eextra} \ 594 useradd ${opts} ${euser} "$@" \
738 || die "enewuser failed" 595 || die "enewuser failed"
739 fi 596 fi
740 fi 597 ;;
598 esac
741 export SANDBOX_ON="${oldsandbox}" 599 export SANDBOX_ON=${oldsandbox}
742 600
743 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ] 601 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ]
744 then 602 then
745 einfo " - Creating ${ehome} in ${D}" 603 einfo " - Creating ${ehome} in ${D}"
746 dodir ${ehome} 604 dodir ${ehome}
783 then 641 then
784 if [ "${egid}" -gt 0 ] 642 if [ "${egid}" -gt 0 ]
785 then 643 then
786 if [ -z "`egetent group ${egid}`" ] 644 if [ -z "`egetent group ${egid}`" ]
787 then 645 then
788 if useq ppc-macos ; then 646 if [[ "${USERLAND}" == "Darwin" ]]; then
789 opts="${opts} ${egid}" 647 opts="${opts} ${egid}"
790 else 648 else
791 opts="${opts} -g ${egid}" 649 opts="${opts} -g ${egid}"
792 fi 650 fi
793 else 651 else
807 opts="${opts} ${eextra}" 665 opts="${opts} ${eextra}"
808 666
809 # add the group 667 # add the group
810 local oldsandbox="${SANDBOX_ON}" 668 local oldsandbox="${SANDBOX_ON}"
811 export SANDBOX_ON="0" 669 export SANDBOX_ON="0"
812 if useq ppc-macos ; then 670 if [[ "${USERLAND}" == "Darwin" ]]; then
813 if [ ! -z "${eextra}" ]; 671 if [ ! -z "${eextra}" ];
814 then 672 then
815 einfo "Extra options are not supported on macos yet" 673 einfo "Extra options are not supported on Darwin/OS X yet"
816 einfo "Please report the ebuild along with the info below" 674 einfo "Please report the ebuild along with the info below"
817 einfo "eextra: ${eextra}" 675 einfo "eextra: ${eextra}"
818 die "Required function missing" 676 die "Required function missing"
819 fi 677 fi
820 678
825 [ -z "`egetent group ${egid}`" ] && break 683 [ -z "`egetent group ${egid}`" ] && break
826 done 684 done
827 esac 685 esac
828 dscl . create /groups/${egroup} gid ${egid} 686 dscl . create /groups/${egroup} gid ${egid}
829 dscl . create /groups/${egroup} passwd '*' 687 dscl . create /groups/${egroup} passwd '*'
830 elif use x86-fbsd ; then 688 elif [[ "${USERLAND}" == "BSD" ]] ; then
831 case ${egid} in 689 case ${egid} in
832 *[!0-9]*) # Non numeric 690 *[!0-9]*) # Non numeric
833 for egid in `jot 898 101`; do 691 for egid in `jot 898 101`; do
834 [ -z "`egetent group ${egid}`" ] && break 692 [ -z "`egetent group ${egid}`" ] && break
835 done 693 done
982 *) 840 *)
983 type= 841 type=
984 ;; 842 ;;
985 esac 843 esac
986 fi 844 fi
987 845 if [ "${SLOT}" == "0" ] ; then
846 local desktop_name="${PN}"
847 else
848 local desktop_name="${PN}-${SLOT}"
849 fi
988 local desktop=${T}/${exec%% *}-${P}.desktop 850 local desktop=${T}/${exec%% *}-${desktop_name}.desktop
989 851
990echo "[Desktop Entry] 852echo "[Desktop Entry]
991Encoding=UTF-8 853Encoding=UTF-8
992Version=0.9.2 854Version=0.9.2
993Name=${name} 855Name=${name}
1009# make_desktop_entry(<title>, <command>) 871# make_desktop_entry(<title>, <command>)
1010# title: File to execute to start the Window Manager 872# title: File to execute to start the Window Manager
1011# command: Name of the Window Manager 873# command: Name of the Window Manager
1012 874
1013make_session_desktop() { 875make_session_desktop() {
1014
1015 [ -z "$1" ] && eerror "make_session_desktop: You must specify the title" && return 1 876 [[ -z $1 ]] && eerror "make_session_desktop: You must specify the title" && return 1
1016 [ -z "$2" ] && eerror "make_session_desktop: You must specify the command" && return 1 877 [[ -z $2 ]] && eerror "make_session_desktop: You must specify the command" && return 1
1017 878
1018 local title="${1}" 879 local title=$1
1019 local command="${2}" 880 local command=$2
1020 local desktop="${T}/${wm}.desktop" 881 local desktop=${T}/${wm}.desktop
1021 882
1022echo "[Desktop Entry] 883echo "[Desktop Entry]
1023Encoding=UTF-8 884Encoding=UTF-8
1024Name=${title} 885Name=${title}
1025Comment=This session logs you into ${title} 886Comment=This session logs you into ${title}
1027TryExec=${command} 888TryExec=${command}
1028Type=Application" > "${desktop}" 889Type=Application" > "${desktop}"
1029 890
1030 insinto /usr/share/xsessions 891 insinto /usr/share/xsessions
1031 doins "${desktop}" 892 doins "${desktop}"
1032
1033 return 0
1034} 893}
1035 894
1036domenu() { 895domenu() {
1037 local i 896 local i j
1038 local j
1039 insinto /usr/share/applications 897 insinto /usr/share/applications
1040 for i in ${@} 898 for i in "$@" ; do
1041 do
1042 if [ -f "${i}" ]; 899 if [[ -f ${i} ]] ; then
1043 then
1044 doins ${i} 900 doins "${i}"
1045 elif [ -d "${i}" ]; 901 elif [[ -d ${i} ]] ; then
1046 then
1047 for j in ${i}/*.desktop 902 for j in "${i}"/*.desktop ; do
1048 do
1049 doins ${j} 903 doins "${j}"
1050 done 904 done
1051 fi 905 fi
1052 done 906 done
1053} 907}
908newmenu() {
909 insinto /usr/share/applications
910 newins "$1" "$2"
911}
1054 912
1055doicon() { 913doicon() {
1056 local i 914 local i j
1057 local j
1058 insinto /usr/share/pixmaps 915 insinto /usr/share/pixmaps
1059 for i in ${@} 916 for i in "$@" ; do
1060 do
1061 if [ -f "${i}" ]; 917 if [[ -f ${i} ]] ; then
1062 then
1063 doins ${i} 918 doins "${i}"
1064 elif [ -d "${i}" ]; 919 elif [[ -d ${i} ]] ; then
1065 then
1066 for j in ${i}/*.png 920 for j in "${i}"/*.png ; do
1067 do
1068 doins ${j} 921 doins "${j}"
1069 done 922 done
1070 fi 923 fi
1071 done 924 done
925}
926newicon() {
927 insinto /usr/share/pixmaps
928 newins "$1" "$2"
1072} 929}
1073 930
1074############################################################## 931##############################################################
1075# END: Handle .desktop files and menu entries # 932# END: Handle .desktop files and menu entries #
1076############################################################## 933##############################################################
1477 local mline="" 1334 local mline=""
1478 local showedmsg=0 1335 local showedmsg=0
1479 1336
1480 for mline in $(mount | egrep -e '(iso|cdrom)' | awk '{print $3}') ; do 1337 for mline in $(mount | egrep -e '(iso|cdrom)' | awk '{print $3}') ; do
1481 [[ -d ${mline}/${dir} ]] || continue 1338 [[ -d ${mline}/${dir} ]] || continue
1482 [[ ! -z $(find ${mline}/${dir} -iname ${file} -maxdepth 1) ]] \ 1339 [[ ! -z $(find ${mline}/${dir} -maxdepth 1 -iname ${file}) ]] \
1483 && export CDROM_ROOT=${mline} 1340 && export CDROM_ROOT=${mline}
1484 done 1341 done
1485 1342
1486 if [[ -z ${CDROM_ROOT} ]] ; then 1343 if [[ -z ${CDROM_ROOT} ]] ; then
1487 echo 1344 echo
1502 fi 1359 fi
1503 showedmsg=1 1360 showedmsg=1
1504 fi 1361 fi
1505 einfo "Press return to scan for the cd again" 1362 einfo "Press return to scan for the cd again"
1506 einfo "or hit CTRL+C to abort the emerge." 1363 einfo "or hit CTRL+C to abort the emerge."
1364 echo
1365 einfo "If you are having trouble with the detection"
1366 einfo "of your CD, it is possible that you do not have"
1367 einfo "Joliet support enabled in your kernel. Please"
1368 einfo "check that CONFIG_JOLIET is enabled in your kernel."
1507 read 1369 read
1508 fi 1370 fi
1509 done 1371 done
1510} 1372}
1511 1373
1575 while ((i--)) ; do 1437 while ((i--)) ; do
1576 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass" 1438 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1577 done 1439 done
1578 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}" 1440 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}"
1579 case ${ARCH} in 1441 case ${ARCH} in
1580 x86) export ARCH="i386";; 1442 x86) export ARCH="i386";;
1581 amd64) export ARCH="x86_64";; 1443 amd64) export ARCH="x86_64";;
1582 hppa) export ARCH="parisc";; 1444 hppa) export ARCH="parisc";;
1583 mips) export ARCH="mips";; 1445 mips) export ARCH="mips";;
1584 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! 1446 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!
1585 *) export ARCH="${ARCH}";; 1447 *) export ARCH="${ARCH}";;
1586 esac 1448 esac
1587} 1449}
1588 1450
1589# set's ARCH back to what portage expects 1451# set's ARCH back to what portage expects
1590set_arch_to_portage() { 1452set_arch_to_portage() {
1634 LIB=$1 1496 LIB=$1
1635 1497
1636 if [ -n "${LIB}" -a -f "${ROOT}${LIB}" ]; then 1498 if [ -n "${LIB}" -a -f "${ROOT}${LIB}" ]; then
1637 SONAME=`basename ${LIB}` 1499 SONAME=`basename ${LIB}`
1638 1500
1639 einfo "An old version of an installed library was detected on your system." 1501 ewarn "An old version of an installed library was detected on your system."
1640 einfo "In order to avoid breaking packages that link against is, this older version" 1502 ewarn "In order to avoid breaking packages that link against it, this older version"
1641 einfo "is not being removed. In order to make full use of this newer version," 1503 ewarn "is not being removed. In order to make full use of this newer version,"
1642 einfo "you will need to execute the following command:" 1504 ewarn "you will need to execute the following command:"
1643 einfo " revdep-rebuild --soname ${SONAME}" 1505 ewarn " revdep-rebuild --soname ${SONAME}"
1644 einfo 1506 ewarn
1645 einfo "After doing that, you can safely remove ${LIB}" 1507 ewarn "After doing that, you can safely remove ${LIB}"
1646 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild" 1508 ewarn "Note: 'emerge gentoolkit' to get revdep-rebuild"
1647 fi 1509 fi
1648} 1510}
1649 1511
1650# Hack for people to figure out if a package was built with 1512# Hack for people to figure out if a package was built with
1651# certain USE flags 1513# certain USE flags
1697dopamd() { 1559dopamd() {
1698 [[ -z $1 ]] && die "dopamd requires at least one argument" 1560 [[ -z $1 ]] && die "dopamd requires at least one argument"
1699 1561
1700 use pam || return 0 1562 use pam || return 0
1701 1563
1702 insinto /etc/pam.d 1564 INSDESTTREE=/etc/pam.d \
1703 doins "$@" || die "failed to install $@" 1565 doins "$@" || die "failed to install $@"
1704} 1566}
1705# newpamd <old name> <new name> 1567# newpamd <old name> <new name>
1706# 1568#
1707# Install pam file <old name> as <new name> in /etc/pam.d 1569# Install pam file <old name> as <new name> in /etc/pam.d
1708newpamd() { 1570newpamd() {
1709 [[ $# -ne 2 ]] && die "newpamd requires two arguements" 1571 [[ $# -ne 2 ]] && die "newpamd requires two arguements"
1710 1572
1711 use pam || return 0 1573 use pam || return 0
1712 1574
1713 insinto /etc/pam.d 1575 INSDESTTREE=/etc/pam.d \
1714 newins "$1" "$2" || die "failed to install $1 as $2" 1576 newins "$1" "$2" || die "failed to install $1 as $2"
1715} 1577}
1716 1578
1717# make a wrapper script ... 1579# make a wrapper script ...
1718# NOTE: this was originally games_make_wrapper, but I noticed other places where 1580# NOTE: this was originally games_make_wrapper, but I noticed other places where

Legend:
Removed from v.1.166  
changed lines
  Added in v.1.191

  ViewVC Help
Powered by ViewVC 1.1.20