| 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.178 2005/05/26 22:09:26 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.179 2005/05/28 05:50:29 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. |
| … | |
… | |
| 409 | # Joe Jezak <josejx@gmail.com> and usata@gentoo.org |
409 | # Joe Jezak <josejx@gmail.com> and usata@gentoo.org |
| 410 | # FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> |
410 | # FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> |
| 411 | # |
411 | # |
| 412 | # egetent(database, key) |
412 | # egetent(database, key) |
| 413 | egetent() { |
413 | egetent() { |
| 414 | if useq ppc-macos ; then |
414 | if [[ "${USERLAND}" == "Darwin" ]] ; then |
| 415 | case "$2" in |
415 | case "$2" in |
| 416 | *[!0-9]*) # Non numeric |
416 | *[!0-9]*) # Non numeric |
| 417 | nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" |
417 | nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" |
| 418 | ;; |
418 | ;; |
| 419 | *) # Numeric |
419 | *) # Numeric |
| 420 | nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" |
420 | nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" |
| 421 | ;; |
421 | ;; |
| 422 | esac |
422 | esac |
| 423 | elif useq x86-fbsd ; then |
423 | elif [[ "${USERLAND}" == "BSD" ]] ; then |
| 424 | local action |
424 | local action |
| 425 | if [ "$1" == "passwd" ] |
425 | if [ "$1" == "passwd" ] |
| 426 | then |
426 | then |
| 427 | action="user" |
427 | action="user" |
| 428 | else |
428 | else |
| … | |
… | |
| 507 | then |
507 | then |
| 508 | eerror "A shell was specified but it does not exist !" |
508 | eerror "A shell was specified but it does not exist !" |
| 509 | die "${eshell} does not exist" |
509 | die "${eshell} does not exist" |
| 510 | fi |
510 | fi |
| 511 | else |
511 | else |
| 512 | if [ "${USERLAND}" == "BSD" ] |
512 | if [[ "${USERLAND}" == "Darwin" ]]; then |
| 513 | then |
|
|
| 514 | eshell="/usr/bin/false" |
513 | eshell="/usr/bin/false" |
|
|
514 | elif [[ "${USERLAND}" == "BSD" ]]; then |
|
|
515 | eshell="/usr/sbin/nologin" |
| 515 | else |
516 | else |
| 516 | eshell="/bin/false" |
517 | eshell="/bin/false" |
| 517 | fi |
518 | fi |
| 518 | fi |
519 | fi |
| 519 | einfo " - Shell: ${eshell}" |
520 | einfo " - Shell: ${eshell}" |
| … | |
… | |
| 566 | |
567 | |
| 567 | # handle extra and add the user |
568 | # handle extra and add the user |
| 568 | local eextra="$@" |
569 | local eextra="$@" |
| 569 | local oldsandbox="${SANDBOX_ON}" |
570 | local oldsandbox="${SANDBOX_ON}" |
| 570 | export SANDBOX_ON="0" |
571 | export SANDBOX_ON="0" |
| 571 | if useq ppc-macos |
572 | if [[ "${USERLAND}" == "Darwin" ]] |
| 572 | then |
573 | then |
| 573 | ### Make the user |
574 | ### Make the user |
| 574 | if [ -z "${eextra}" ] |
575 | if [ -z "${eextra}" ] |
| 575 | then |
576 | then |
| 576 | dscl . create /users/${euser} uid ${euid} |
577 | dscl . create /users/${euser} uid ${euid} |
| … | |
… | |
| 589 | einfo "Extra options are not supported on macos yet" |
590 | einfo "Extra options are not supported on macos yet" |
| 590 | einfo "Please report the ebuild along with the info below" |
591 | einfo "Please report the ebuild along with the info below" |
| 591 | einfo "eextra: ${eextra}" |
592 | einfo "eextra: ${eextra}" |
| 592 | die "Required function missing" |
593 | die "Required function missing" |
| 593 | fi |
594 | fi |
| 594 | elif use x86-fbsd ; then |
595 | elif [[ "${USERLAND}" == "BSD" ]] ; then |
| 595 | if [ -z "${eextra}" ] |
596 | if [ -z "${eextra}" ] |
| 596 | then |
597 | then |
| 597 | pw useradd ${euser} ${opts} \ |
598 | pw useradd ${euser} ${opts} \ |
| 598 | -c "added by portage for ${PN}" \ |
599 | -c "added by portage for ${PN}" \ |
| 599 | die "enewuser failed" |
600 | die "enewuser failed" |
| … | |
… | |
| 659 | then |
660 | then |
| 660 | if [ "${egid}" -gt 0 ] |
661 | if [ "${egid}" -gt 0 ] |
| 661 | then |
662 | then |
| 662 | if [ -z "`egetent group ${egid}`" ] |
663 | if [ -z "`egetent group ${egid}`" ] |
| 663 | then |
664 | then |
| 664 | if useq ppc-macos ; then |
665 | if [[ "${USERLAND}" == "Darwin" ]]; then |
| 665 | opts="${opts} ${egid}" |
666 | opts="${opts} ${egid}" |
| 666 | else |
667 | else |
| 667 | opts="${opts} -g ${egid}" |
668 | opts="${opts} -g ${egid}" |
| 668 | fi |
669 | fi |
| 669 | else |
670 | else |
| … | |
… | |
| 683 | opts="${opts} ${eextra}" |
684 | opts="${opts} ${eextra}" |
| 684 | |
685 | |
| 685 | # add the group |
686 | # add the group |
| 686 | local oldsandbox="${SANDBOX_ON}" |
687 | local oldsandbox="${SANDBOX_ON}" |
| 687 | export SANDBOX_ON="0" |
688 | export SANDBOX_ON="0" |
| 688 | if useq ppc-macos ; then |
689 | if [[ "${USERLAND}" == "Darwin" ]]; then |
| 689 | if [ ! -z "${eextra}" ]; |
690 | if [ ! -z "${eextra}" ]; |
| 690 | then |
691 | then |
| 691 | einfo "Extra options are not supported on macos yet" |
692 | einfo "Extra options are not supported on Darwin/OS X yet" |
| 692 | einfo "Please report the ebuild along with the info below" |
693 | einfo "Please report the ebuild along with the info below" |
| 693 | einfo "eextra: ${eextra}" |
694 | einfo "eextra: ${eextra}" |
| 694 | die "Required function missing" |
695 | die "Required function missing" |
| 695 | fi |
696 | fi |
| 696 | |
697 | |
| … | |
… | |
| 701 | [ -z "`egetent group ${egid}`" ] && break |
702 | [ -z "`egetent group ${egid}`" ] && break |
| 702 | done |
703 | done |
| 703 | esac |
704 | esac |
| 704 | dscl . create /groups/${egroup} gid ${egid} |
705 | dscl . create /groups/${egroup} gid ${egid} |
| 705 | dscl . create /groups/${egroup} passwd '*' |
706 | dscl . create /groups/${egroup} passwd '*' |
| 706 | elif use x86-fbsd ; then |
707 | elif [[ "${USERLAND}" == "BSD" ]] ; then |
| 707 | case ${egid} in |
708 | case ${egid} in |
| 708 | *[!0-9]*) # Non numeric |
709 | *[!0-9]*) # Non numeric |
| 709 | for egid in `jot 898 101`; do |
710 | for egid in `jot 898 101`; do |
| 710 | [ -z "`egetent group ${egid}`" ] && break |
711 | [ -z "`egetent group ${egid}`" ] && break |
| 711 | done |
712 | done |