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

Diff of /eclass/eutils.eclass

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

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

  ViewVC Help
Powered by ViewVC 1.1.20