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

Diff of /eclass/eutils.eclass

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

Revision 1.175 Revision 1.191
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.175 2005/05/25 00:04:25 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.191 2005/07/13 19:15:05 eradicator 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
68 dodir /usr/${libdir} 67 dodir /usr/${libdir}
69 68
70 for lib in "${@}" ; do 69 for lib in "${@}" ; do
71 cat > "${D}/usr/${libdir}/${lib}" <<-END_LDSCRIPT 70 cat > "${D}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
72 /* GNU ld script 71 /* GNU ld script
73 Since Gentoo has critical dynamic libraries 72 Since Gentoo has critical dynamic libraries
74 in /lib, and the static versions in /usr/lib, 73 in /lib, and the static versions in /usr/lib,
75 we need to have a "fake" dynamic lib in /usr/lib, 74 we need to have a "fake" dynamic lib in /usr/lib,
76 otherwise we run into linking problems. 75 otherwise we run into linking problems.
77 76
78 See bug http://bugs.gentoo.org/4411 for more info. 77 See bug http://bugs.gentoo.org/4411 for more info.
79 */ 78 */
80 GROUP ( /${libdir}/${lib} ) 79 GROUP ( /${libdir}/${lib} )
81 END_LDSCRIPT 80 END_LDSCRIPT
82 fperms a+x "/usr/${libdir}/${lib}" 81 fperms a+x "/usr/${libdir}/${lib}"
249 # New ARCH dependant patch naming scheme ... 248 # New ARCH dependant patch naming scheme ...
250 # 249 #
251 # ???_arch_foo.patch 250 # ???_arch_foo.patch
252 # 251 #
253 if [ -f ${x} ] && \ 252 if [ -f ${x} ] && \
254 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ 253 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "${x/_${ARCH}_}" != "${x}" ] || \
255 [ "${EPATCH_FORCE}" = "yes" ]) 254 [ "${EPATCH_FORCE}" = "yes" ])
256 then 255 then
257 local count=0 256 local count=0
258 local popts="${EPATCH_OPTS}" 257 local popts="${EPATCH_OPTS}"
259 local patchname=${x##*/} 258 local patchname=${x##*/}
409# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 408# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
410# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> 409# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
411# 410#
412# egetent(database, key) 411# egetent(database, key)
413egetent() { 412egetent() {
414 if useq ppc-macos ; then 413 if [[ "${USERLAND}" == "Darwin" ]] ; then
415 case "$2" in 414 case "$2" in
416 *[!0-9]*) # Non numeric 415 *[!0-9]*) # Non numeric
417 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 416 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
418 ;; 417 ;;
419 *) # Numeric 418 *) # Numeric
420 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }" 419 nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
421 ;; 420 ;;
422 esac 421 esac
423 elif useq x86-fbsd ; then 422 elif [[ "${USERLAND}" == "BSD" ]] ; then
424 local action 423 local action
425 if [ "$1" == "passwd" ] 424 if [ "$1" == "passwd" ]
426 then 425 then
427 action="user" 426 action="user"
428 else 427 else
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}" == "BSD" ] 503 case ${USERLAND} in
513 then
514 eshell="/usr/bin/false" 504 Darwin) eshell="/usr/bin/false";;
515 else 505 BSD) eshell="/usr/sbin/nologin";;
516 eshell="/bin/false" 506 *) eshell="/bin/false";;
517 fi 507 esac
518 fi 508 fi
519 einfo " - Shell: ${eshell}" 509 einfo " - Shell: ${eshell}"
520 opts="${opts} -s ${eshell}" 510 opts="${opts} -s ${eshell}"
521 511
522 # handle homedir 512 # handle homedir
523 local ehome="$1"; shift 513 local ehome=$1; shift
524 if [ ! -z "${ehome}" ] && [ "${eshell}" != "-1" ] 514 if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]] ; then
525 then
526 ehome="/dev/null" 515 ehome="/dev/null"
527 fi 516 fi
528 einfo " - Home: ${ehome}" 517 einfo " - Home: ${ehome}"
529 opts="${opts} -d ${ehome}" 518 opts="${opts} -d ${ehome}"
530 519
531 # handle groups 520 # handle groups
532 local egroups="$1"; shift 521 local egroups=$1; shift
533 if [ ! -z "${egroups}" ] 522 if [[ ! -z ${egroups} ]] ; then
534 then
535 local oldifs="${IFS}" 523 local oldifs=${IFS}
536 local defgroup="" exgroups="" 524 local defgroup="" exgroups=""
537 525
538 export IFS="," 526 export IFS=","
539 for g in ${egroups} 527 for g in ${egroups} ; do
540 do
541 export IFS="${oldifs}" 528 export IFS=${oldifs}
542 if [ -z "`egetent group \"${g}\"`" ] 529 if [[ -z $(egetent group "${g}") ]] ; then
543 then
544 eerror "You must add group ${g} to the system first" 530 eerror "You must add group ${g} to the system first"
545 die "${g} is not a valid GID" 531 die "${g} is not a valid GID"
546 fi 532 fi
547 if [ -z "${defgroup}" ] 533 if [[ -z ${defgroup} ]] ; then
548 then
549 defgroup="${g}" 534 defgroup=${g}
550 else 535 else
551 exgroups="${exgroups},${g}" 536 exgroups="${exgroups},${g}"
552 fi 537 fi
553 export IFS="," 538 export IFS=","
554 done 539 done
555 export IFS="${oldifs}" 540 export IFS=${oldifs}
556 541
557 opts="${opts} -g ${defgroup}" 542 opts="${opts} -g ${defgroup}"
558 if [ ! -z "${exgroups}" ] 543 if [[ ! -z ${exgroups} ]] ; then
559 then
560 opts="${opts} -G ${exgroups:1}" 544 opts="${opts} -G ${exgroups:1}"
561 fi 545 fi
562 else 546 else
563 egroups="(none)" 547 egroups="(none)"
564 fi 548 fi
565 einfo " - Groups: ${egroups}" 549 einfo " - Groups: ${egroups}"
566 550
567 # handle extra and add the user 551 # handle extra and add the user
568 local eextra="$@"
569 local oldsandbox="${SANDBOX_ON}" 552 local oldsandbox=${SANDBOX_ON}
570 export SANDBOX_ON="0" 553 export SANDBOX_ON="0"
571 if useq ppc-macos 554 case ${USERLAND} in
572 then 555 Darwin)
573 ### Make the user 556 ### Make the user
574 if [ -z "${eextra}" ] 557 if [[ -z $@ ]] ; then
575 then
576 dscl . create /users/${euser} uid ${euid} 558 dscl . create /users/${euser} uid ${euid}
577 dscl . create /users/${euser} shell ${eshell} 559 dscl . create /users/${euser} shell ${eshell}
578 dscl . create /users/${euser} home ${ehome} 560 dscl . create /users/${euser} home ${ehome}
579 dscl . create /users/${euser} realname "added by portage for ${PN}" 561 dscl . create /users/${euser} realname "added by portage for ${PN}"
580 ### Add the user to the groups specified 562 ### Add the user to the groups specified
581 local oldifs="${IFS}" 563 local oldifs=${IFS}
582 export IFS="," 564 export IFS=","
583 for g in ${egroups} 565 for g in ${egroups} ; do
584 do
585 dscl . merge /groups/${g} users ${euser} 566 dscl . merge /groups/${g} users ${euser}
586 done 567 done
587 export IFS="${oldifs}" 568 export IFS=${oldifs}
588 else 569 else
589 einfo "Extra options are not supported on macos yet" 570 einfo "Extra options are not supported on Darwin yet"
590 einfo "Please report the ebuild along with the info below" 571 einfo "Please report the ebuild along with the info below"
591 einfo "eextra: ${eextra}" 572 einfo "eextra: $@"
592 die "Required function missing" 573 die "Required function missing"
593 fi 574 fi
594 elif use x86-fbsd ; then 575 ;;
595 if [ -z "${eextra}" ] 576 BSD)
596 then 577 if [[ -z $@ ]] ; then
597 pw useradd ${euser} ${opts} \ 578 pw useradd ${euser} ${opts} \
598 -c "added by portage for ${PN}" \ 579 -c "added by portage for ${PN}" \
599 die "enewuser failed" 580 die "enewuser failed"
600 else 581 else
601 einfo " - Extra: ${eextra}" 582 einfo " - Extra: $@"
602 pw useradd ${euser} ${opts} \ 583 pw useradd ${euser} ${opts} \
603 -c ${eextra} || die "enewuser failed" 584 "$@" || die "enewuser failed"
604 fi 585 fi
605 else 586 ;;
606 if [ -z "${eextra}" ] 587 *)
607 then 588 if [[ -z $@ ]] ; then
608 useradd ${opts} ${euser} \ 589 useradd ${opts} ${euser} \
609 -c "added by portage for ${PN}" \ 590 -c "added by portage for ${PN}" \
610 || die "enewuser failed" 591 || die "enewuser failed"
611 else 592 else
612 einfo " - Extra: ${eextra}" 593 einfo " - Extra: $@"
613 useradd ${opts} ${euser} ${eextra} \ 594 useradd ${opts} ${euser} "$@" \
614 || die "enewuser failed" 595 || die "enewuser failed"
615 fi 596 fi
616 fi 597 ;;
598 esac
617 export SANDBOX_ON="${oldsandbox}" 599 export SANDBOX_ON=${oldsandbox}
618 600
619 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ] 601 if [ ! -e "${ehome}" ] && [ ! -e "${D}/${ehome}" ]
620 then 602 then
621 einfo " - Creating ${ehome} in ${D}" 603 einfo " - Creating ${ehome} in ${D}"
622 dodir ${ehome} 604 dodir ${ehome}
659 then 641 then
660 if [ "${egid}" -gt 0 ] 642 if [ "${egid}" -gt 0 ]
661 then 643 then
662 if [ -z "`egetent group ${egid}`" ] 644 if [ -z "`egetent group ${egid}`" ]
663 then 645 then
664 if useq ppc-macos ; then 646 if [[ "${USERLAND}" == "Darwin" ]]; then
665 opts="${opts} ${egid}" 647 opts="${opts} ${egid}"
666 else 648 else
667 opts="${opts} -g ${egid}" 649 opts="${opts} -g ${egid}"
668 fi 650 fi
669 else 651 else
683 opts="${opts} ${eextra}" 665 opts="${opts} ${eextra}"
684 666
685 # add the group 667 # add the group
686 local oldsandbox="${SANDBOX_ON}" 668 local oldsandbox="${SANDBOX_ON}"
687 export SANDBOX_ON="0" 669 export SANDBOX_ON="0"
688 if useq ppc-macos ; then 670 if [[ "${USERLAND}" == "Darwin" ]]; then
689 if [ ! -z "${eextra}" ]; 671 if [ ! -z "${eextra}" ];
690 then 672 then
691 einfo "Extra options are not supported on macos yet" 673 einfo "Extra options are not supported on Darwin/OS X yet"
692 einfo "Please report the ebuild along with the info below" 674 einfo "Please report the ebuild along with the info below"
693 einfo "eextra: ${eextra}" 675 einfo "eextra: ${eextra}"
694 die "Required function missing" 676 die "Required function missing"
695 fi 677 fi
696 678
701 [ -z "`egetent group ${egid}`" ] && break 683 [ -z "`egetent group ${egid}`" ] && break
702 done 684 done
703 esac 685 esac
704 dscl . create /groups/${egroup} gid ${egid} 686 dscl . create /groups/${egroup} gid ${egid}
705 dscl . create /groups/${egroup} passwd '*' 687 dscl . create /groups/${egroup} passwd '*'
706 elif use x86-fbsd ; then 688 elif [[ "${USERLAND}" == "BSD" ]] ; then
707 case ${egid} in 689 case ${egid} in
708 *[!0-9]*) # Non numeric 690 *[!0-9]*) # Non numeric
709 for egid in `jot 898 101`; do 691 for egid in `jot 898 101`; do
710 [ -z "`egetent group ${egid}`" ] && break 692 [ -z "`egetent group ${egid}`" ] && break
711 done 693 done
858 *) 840 *)
859 type= 841 type=
860 ;; 842 ;;
861 esac 843 esac
862 fi 844 fi
863 845 if [ "${SLOT}" == "0" ] ; then
846 local desktop_name="${PN}"
847 else
848 local desktop_name="${PN}-${SLOT}"
849 fi
864 local desktop=${T}/${exec%% *}-${P}.desktop 850 local desktop=${T}/${exec%% *}-${desktop_name}.desktop
865 851
866echo "[Desktop Entry] 852echo "[Desktop Entry]
867Encoding=UTF-8 853Encoding=UTF-8
868Version=0.9.2 854Version=0.9.2
869Name=${name} 855Name=${name}
914 doins "${i}" 900 doins "${i}"
915 elif [[ -d ${i} ]] ; then 901 elif [[ -d ${i} ]] ; then
916 for j in "${i}"/*.desktop ; do 902 for j in "${i}"/*.desktop ; do
917 doins "${j}" 903 doins "${j}"
918 done 904 done
919 fi 905 fi
920 done 906 done
921} 907}
922newmenu() { 908newmenu() {
923 insinto /usr/share/applications 909 insinto /usr/share/applications
924 newins "$1" "$2" 910 newins "$1" "$2"
932 doins "${i}" 918 doins "${i}"
933 elif [[ -d ${i} ]] ; then 919 elif [[ -d ${i} ]] ; then
934 for j in "${i}"/*.png ; do 920 for j in "${i}"/*.png ; do
935 doins "${j}" 921 doins "${j}"
936 done 922 done
937 fi 923 fi
938 done 924 done
939} 925}
940newicon() { 926newicon() {
941 insinto /usr/share/pixmaps 927 insinto /usr/share/pixmaps
942 newins "$1" "$2" 928 newins "$1" "$2"
1373 fi 1359 fi
1374 showedmsg=1 1360 showedmsg=1
1375 fi 1361 fi
1376 einfo "Press return to scan for the cd again" 1362 einfo "Press return to scan for the cd again"
1377 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."
1378 read 1369 read
1379 fi 1370 fi
1380 done 1371 done
1381} 1372}
1382 1373
1446 while ((i--)) ; do 1437 while ((i--)) ; do
1447 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass" 1438 ewarn "PLEASE UPDATE TO YOUR PACKAGE TO USE linux-info.eclass"
1448 done 1439 done
1449 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}" 1440 export EUTILS_ECLASS_PORTAGE_ARCH="${ARCH}"
1450 case ${ARCH} in 1441 case ${ARCH} in
1451 x86) export ARCH="i386";; 1442 x86) export ARCH="i386";;
1452 amd64) export ARCH="x86_64";; 1443 amd64) export ARCH="x86_64";;
1453 hppa) export ARCH="parisc";; 1444 hppa) export ARCH="parisc";;
1454 mips) export ARCH="mips";; 1445 mips) export ARCH="mips";;
1455 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! 1446 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!
1456 *) export ARCH="${ARCH}";; 1447 *) export ARCH="${ARCH}";;
1457 esac 1448 esac
1458} 1449}
1459 1450
1460# set's ARCH back to what portage expects 1451# set's ARCH back to what portage expects
1461set_arch_to_portage() { 1452set_arch_to_portage() {
1505 LIB=$1 1496 LIB=$1
1506 1497
1507 if [ -n "${LIB}" -a -f "${ROOT}${LIB}" ]; then 1498 if [ -n "${LIB}" -a -f "${ROOT}${LIB}" ]; then
1508 SONAME=`basename ${LIB}` 1499 SONAME=`basename ${LIB}`
1509 1500
1510 einfo "An old version of an installed library was detected on your system." 1501 ewarn "An old version of an installed library was detected on your system."
1511 einfo "In order to avoid breaking packages that link against is, this older version" 1502 ewarn "In order to avoid breaking packages that link against it, this older version"
1512 einfo "is not being removed. In order to make full use of this newer version," 1503 ewarn "is not being removed. In order to make full use of this newer version,"
1513 einfo "you will need to execute the following command:" 1504 ewarn "you will need to execute the following command:"
1514 einfo " revdep-rebuild --soname ${SONAME}" 1505 ewarn " revdep-rebuild --soname ${SONAME}"
1515 einfo 1506 ewarn
1516 einfo "After doing that, you can safely remove ${LIB}" 1507 ewarn "After doing that, you can safely remove ${LIB}"
1517 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild" 1508 ewarn "Note: 'emerge gentoolkit' to get revdep-rebuild"
1518 fi 1509 fi
1519} 1510}
1520 1511
1521# Hack for people to figure out if a package was built with 1512# Hack for people to figure out if a package was built with
1522# certain USE flags 1513# certain USE flags

Legend:
Removed from v.1.175  
changed lines
  Added in v.1.191

  ViewVC Help
Powered by ViewVC 1.1.20