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

Diff of /eclass/eutils.eclass

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

Revision 1.204 Revision 1.205
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.204 2005/10/07 04:15:20 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.205 2005/10/07 15:31:46 flameeyes 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.
408# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 408# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
409# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> 409# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
410# 410#
411# egetent(database, key) 411# egetent(database, key)
412egetent() { 412egetent() {
413 if [[ "${USERLAND}" == "Darwin" ]] ; then 413 case ${CHOST} in
414 *-darwin*)
414 case "$2" in 415 case "$2" in
415 *[!0-9]*) # Non numeric 416 *[!0-9]*) # Non numeric
416 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 417 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
417 ;; 418 ;;
418 *) # Numeric 419 *) # Numeric
419 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" 420 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
420 ;; 421 ;;
421 esac 422 esac
422 elif [[ "${USERLAND}" == "BSD" ]] ; then 423 ;;
424 *-freebsd*)
423 local opts action="user" 425 local opts action="user"
424 [[ $1 == "passwd" ]] || action="group" 426 [[ $1 == "passwd" ]] || action="group"
425 427
426 # lookup by uid/gid 428 # lookup by uid/gid
427 if [[ $2 == [[:digit:]]* ]] ; then 429 if [[ $2 == [[:digit:]]* ]] ; then
428 [[ ${action} == "user" ]] && opts="-u" || opts="-g" 430 [[ ${action} == "user" ]] && opts="-u" || opts="-g"
429 fi 431 fi
430 432
431 pw show ${action} ${opts} "$2" -q 433 pw show ${action} ${opts} "$2" -q
432 else 434 ;;
435 *)
433 which nscd >& /dev/null && nscd -i "$1" 436 type -p nscd >& /dev/null && nscd -i "$1"
434 getent "$1" "$2" 437 getent "$1" "$2"
435 fi 438 ;;
439 esac
436} 440}
437 441
438# Simplify/standardize adding users to the system 442# Simplify/standardize adding users to the system
439# vapier@gentoo.org 443# vapier@gentoo.org
440# 444#
549 einfo " - Groups: ${egroups}" 553 einfo " - Groups: ${egroups}"
550 554
551 # handle extra and add the user 555 # handle extra and add the user
552 local oldsandbox=${SANDBOX_ON} 556 local oldsandbox=${SANDBOX_ON}
553 export SANDBOX_ON="0" 557 export SANDBOX_ON="0"
554 case ${USERLAND} in 558 case ${CHOST} in
555 Darwin) 559 *-darwin*)
556 ### Make the user 560 ### Make the user
557 if [[ -z $@ ]] ; then 561 if [[ -z $@ ]] ; then
558 dscl . create /users/${euser} uid ${euid} 562 dscl . create /users/${euser} uid ${euid}
559 dscl . create /users/${euser} shell ${eshell} 563 dscl . create /users/${euser} shell ${eshell}
560 dscl . create /users/${euser} home ${ehome} 564 dscl . create /users/${euser} home ${ehome}
571 einfo "Please report the ebuild along with the info below" 575 einfo "Please report the ebuild along with the info below"
572 einfo "eextra: $@" 576 einfo "eextra: $@"
573 die "Required function missing" 577 die "Required function missing"
574 fi 578 fi
575 ;; 579 ;;
576 BSD) 580 *-freebsd*)
577 if [[ -z $@ ]] ; then 581 if [[ -z $@ ]] ; then
578 pw useradd ${euser} ${opts} \ 582 pw useradd ${euser} ${opts} \
579 -c "added by portage for ${PN}" \ 583 -c "added by portage for ${PN}" \
580 die "enewuser failed" 584 die "enewuser failed"
581 else 585 else
641 then 645 then
642 if [ "${egid}" -gt 0 ] 646 if [ "${egid}" -gt 0 ]
643 then 647 then
644 if [ -z "`egetent group ${egid}`" ] 648 if [ -z "`egetent group ${egid}`" ]
645 then 649 then
646 if [[ "${USERLAND}" == "Darwin" ]]; then 650 if [[ "${CHOST}" == *-darwin* ]]; then
647 opts="${opts} ${egid}" 651 opts="${opts} ${egid}"
648 else 652 else
649 opts="${opts} -g ${egid}" 653 opts="${opts} -g ${egid}"
650 fi 654 fi
651 else 655 else
665 opts="${opts} ${eextra}" 669 opts="${opts} ${eextra}"
666 670
667 # add the group 671 # add the group
668 local oldsandbox="${SANDBOX_ON}" 672 local oldsandbox="${SANDBOX_ON}"
669 export SANDBOX_ON="0" 673 export SANDBOX_ON="0"
670 if [[ "${USERLAND}" == "Darwin" ]]; then 674 case ${CHOST} in
675 *-darwin*)
671 if [ ! -z "${eextra}" ]; 676 if [ ! -z "${eextra}" ];
672 then 677 then
673 einfo "Extra options are not supported on Darwin/OS X yet" 678 einfo "Extra options are not supported on Darwin/OS X yet"
674 einfo "Please report the ebuild along with the info below" 679 einfo "Please report the ebuild along with the info below"
675 einfo "eextra: ${eextra}" 680 einfo "eextra: ${eextra}"
676 die "Required function missing" 681 die "Required function missing"
677 fi 682 fi
678 683
679 # If we need the next available 684 # If we need the next available
680 case ${egid} in 685 case ${egid} in
681 *[!0-9]*) # Non numeric 686 *[!0-9]*) # Non numeric
682 for egid in $(seq 101 999); do 687 for egid in $(seq 101 999); do
683 [ -z "`egetent group ${egid}`" ] && break 688 [ -z "`egetent group ${egid}`" ] && break
684 done 689 done
685 esac 690 esac
686 dscl . create /groups/${egroup} gid ${egid} 691 dscl . create /groups/${egroup} gid ${egid}
687 dscl . create /groups/${egroup} passwd '*' 692 dscl . create /groups/${egroup} passwd '*'
688 elif [[ "${USERLAND}" == "BSD" ]] ; then 693 ;;
694
695 *-freebsd*)
689 case ${egid} in 696 case ${egid} in
690 *[!0-9]*) # Non numeric 697 *[!0-9]*) # Non numeric
691 for egid in $(seq 101 999); do 698 for egid in $(seq 101 999); do
692 [ -z "`egetent group ${egid}`" ] && break 699 [ -z "`egetent group ${egid}`" ] && break
693 done 700 done
694 esac 701 esac
695 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed" 702 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
696 else 703 ;;
704 *)
697 groupadd ${opts} ${egroup} || die "enewgroup failed" 705 groupadd ${opts} ${egroup} || die "enewgroup failed"
698 fi 706 ;;
707 esac
699 export SANDBOX_ON="${oldsandbox}" 708 export SANDBOX_ON="${oldsandbox}"
700} 709}
701 710
702# Simple script to replace 'dos2unix' binaries 711# Simple script to replace 'dos2unix' binaries
703# vapier@gentoo.org 712# vapier@gentoo.org

Legend:
Removed from v.1.204  
changed lines
  Added in v.1.205

  ViewVC Help
Powered by ViewVC 1.1.20