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

Diff of /eclass/eutils.eclass

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

Revision 1.255 Revision 1.256
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 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.255 2006/10/24 17:27:31 wolf31o2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.256 2006/10/31 19:29:12 agriffis Exp $
4# 4#
5# This eclass is for general purpose functions that most ebuilds 5# This eclass is for general purpose functions that most ebuilds
6# have to implement themselves. 6# have to implement themselves.
7# 7#
8# NB: If you add anything, please comment it! 8# NB: If you add anything, please comment it!
454 eerror "No username specified !" 454 eerror "No username specified !"
455 die "Cannot call enewuser without a username" 455 die "Cannot call enewuser without a username"
456 fi 456 fi
457 457
458 # lets see if the username already exists 458 # lets see if the username already exists
459 if [[ ${euser} == $(egetent passwd "${euser}" | cut -d: -f1) ]] ; then 459 if [[ -n $(egetent passwd "${euser}") ]] ; then
460 return 0 460 return 0
461 fi 461 fi
462 einfo "Adding user '${euser}' to your system ..." 462 einfo "Adding user '${euser}' to your system ..."
463 463
464 # options to pass to useradd 464 # options to pass to useradd
465 local opts= 465 local opts=
466 466
467 # handle uid 467 # handle uid
468 local euid=$1; shift 468 local euid=$1; shift
469 if [[ ! -z ${euid} ]] && [[ ${euid} != "-1" ]] ; then 469 if [[ -n ${euid} && ${euid} != -1 ]] ; then
470 if [[ ${euid} -gt 0 ]] ; then 470 if [[ ${euid} -gt 0 ]] ; then
471 if [[ ! -z $(egetent passwd ${euid}) ]] ; then 471 if [[ -n $(egetent passwd ${euid}) ]] ; then
472 euid="next" 472 euid="next"
473 fi 473 fi
474 else 474 else
475 eerror "Userid given but is not greater than 0 !" 475 eerror "Userid given but is not greater than 0 !"
476 die "${euid} is not a valid UID" 476 die "${euid} is not a valid UID"
477 fi 477 fi
478 else 478 else
479 euid="next" 479 euid="next"
480 fi 480 fi
481 if [[ ${euid} == "next" ]] ; then 481 if [[ ${euid} == "next" ]] ; then
482 for euid in $(seq 101 999) ; do 482 for ((euid = 101; euid <= 999; euid++)); do
483 [[ -z $(egetent passwd ${euid}) ]] && break 483 [[ -z $(egetent passwd ${euid}) ]] && break
484 done 484 done
485 fi 485 fi
486 opts="${opts} -u ${euid}" 486 opts="${opts} -u ${euid}"
487 einfo " - Userid: ${euid}" 487 einfo " - Userid: ${euid}"
662 eerror "No group specified !" 662 eerror "No group specified !"
663 die "Cannot call enewgroup without a group" 663 die "Cannot call enewgroup without a group"
664 fi 664 fi
665 665
666 # see if group already exists 666 # see if group already exists
667 if [ "${egroup}" == "`egetent group \"${egroup}\" | cut -d: -f1`" ] 667 if [[ -n $(egetent group "${egroup}") ]]; then
668 then
669 return 0 668 return 0
670 fi 669 fi
671 einfo "Adding group '${egroup}' to your system ..." 670 einfo "Adding group '${egroup}' to your system ..."
672 671
673 # options to pass to useradd 672 # options to pass to useradd
716 fi 715 fi
717 716
718 # If we need the next available 717 # If we need the next available
719 case ${egid} in 718 case ${egid} in
720 *[!0-9]*) # Non numeric 719 *[!0-9]*) # Non numeric
721 for egid in $(seq 101 999); do 720 for ((egid = 101; egid <= 999; egid++)); do
722 [ -z "`egetent group ${egid}`" ] && break 721 [[ -z $(egetent group ${egid}) ]] && break
723 done 722 done
724 esac 723 esac
725 dscl . create /groups/${egroup} gid ${egid} 724 dscl . create /groups/${egroup} gid ${egid}
726 dscl . create /groups/${egroup} passwd '*' 725 dscl . create /groups/${egroup} passwd '*'
727 ;; 726 ;;
728 727
729 *-freebsd*|*-dragonfly*) 728 *-freebsd*|*-dragonfly*)
730 case ${egid} in 729 case ${egid} in
731 *[!0-9]*) # Non numeric 730 *[!0-9]*) # Non numeric
732 for egid in $(seq 101 999); do 731 for ((egid = 101; egid <= 999; egid++)); do
733 [ -z "`egetent group ${egid}`" ] && break 732 [[ -z $(egetent group ${egid}) ]] && break
734 done 733 done
735 esac 734 esac
736 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed" 735 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
737 ;; 736 ;;
738 737
739 *-netbsd*) 738 *-netbsd*)
740 case ${egid} in 739 case ${egid} in
741 *[!0-9]*) # Non numeric 740 *[!0-9]*) # Non numeric
742 for egid in $(seq 101 999); do 741 for ((egid = 101; egid <= 999; egid++)); do
743 [ -z "`egetent group ${egid}`" ] && break 742 [[ -z $(egetent group ${egid}) ]] && break
744 done 743 done
745 esac 744 esac
746 groupadd -g ${egid} ${egroup} || die "enewgroup failed" 745 groupadd -g ${egid} ${egroup} || die "enewgroup failed"
747 ;; 746 ;;
748 747

Legend:
Removed from v.1.255  
changed lines
  Added in v.1.256

  ViewVC Help
Powered by ViewVC 1.1.20