/[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.182
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.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.
11 11
12inherit multilib 12inherit multilib
13ECLASS=eutils 13ECLASS=eutils
14INHERITED="$INHERITED $ECLASS" 14INHERITED="$INHERITED $ECLASS"
15 15
16DEPEND="!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.
17 18
18DESCRIPTION="Based on the ${ECLASS} eclass" 19DESCRIPTION="Based on the ${ECLASS} eclass"
19 20
20# 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
21# 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
118EPATCH_SOURCE="${WORKDIR}/patch" 119EPATCH_SOURCE="${WORKDIR}/patch"
119# Default extension for patches 120# Default extension for patches
120EPATCH_SUFFIX="patch.bz2" 121EPATCH_SUFFIX="patch.bz2"
121# Default options for patch 122# Default options for patch
122# 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
123EPATCH_OPTS="-g0" 124# Set --no-backup-if-mismatch so we don't leave '.orig' files behind.
125EPATCH_OPTS="-g0 --no-backup-if-mismatch"
124# 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,
125# and not the full path .. 127# and not the full path ..
126EPATCH_EXCLUDE="" 128EPATCH_EXCLUDE=""
127# Change the printed message for a single patch. 129# Change the printed message for a single patch.
128EPATCH_SINGLE_MSG="" 130EPATCH_SINGLE_MSG=""
131# Change the printed message for multiple patches.
132EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
129# Force applying bulk patches even if not following the style: 133# Force applying bulk patches even if not following the style:
130# 134#
131# ??_${ARCH}_foo.${EPATCH_SUFFIX} 135# ??_${ARCH}_foo.${EPATCH_SUFFIX}
132# 136#
133EPATCH_FORCE="no" 137EPATCH_FORCE="no"
174 local x="" 178 local x=""
175 179
176 if [ "$#" -gt 1 ] 180 if [ "$#" -gt 1 ]
177 then 181 then
178 local m="" 182 local m=""
179 einfo "${#} patches to apply ..."
180 for m in "$@" ; do 183 for m in "$@" ; do
181 epatch "${m}" 184 epatch "${m}"
182 done 185 done
183 return 0 186 return 0
184 fi 187 fi
238 ;; 241 ;;
239 esac 242 esac
240 243
241 if [ "${SINGLE_PATCH}" = "no" ] 244 if [ "${SINGLE_PATCH}" = "no" ]
242 then 245 then
243 einfo "Applying various patches (bugfixes/updates) ..." 246 einfo "${EPATCH_MULTI_MSG}"
244 fi 247 fi
245 for x in ${EPATCH_SOURCE} 248 for x in ${EPATCH_SOURCE}
246 do 249 do
247 # New ARCH dependant patch naming scheme ... 250 # New ARCH dependant patch naming scheme ...
248 # 251 #
249 # ???_arch_foo.patch 252 # ???_arch_foo.patch
250 # 253 #
251 if [ -f ${x} ] && \ 254 if [ -f ${x} ] && \
252 ([ "${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}" ] || \
253 [ "${EPATCH_FORCE}" = "yes" ]) 256 [ "${EPATCH_FORCE}" = "yes" ])
254 then 257 then
255 local count=0 258 local count=0
256 local popts="${EPATCH_OPTS}" 259 local popts="${EPATCH_OPTS}"
257 local patchname=${x##*/} 260 local patchname=${x##*/}
367 then 370 then
368 einfo "Done with patching" 371 einfo "Done with patching"
369 fi 372 fi
370} 373}
371 374
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) 375# Cheap replacement for when debianutils (and thus mktemp)
499# does not exist on the users system 376# does not exist on the users system
500# vapier@gentoo.org 377# vapier@gentoo.org
501# 378#
502# Takes just 1 optional parameter (the directory to create tmpfile in) 379# Takes just 1 optional parameter (the directory to create tmpfile in)
533# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 410# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
534# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> 411# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
535# 412#
536# egetent(database, key) 413# egetent(database, key)
537egetent() { 414egetent() {
538 if useq ppc-macos ; then 415 if [[ "${USERLAND}" == "Darwin" ]] ; then
539 case "$2" in 416 case "$2" in
540 *[!0-9]*) # Non numeric 417 *[!0-9]*) # Non numeric
541 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 418 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
542 ;; 419 ;;
543 *) # Numeric 420 *) # Numeric
544 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" 421 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
545 ;; 422 ;;
546 esac 423 esac
547 elif useq x86-fbsd ; then 424 elif [[ "${USERLAND}" == "BSD" ]] ; then
548 local action 425 local action
549 if [ "$1" == "passwd" ] 426 if [ "$1" == "passwd" ]
550 then 427 then
551 action="user" 428 action="user"
552 else 429 else
572# homedir: /dev/null 449# homedir: /dev/null
573# groups: none 450# groups: none
574# extra: comment of 'added by portage for ${PN}' 451# extra: comment of 'added by portage for ${PN}'
575enewuser() { 452enewuser() {
576 # get the username 453 # get the username
577 local euser="$1"; shift 454 local euser=$1; shift
578 if [ -z "${euser}" ] 455 if [[ -z ${euser} ]] ; then
579 then
580 eerror "No username specified !" 456 eerror "No username specified !"
581 die "Cannot call enewuser without a username" 457 die "Cannot call enewuser without a username"
582 fi 458 fi
583 459
584 # lets see if the username already exists 460 # lets see if the username already exists
585 if [ "${euser}" == "`egetent passwd \"${euser}\" | cut -d: -f1`" ] 461 if [[ ${euser} == $(egetent passwd "${euser}" | cut -d: -f1) ]] ; then
586 then
587 return 0 462 return 0
588 fi 463 fi
589 einfo "Adding user '${euser}' to your system ..." 464 einfo "Adding user '${euser}' to your system ..."
590 465
591 # options to pass to useradd 466 # options to pass to useradd
592 local opts= 467 local opts=
593 468
594 # handle uid 469 # handle uid
595 local euid="$1"; shift 470 local euid=$1; shift
596 if [ ! -z "${euid}" ] && [ "${euid}" != "-1" ] 471 if [[ ! -z ${euid} ]] && [[ ${euid} != "-1" ]] ; then
597 then
598 if [ "${euid}" -gt 0 ] 472 if [[ ${euid} -gt 0 ]] ; then
599 then
600 if [ ! -z "`egetent passwd ${euid}`" ] 473 if [[ ! -z $(egetent passwd ${euid}) ]] ; then
601 then
602 euid="next" 474 euid="next"
603 fi 475 fi
604 else 476 else
605 eerror "Userid given but is not greater than 0 !" 477 eerror "Userid given but is not greater than 0 !"
606 die "${euid} is not a valid UID" 478 die "${euid} is not a valid UID"
607 fi 479 fi
608 else 480 else
609 euid="next" 481 euid="next"
610 fi 482 fi
611 if [ "${euid}" == "next" ] 483 if [[ ${euid} == "next" ]] ; then
612 then
613 local pwrange 484 local pwrange
614 if [ "${USERLAND}" == "BSD" ] ; then 485 if [[ ${USERLAND} == "BSD" ]] ; then
615 pwrange="`jot 898 101`" 486 pwrange=$(jot 898 101)
616 else 487 else
617 pwrange="`seq 101 999`" 488 pwrange=$(seq 101 999)
618 fi 489 fi
619 for euid in ${pwrange} ; do 490 for euid in ${pwrange} ; do
620 [ -z "`egetent passwd ${euid}`" ] && break 491 [[ -z $(egetent passwd ${euid}) ]] && break
621 done 492 done
622 fi 493 fi
623 opts="${opts} -u ${euid}" 494 opts="${opts} -u ${euid}"
624 einfo " - Userid: ${euid}" 495 einfo " - Userid: ${euid}"
625 496
626 # handle shell 497 # handle shell
627 local eshell="$1"; shift 498 local eshell=$1; shift
628 if [ ! -z "${eshell}" ] && [ "${eshell}" != "-1" ] 499 if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then
629 then
630 if [ ! -e "${eshell}" ] 500 if [[ ! -e ${eshell} ]] ; then
631 then
632 eerror "A shell was specified but it does not exist !" 501 eerror "A shell was specified but it does not exist !"
633 die "${eshell} does not exist" 502 die "${eshell} does not exist"
634 fi 503 fi
635 else 504 else
636 if [ "${USERLAND}" == "BSD" ] 505 case ${USERLAND} in
637 then
638 eshell="/usr/bin/false" 506 Darwin) eshell="/usr/bin/false";;
639 else 507 BSD) eshell="/usr/sbin/nologin";;
640 eshell="/bin/false" 508 *) eshell="/bin/false";;
641 fi 509 esac
642 fi 510 fi
643 einfo " - Shell: ${eshell}" 511 einfo " - Shell: ${eshell}"
644 opts="${opts} -s ${eshell}" 512 opts="${opts} -s ${eshell}"
645 513
646 # handle homedir 514 # handle homedir
647 local ehome="$1"; shift 515 local ehome=$1; shift
648 if [ -z "${ehome}" ] && [ "${eshell}" != "-1" ] 516 if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]] ; then
649 then
650 ehome="/dev/null" 517 ehome="/dev/null"
651 fi 518 fi
652 einfo " - Home: ${ehome}" 519 einfo " - Home: ${ehome}"
653 opts="${opts} -d ${ehome}" 520 opts="${opts} -d ${ehome}"
654 521
655 # handle groups 522 # handle groups
656 local egroups="$1"; shift 523 local egroups=$1; shift
657 if [ ! -z "${egroups}" ] 524 if [[ ! -z ${egroups} ]] ; then
658 then
659 local oldifs="${IFS}" 525 local oldifs=${IFS}
660 local defgroup="" exgroups="" 526 local defgroup="" exgroups=""
661 527
662 export IFS="," 528 export IFS=","
663 for g in ${egroups} 529 for g in ${egroups} ; do
664 do
665 export IFS="${oldifs}" 530 export IFS=${oldifs}
666 if [ -z "`egetent group \"${g}\"`" ] 531 if [[ -z $(egetent group "${g}") ]] ; then
667 then
668 eerror "You must add group ${g} to the system first" 532 eerror "You must add group ${g} to the system first"
669 die "${g} is not a valid GID" 533 die "${g} is not a valid GID"
670 fi 534 fi
671 if [ -z "${defgroup}" ] 535 if [[ -z ${defgroup} ]] ; then
672 then
673 defgroup="${g}" 536 defgroup=${g}
674 else 537 else
675 exgroups="${exgroups},${g}" 538 exgroups="${exgroups},${g}"
676 fi 539 fi
677 export IFS="," 540 export IFS=","
678 done 541 done
679 export IFS="${oldifs}" 542 export IFS=${oldifs}
680 543
681 opts="${opts} -g ${defgroup}" 544 opts="${opts} -g ${defgroup}"
682 if [ ! -z "${exgroups}" ] 545 if [[ ! -z ${exgroups} ]] ; then
683 then
684 opts="${opts} -G ${exgroups:1}" 546 opts="${opts} -G ${exgroups:1}"
685 fi 547 fi
686 else 548 else
687 egroups="(none)" 549 egroups="(none)"
688 fi 550 fi
689 einfo " - Groups: ${egroups}" 551 einfo " - Groups: ${egroups}"
690 552
691 # handle extra and add the user 553 # handle extra and add the user
692 local eextra="$@"
693 local oldsandbox="${SANDBOX_ON}" 554 local oldsandbox=${SANDBOX_ON}
694 export SANDBOX_ON="0" 555 export SANDBOX_ON="0"
695 if useq ppc-macos 556 case ${USERLAND} in
696 then 557 Darwin)
697 ### Make the user 558 ### Make the user
698 if [ -z "${eextra}" ] 559 if [[ -z $@ ]] ; then
699 then
700 dscl . create /users/${euser} uid ${euid} 560 dscl . create /users/${euser} uid ${euid}
701 dscl . create /users/${euser} shell ${eshell} 561 dscl . create /users/${euser} shell ${eshell}
702 dscl . create /users/${euser} home ${ehome} 562 dscl . create /users/${euser} home ${ehome}
703 dscl . create /users/${euser} realname "added by portage for ${PN}" 563 dscl . create /users/${euser} realname "added by portage for ${PN}"
704 ### Add the user to the groups specified 564 ### Add the user to the groups specified
705 local oldifs="${IFS}" 565 local oldifs=${IFS}
706 export IFS="," 566 export IFS=","
707 for g in ${egroups} 567 for g in ${egroups} ; do
708 do
709 dscl . merge /groups/${g} users ${euser} 568 dscl . merge /groups/${g} users ${euser}
710 done 569 done
711 export IFS="${oldifs}" 570 export IFS=${oldifs}
712 else 571 else
713 einfo "Extra options are not supported on macos yet" 572 einfo "Extra options are not supported on Darwin yet"
714 einfo "Please report the ebuild along with the info below" 573 einfo "Please report the ebuild along with the info below"
715 einfo "eextra: ${eextra}" 574 einfo "eextra: $@"
716 die "Required function missing" 575 die "Required function missing"
717 fi 576 fi
718 elif use x86-fbsd ; then 577 ;;
719 if [ -z "${eextra}" ] 578 BSD)
720 then 579 if [[ -z $@ ]] ; then
721 pw useradd ${euser} ${opts} \ 580 pw useradd ${euser} ${opts} \
722 -c "added by portage for ${PN}" \ 581 -c "added by portage for ${PN}" \
723 die "enewuser failed" 582 die "enewuser failed"
724 else 583 else
725 einfo " - Extra: ${eextra}" 584 einfo " - Extra: $@"
726 pw useradd ${euser} ${opts} \ 585 pw useradd ${euser} ${opts} \
727 -c ${eextra} || die "enewuser failed" 586 "$@" || die "enewuser failed"
728 fi 587 fi
729 else 588 ;;
730 if [ -z "${eextra}" ] 589 *)
731 then 590 if [[ -z $@ ]] ; then
732 useradd ${opts} ${euser} \ 591 useradd ${opts} ${euser} \
733 -c "added by portage for ${PN}" \ 592 -c "added by portage for ${PN}" \
734 || die "enewuser failed" 593 || die "enewuser failed"
735 else 594 else
736 einfo " - Extra: ${eextra}" 595 einfo " - Extra: $@"
737 useradd ${opts} ${euser} ${eextra} \ 596 useradd ${opts} ${euser} "$@" \
738 || die "enewuser failed" 597 || die "enewuser failed"
739 fi 598 fi
740 fi 599 ;;
600 esac
741 export SANDBOX_ON="${oldsandbox}" 601 export SANDBOX_ON=${oldsandbox}
742 602
743 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ] 603 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ]
744 then 604 then
745 einfo " - Creating ${ehome} in ${D}" 605 einfo " - Creating ${ehome} in ${D}"
746 dodir ${ehome} 606 dodir ${ehome}
783 then 643 then
784 if [ "${egid}" -gt 0 ] 644 if [ "${egid}" -gt 0 ]
785 then 645 then
786 if [ -z "`egetent group ${egid}`" ] 646 if [ -z "`egetent group ${egid}`" ]
787 then 647 then
788 if useq ppc-macos ; then 648 if [[ "${USERLAND}" == "Darwin" ]]; then
789 opts="${opts} ${egid}" 649 opts="${opts} ${egid}"
790 else 650 else
791 opts="${opts} -g ${egid}" 651 opts="${opts} -g ${egid}"
792 fi 652 fi
793 else 653 else
807 opts="${opts} ${eextra}" 667 opts="${opts} ${eextra}"
808 668
809 # add the group 669 # add the group
810 local oldsandbox="${SANDBOX_ON}" 670 local oldsandbox="${SANDBOX_ON}"
811 export SANDBOX_ON="0" 671 export SANDBOX_ON="0"
812 if useq ppc-macos ; then 672 if [[ "${USERLAND}" == "Darwin" ]]; then
813 if [ ! -z "${eextra}" ]; 673 if [ ! -z "${eextra}" ];
814 then 674 then
815 einfo "Extra options are not supported on macos yet" 675 einfo "Extra options are not supported on Darwin/OS X yet"
816 einfo "Please report the ebuild along with the info below" 676 einfo "Please report the ebuild along with the info below"
817 einfo "eextra: ${eextra}" 677 einfo "eextra: ${eextra}"
818 die "Required function missing" 678 die "Required function missing"
819 fi 679 fi
820 680
825 [ -z "`egetent group ${egid}`" ] && break 685 [ -z "`egetent group ${egid}`" ] && break
826 done 686 done
827 esac 687 esac
828 dscl . create /groups/${egroup} gid ${egid} 688 dscl . create /groups/${egroup} gid ${egid}
829 dscl . create /groups/${egroup} passwd '*' 689 dscl . create /groups/${egroup} passwd '*'
830 elif use x86-fbsd ; then 690 elif [[ "${USERLAND}" == "BSD" ]] ; then
831 case ${egid} in 691 case ${egid} in
832 *[!0-9]*) # Non numeric 692 *[!0-9]*) # Non numeric
833 for egid in `jot 898 101`; do 693 for egid in `jot 898 101`; do
834 [ -z "`egetent group ${egid}`" ] && break 694 [ -z "`egetent group ${egid}`" ] && break
835 done 695 done
982 *) 842 *)
983 type= 843 type=
984 ;; 844 ;;
985 esac 845 esac
986 fi 846 fi
987 847 if [ "${SLOT}" == "0" ] ; then
848 local desktop_name="${PN}"
849 else
850 local desktop_name="${PN}-${SLOT}"
851 fi
988 local desktop=${T}/${exec%% *}-${P}.desktop 852 local desktop=${T}/${exec%% *}-${desktop_name}.desktop
989 853
990echo "[Desktop Entry] 854echo "[Desktop Entry]
991Encoding=UTF-8 855Encoding=UTF-8
992Version=0.9.2 856Version=0.9.2
993Name=${name} 857Name=${name}
1009# make_desktop_entry(<title>, <command>) 873# make_desktop_entry(<title>, <command>)
1010# title: File to execute to start the Window Manager 874# title: File to execute to start the Window Manager
1011# command: Name of the Window Manager 875# command: Name of the Window Manager
1012 876
1013make_session_desktop() { 877make_session_desktop() {
1014
1015 [ -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
1016 [ -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
1017 880
1018 local title="${1}" 881 local title=$1
1019 local command="${2}" 882 local command=$2
1020 local desktop="${T}/${wm}.desktop" 883 local desktop=${T}/${wm}.desktop
1021 884
1022echo "[Desktop Entry] 885echo "[Desktop Entry]
1023Encoding=UTF-8 886Encoding=UTF-8
1024Name=${title} 887Name=${title}
1025Comment=This session logs you into ${title} 888Comment=This session logs you into ${title}
1027TryExec=${command} 890TryExec=${command}
1028Type=Application" > "${desktop}" 891Type=Application" > "${desktop}"
1029 892
1030 insinto /usr/share/xsessions 893 insinto /usr/share/xsessions
1031 doins "${desktop}" 894 doins "${desktop}"
1032
1033 return 0
1034} 895}
1035 896
1036domenu() { 897domenu() {
1037 local i 898 local i j
1038 local j
1039 insinto /usr/share/applications 899 insinto /usr/share/applications
1040 for i in ${@} 900 for i in "$@" ; do
1041 do
1042 if [ -f "${i}" ]; 901 if [[ -f ${i} ]] ; then
1043 then
1044 doins ${i} 902 doins "${i}"
1045 elif [ -d "${i}" ]; 903 elif [[ -d ${i} ]] ; then
1046 then
1047 for j in ${i}/*.desktop 904 for j in "${i}"/*.desktop ; do
1048 do
1049 doins ${j} 905 doins "${j}"
1050 done 906 done
1051 fi 907 fi
1052 done 908 done
1053} 909}
910newmenu() {
911 insinto /usr/share/applications
912 newins "$1" "$2"
913}
1054 914
1055doicon() { 915doicon() {
1056 local i 916 local i j
1057 local j
1058 insinto /usr/share/pixmaps 917 insinto /usr/share/pixmaps
1059 for i in ${@} 918 for i in "$@" ; do
1060 do
1061 if [ -f "${i}" ]; 919 if [[ -f ${i} ]] ; then
1062 then
1063 doins ${i} 920 doins "${i}"
1064 elif [ -d "${i}" ]; 921 elif [[ -d ${i} ]] ; then
1065 then
1066 for j in ${i}/*.png 922 for j in "${i}"/*.png ; do
1067 do
1068 doins ${j} 923 doins "${j}"
1069 done 924 done
1070 fi 925 fi
1071 done 926 done
927}
928newicon() {
929 insinto /usr/share/pixmaps
930 newins "$1" "$2"
1072} 931}
1073 932
1074############################################################## 933##############################################################
1075# END: Handle .desktop files and menu entries # 934# END: Handle .desktop files and menu entries #
1076############################################################## 935##############################################################
1477 local mline="" 1336 local mline=""
1478 local showedmsg=0 1337 local showedmsg=0
1479 1338
1480 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
1481 [[ -d ${mline}/${dir} ]] || continue 1340 [[ -d ${mline}/${dir} ]] || continue
1482 [[ ! -z $(find ${mline}/${dir} -iname ${file} -maxdepth 1) ]] \ 1341 [[ ! -z $(find ${mline}/${dir} -maxdepth 1 -iname ${file}) ]] \
1483 && export CDROM_ROOT=${mline} 1342 && export CDROM_ROOT=${mline}
1484 done 1343 done
1485 1344
1486 if [[ -z ${CDROM_ROOT} ]] ; then 1345 if [[ -z ${CDROM_ROOT} ]] ; then
1487 echo 1346 echo
1575 while ((i--)) ; do 1434 while ((i--)) ; do
1576 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass" 1435 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1577 done 1436 done
1578 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}" 1437 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}"
1579 case ${ARCH} in 1438 case ${ARCH} in
1580 x86) export ARCH="i386";; 1439 x86) export ARCH="i386";;
1581 amd64) export ARCH="x86_64";; 1440 amd64) export ARCH="x86_64";;
1582 hppa) export ARCH="parisc";; 1441 hppa) export ARCH="parisc";;
1583 mips) export ARCH="mips";; 1442 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! 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!
1585 *) export ARCH="${ARCH}";; 1444 *) export ARCH="${ARCH}";;
1586 esac 1445 esac
1587} 1446}
1588 1447
1589# set's ARCH back to what portage expects 1448# set's ARCH back to what portage expects
1590set_arch_to_portage() { 1449set_arch_to_portage() {
1697dopamd() { 1556dopamd() {
1698 [[ -z $1 ]] && die "dopamd requires at least one argument" 1557 [[ -z $1 ]] && die "dopamd requires at least one argument"
1699 1558
1700 use pam || return 0 1559 use pam || return 0
1701 1560
1702 insinto /etc/pam.d 1561 INSDESTTREE=/etc/pam.d \
1703 doins "$@" || die "failed to install $@" 1562 doins "$@" || die "failed to install $@"
1704} 1563}
1705# newpamd <old name> <new name> 1564# newpamd <old name> <new name>
1706# 1565#
1707# Install pam file <old name> as <new name> in /etc/pam.d 1566# Install pam file <old name> as <new name> in /etc/pam.d
1708newpamd() { 1567newpamd() {
1709 [[ $# -ne 2 ]] && die "newpamd requires two arguements" 1568 [[ $# -ne 2 ]] && die "newpamd requires two arguements"
1710 1569
1711 use pam || return 0 1570 use pam || return 0
1712 1571
1713 insinto /etc/pam.d 1572 INSDESTTREE=/etc/pam.d \
1714 newins "$1" "$2" || die "failed to install $1 as $2" 1573 newins "$1" "$2" || die "failed to install $1 as $2"
1715} 1574}
1716 1575
1717# make a wrapper script ... 1576# make a wrapper script ...
1718# NOTE: this was originally games_make_wrapper, but I noticed other places where 1577# 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.182

  ViewVC Help
Powered by ViewVC 1.1.20