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

Diff of /eclass/eutils.eclass

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

Revision 1.179 Revision 1.187
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.179 2005/05/28 05:50:29 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.187 2005/07/06 20:23:20 agriffis 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.
9# 9#
10# NB: If you add anything, please comment it! 10# NB: If you add anything, please comment it!
11 11
12inherit multilib 12inherit multilib
13ECLASS=eutils
14INHERITED="$INHERITED $ECLASS"
15 13
16DEPEND="!bootstrap? ( sys-devel/patch )" 14DEPEND="!bootstrap? ( sys-devel/patch )"
15# sys-apps/shadow is needed for useradd, etc, bug #94745.
17 16
18DESCRIPTION="Based on the ${ECLASS} eclass" 17DESCRIPTION="Based on the ${ECLASS} eclass"
19 18
20# Wait for the supplied number of seconds. If no argument is supplied, defaults 19# 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 20# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not
448# homedir: /dev/null 447# homedir: /dev/null
449# groups: none 448# groups: none
450# extra: comment of 'added by portage for ${PN}' 449# extra: comment of 'added by portage for ${PN}'
451enewuser() { 450enewuser() {
452 # get the username 451 # get the username
453 local euser="$1"; shift 452 local euser=$1; shift
454 if [ -z "${euser}" ] 453 if [[ -z ${euser} ]] ; then
455 then
456 eerror "No username specified !" 454 eerror "No username specified !"
457 die "Cannot call enewuser without a username" 455 die "Cannot call enewuser without a username"
458 fi 456 fi
459 457
460 # lets see if the username already exists 458 # lets see if the username already exists
461 if [ "${euser}" == "`egetent passwd \"${euser}\" | cut -d: -f1`" ] 459 if [[ ${euser} == $(egetent passwd "${euser}" | cut -d: -f1) ]] ; then
462 then
463 return 0 460 return 0
464 fi 461 fi
465 einfo "Adding user '${euser}' to your system ..." 462 einfo "Adding user '${euser}' to your system ..."
466 463
467 # options to pass to useradd 464 # options to pass to useradd
468 local opts= 465 local opts=
469 466
470 # handle uid 467 # handle uid
471 local euid="$1"; shift 468 local euid=$1; shift
472 if [ ! -z "${euid}" ] && [ "${euid}" != "-1" ] 469 if [[ ! -z ${euid} ]] && [[ ${euid} != "-1" ]] ; then
473 then
474 if [ "${euid}" -gt 0 ] 470 if [[ ${euid} -gt 0 ]] ; then
475 then
476 if [ ! -z "`egetent passwd ${euid}`" ] 471 if [[ ! -z $(egetent passwd ${euid}) ]] ; then
477 then
478 euid="next" 472 euid="next"
479 fi 473 fi
480 else 474 else
481 eerror "Userid given but is not greater than 0 !" 475 eerror "Userid given but is not greater than 0 !"
482 die "${euid} is not a valid UID" 476 die "${euid} is not a valid UID"
483 fi 477 fi
484 else 478 else
485 euid="next" 479 euid="next"
486 fi 480 fi
487 if [ "${euid}" == "next" ] 481 if [[ ${euid} == "next" ]] ; then
488 then
489 local pwrange 482 local pwrange
490 if [ "${USERLAND}" == "BSD" ] ; then 483 if [[ ${USERLAND} == "BSD" ]] ; then
491 pwrange="`jot 898 101`" 484 pwrange=$(jot 898 101)
492 else 485 else
493 pwrange="`seq 101 999`" 486 pwrange=$(seq 101 999)
494 fi 487 fi
495 for euid in ${pwrange} ; do 488 for euid in ${pwrange} ; do
496 [ -z "`egetent passwd ${euid}`" ] && break 489 [[ -z $(egetent passwd ${euid}) ]] && break
497 done 490 done
498 fi 491 fi
499 opts="${opts} -u ${euid}" 492 opts="${opts} -u ${euid}"
500 einfo " - Userid: ${euid}" 493 einfo " - Userid: ${euid}"
501 494
502 # handle shell 495 # handle shell
503 local eshell="$1"; shift 496 local eshell=$1; shift
504 if [ ! -z "${eshell}" ] && [ "${eshell}" != "-1" ] 497 if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then
505 then
506 if [ ! -e "${eshell}" ] 498 if [[ ! -e ${eshell} ]] ; then
507 then
508 eerror "A shell was specified but it does not exist !" 499 eerror "A shell was specified but it does not exist !"
509 die "${eshell} does not exist" 500 die "${eshell} does not exist"
510 fi 501 fi
511 else 502 else
512 if [[ "${USERLAND}" == "Darwin" ]]; then 503 case ${USERLAND} in
513 eshell="/usr/bin/false" 504 Darwin) eshell="/usr/bin/false";;
514 elif [[ "${USERLAND}" == "BSD" ]]; then
515 eshell="/usr/sbin/nologin" 505 BSD) eshell="/usr/sbin/nologin";;
516 else
517 eshell="/bin/false" 506 *) eshell="/bin/false";;
518 fi 507 esac
519 fi 508 fi
520 einfo " - Shell: ${eshell}" 509 einfo " - Shell: ${eshell}"
521 opts="${opts} -s ${eshell}" 510 opts="${opts} -s ${eshell}"
522 511
523 # handle homedir 512 # handle homedir
524 local ehome="$1"; shift 513 local ehome=$1; shift
525 if [ -z "${ehome}" ] || [ "${eshell}" == "-1" ] 514 if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]] ; then
526 then
527 ehome="/dev/null" 515 ehome="/dev/null"
528 fi 516 fi
529 einfo " - Home: ${ehome}" 517 einfo " - Home: ${ehome}"
530 opts="${opts} -d ${ehome}" 518 opts="${opts} -d ${ehome}"
531 519
532 # handle groups 520 # handle groups
533 local egroups="$1"; shift 521 local egroups=$1; shift
534 if [ ! -z "${egroups}" ] 522 if [[ ! -z ${egroups} ]] ; then
535 then
536 local oldifs="${IFS}" 523 local oldifs=${IFS}
537 local defgroup="" exgroups="" 524 local defgroup="" exgroups=""
538 525
539 export IFS="," 526 export IFS=","
540 for g in ${egroups} 527 for g in ${egroups} ; do
541 do
542 export IFS="${oldifs}" 528 export IFS=${oldifs}
543 if [ -z "`egetent group \"${g}\"`" ] 529 if [[ -z $(egetent group "${g}") ]] ; then
544 then
545 eerror "You must add group ${g} to the system first" 530 eerror "You must add group ${g} to the system first"
546 die "${g} is not a valid GID" 531 die "${g} is not a valid GID"
547 fi 532 fi
548 if [ -z "${defgroup}" ] 533 if [[ -z ${defgroup} ]] ; then
549 then
550 defgroup="${g}" 534 defgroup=${g}
551 else 535 else
552 exgroups="${exgroups},${g}" 536 exgroups="${exgroups},${g}"
553 fi 537 fi
554 export IFS="," 538 export IFS=","
555 done 539 done
556 export IFS="${oldifs}" 540 export IFS=${oldifs}
557 541
558 opts="${opts} -g ${defgroup}" 542 opts="${opts} -g ${defgroup}"
559 if [ ! -z "${exgroups}" ] 543 if [[ ! -z ${exgroups} ]] ; then
560 then
561 opts="${opts} -G ${exgroups:1}" 544 opts="${opts} -G ${exgroups:1}"
562 fi 545 fi
563 else 546 else
564 egroups="(none)" 547 egroups="(none)"
565 fi 548 fi
566 einfo " - Groups: ${egroups}" 549 einfo " - Groups: ${egroups}"
567 550
568 # handle extra and add the user 551 # handle extra and add the user
569 local eextra="$@"
570 local oldsandbox="${SANDBOX_ON}" 552 local oldsandbox=${SANDBOX_ON}
571 export SANDBOX_ON="0" 553 export SANDBOX_ON="0"
572 if [[ "${USERLAND}" == "Darwin" ]] 554 case ${USERLAND} in
573 then 555 Darwin)
574 ### Make the user 556 ### Make the user
575 if [ -z "${eextra}" ] 557 if [[ -z $@ ]] ; then
576 then
577 dscl . create /users/${euser} uid ${euid} 558 dscl . create /users/${euser} uid ${euid}
578 dscl . create /users/${euser} shell ${eshell} 559 dscl . create /users/${euser} shell ${eshell}
579 dscl . create /users/${euser} home ${ehome} 560 dscl . create /users/${euser} home ${ehome}
580 dscl . create /users/${euser} realname "added by portage for ${PN}" 561 dscl . create /users/${euser} realname "added by portage for ${PN}"
581 ### Add the user to the groups specified 562 ### Add the user to the groups specified
582 local oldifs="${IFS}" 563 local oldifs=${IFS}
583 export IFS="," 564 export IFS=","
584 for g in ${egroups} 565 for g in ${egroups} ; do
585 do
586 dscl . merge /groups/${g} users ${euser} 566 dscl . merge /groups/${g} users ${euser}
587 done 567 done
588 export IFS="${oldifs}" 568 export IFS=${oldifs}
589 else 569 else
590 einfo "Extra options are not supported on macos yet" 570 einfo "Extra options are not supported on Darwin yet"
591 einfo "Please report the ebuild along with the info below" 571 einfo "Please report the ebuild along with the info below"
592 einfo "eextra: ${eextra}" 572 einfo "eextra: $@"
593 die "Required function missing" 573 die "Required function missing"
594 fi 574 fi
595 elif [[ "${USERLAND}" == "BSD" ]] ; then 575 ;;
596 if [ -z "${eextra}" ] 576 BSD)
597 then 577 if [[ -z $@ ]] ; then
598 pw useradd ${euser} ${opts} \ 578 pw useradd ${euser} ${opts} \
599 -c "added by portage for ${PN}" \ 579 -c "added by portage for ${PN}" \
600 die "enewuser failed" 580 die "enewuser failed"
601 else 581 else
602 einfo " - Extra: ${eextra}" 582 einfo " - Extra: $@"
603 pw useradd ${euser} ${opts} \ 583 pw useradd ${euser} ${opts} \
604 -c ${eextra} || die "enewuser failed" 584 "$@" || die "enewuser failed"
605 fi 585 fi
606 else 586 ;;
607 if [ -z "${eextra}" ] 587 *)
608 then 588 if [[ -z $@ ]] ; then
609 useradd ${opts} ${euser} \ 589 useradd ${opts} ${euser} \
610 -c "added by portage for ${PN}" \ 590 -c "added by portage for ${PN}" \
611 || die "enewuser failed" 591 || die "enewuser failed"
612 else 592 else
613 einfo " - Extra: ${eextra}" 593 einfo " - Extra: $@"
614 useradd ${opts} ${euser} ${eextra} \ 594 useradd ${opts} ${euser} "$@" \
615 || die "enewuser failed" 595 || die "enewuser failed"
616 fi 596 fi
617 fi 597 ;;
598 esac
618 export SANDBOX_ON="${oldsandbox}" 599 export SANDBOX_ON=${oldsandbox}
619 600
620 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ] 601 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ]
621 then 602 then
622 einfo " - Creating ${ehome} in ${D}" 603 einfo " - Creating ${ehome} in ${D}"
623 dodir ${ehome} 604 dodir ${ehome}
1378 fi 1359 fi
1379 showedmsg=1 1360 showedmsg=1
1380 fi 1361 fi
1381 einfo "Press return to scan for the cd again" 1362 einfo "Press return to scan for the cd again"
1382 einfo "or hit CTRL+C to abort the emerge." 1363 einfo "or hit CTRL+C to abort the emerge."
1364 echo
1365 einfo "If you are having trouble with the detection"
1366 einfo "of your CD, it is possible that you do not have"
1367 einfo "Joliet support enabled in your kernel. Please"
1368 einfo "check that CONFIG_JOLIET is enabled in your kernel."
1383 read 1369 read
1384 fi 1370 fi
1385 done 1371 done
1386} 1372}
1387 1373
1511 1497
1512 if [ -n "${LIB}" -a -f "${ROOT}${LIB}" ]; then 1498 if [ -n "${LIB}" -a -f "${ROOT}${LIB}" ]; then
1513 SONAME=`basename ${LIB}` 1499 SONAME=`basename ${LIB}`
1514 1500
1515 einfo "An old version of an installed library was detected on your system." 1501 einfo "An old version of an installed library was detected on your system."
1516 einfo "In order to avoid breaking packages that link against is, this older version" 1502 einfo "In order to avoid breaking packages that link against it, this older version"
1517 einfo "is not being removed. In order to make full use of this newer version," 1503 einfo "is not being removed. In order to make full use of this newer version,"
1518 einfo "you will need to execute the following command:" 1504 einfo "you will need to execute the following command:"
1519 einfo " revdep-rebuild --soname ${SONAME}" 1505 einfo " revdep-rebuild --soname ${SONAME}"
1520 einfo 1506 einfo
1521 einfo "After doing that, you can safely remove ${LIB}" 1507 einfo "After doing that, you can safely remove ${LIB}"

Legend:
Removed from v.1.179  
changed lines
  Added in v.1.187

  ViewVC Help
Powered by ViewVC 1.1.20