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

Diff of /eclass/eutils.eclass

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

Revision 1.113 Revision 1.118
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 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.113 2004/10/05 05:15:59 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.118 2004/10/13 14:33:01 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.
541 541
542# Cheap replacement for when debianutils (and thus mktemp) 542# Cheap replacement for when debianutils (and thus mktemp)
543# does not exist on the users system 543# does not exist on the users system
544# vapier@gentoo.org 544# vapier@gentoo.org
545# 545#
546# Takes just 1 parameter (the directory to create tmpfile in) 546# Takes just 1 optional parameter (the directory to create tmpfile in)
547mymktemp() { 547emktemp() {
548 local topdir="$1" 548 local topdir="$1"
549 549
550 [ -z "${topdir}" ] && topdir=/tmp 550 if [ -z "${topdir}" ]
551 if [ "`which mktemp 2>/dev/null`" ]
552 then 551 then
552 [ -z "${T}" ] \
553 && topdir="/tmp" \
554 || topdir="${T}"
555 fi
556
557 if [ -z "$(type -p mktemp)" ]
558 then
559 local tmp=/
560 while [ -e "${tmp}" ] ; do
561 tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}"
562 done
563 touch "${tmp}"
564 echo "${tmp}"
565 else
553 mktemp -p ${topdir} 566 mktemp -p "${topdir}"
554 else
555 local tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}"
556 touch ${tmp}
557 echo ${tmp}
558 fi 567 fi
559} 568}
560 569
561# Small wrapper for getent (Linux), nidump (Mac OS X), 570# Small wrapper for getent (Linux), nidump (Mac OS X),
562# and pw (FreeBSD) used in enewuser()/enewgroup() 571# and pw (FreeBSD) used in enewuser()/enewgroup()
563# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 572# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
564# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> 573# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
565# 574#
566# egetent(database, key) 575# egetent(database, key)
567egetent() { 576egetent() {
568 if use macos || use ppc-macos ; then 577 if useq macos || useq ppc-macos ; then
569 case "$2" in 578 case "$2" in
570 *[!0-9]*) # Non numeric 579 *[!0-9]*) # Non numeric
571 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 580 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
572 ;; 581 ;;
573 *) # Numeric 582 *) # Numeric
639 euid="next" 648 euid="next"
640 fi 649 fi
641 if [ "${euid}" == "next" ] 650 if [ "${euid}" == "next" ]
642 then 651 then
643 local pwrange 652 local pwrange
644 if use macos || use ppc-macos || [ "${USERLAND}" == "BSD" ] ; then 653 if [ "${USERLAND}" == "BSD" ] ; then
645 pwrange="`jot 898 101`" 654 pwrange="`jot 898 101`"
646 else 655 else
647 pwrange="`seq 101 999`" 656 pwrange="`seq 101 999`"
648 fi 657 fi
649 for euid in ${pwrange} ; do 658 for euid in ${pwrange} ; do
690 local defgroup="" exgroups="" 699 local defgroup="" exgroups=""
691 700
692 export IFS="," 701 export IFS=","
693 for g in ${egroups} 702 for g in ${egroups}
694 do 703 do
704 export IFS="${oldifs}"
695 if [ -z "`egetent group \"${g}\"`" ] 705 if [ -z "`egetent group \"${g}\"`" ]
696 then 706 then
697 eerror "You must add group ${g} to the system first" 707 eerror "You must add group ${g} to the system first"
698 die "${g} is not a valid GID" 708 die "${g} is not a valid GID"
699 fi 709 fi
701 then 711 then
702 defgroup="${g}" 712 defgroup="${g}"
703 else 713 else
704 exgroups="${exgroups},${g}" 714 exgroups="${exgroups},${g}"
705 fi 715 fi
716 export IFS=","
706 done 717 done
707 export IFS="${oldifs}" 718 export IFS="${oldifs}"
708 719
709 opts="${opts} -g ${defgroup}" 720 opts="${opts} -g ${defgroup}"
710 if [ ! -z "${exgroups}" ] 721 if [ ! -z "${exgroups}" ]
718 729
719 # handle extra and add the user 730 # handle extra and add the user
720 local eextra="$@" 731 local eextra="$@"
721 local oldsandbox="${SANDBOX_ON}" 732 local oldsandbox="${SANDBOX_ON}"
722 export SANDBOX_ON="0" 733 export SANDBOX_ON="0"
723 if use macos || use ppc-macos ; 734 if useq macos || useq ppc-macos ;
724 then 735 then
725 ### Make the user 736 ### Make the user
726 if [ -z "${eextra}" ] 737 if [ -z "${eextra}" ]
727 then 738 then
728 dscl . create /users/${euser} uid ${euid} 739 dscl . create /users/${euser} uid ${euid}
729 dscl . create /users/${euser} shell ${eshell} 740 dscl . create /users/${euser} shell ${eshell}
730 dscl . create /users/${euser} home ${ehome} 741 dscl . create /users/${euser} home ${ehome}
731 dscl . create /users/${euser} realname "added by portage for ${PN}" 742 dscl . create /users/${euser} realname "added by portage for ${PN}"
732 ### Add the user to the groups specified 743 ### Add the user to the groups specified
744 local oldifs="${IFS}"
745 export IFS=","
733 for g in ${egroups} 746 for g in ${egroups}
734 do 747 do
735 # $egroups is , delimited, not space
736 ewarn "This is code is wrong; someone on the OS X team should fix it"
737 dscl . merge /groups/${g} users ${euser} 748 dscl . merge /groups/${g} users ${euser}
738 done 749 done
750 export IFS="${oldifs}"
739 else 751 else
740 einfo "Extra options are not supported on macos yet" 752 einfo "Extra options are not supported on macos yet"
741 einfo "Please report the ebuild along with the info below" 753 einfo "Please report the ebuild along with the info below"
742 einfo "eextra: ${eextra}" 754 einfo "eextra: ${eextra}"
743 die "Required function missing" 755 die "Required function missing"
810 then 822 then
811 if [ "${egid}" -gt 0 ] 823 if [ "${egid}" -gt 0 ]
812 then 824 then
813 if [ -z "`egetent group ${egid}`" ] 825 if [ -z "`egetent group ${egid}`" ]
814 then 826 then
815 if use macos || use ppc-macos ; then 827 if useq macos || useq ppc-macos ; then
816 opts="${opts} ${egid}" 828 opts="${opts} ${egid}"
817 else 829 else
818 opts="${opts} -g ${egid}" 830 opts="${opts} -g ${egid}"
819 fi 831 fi
820 else 832 else
834 opts="${opts} ${eextra}" 846 opts="${opts} ${eextra}"
835 847
836 # add the group 848 # add the group
837 local oldsandbox="${SANDBOX_ON}" 849 local oldsandbox="${SANDBOX_ON}"
838 export SANDBOX_ON="0" 850 export SANDBOX_ON="0"
839 if use macos || use ppc-macos ; 851 if useq macos || useq ppc-macos ;
840 then 852 then
841 if [ ! -z "${eextra}" ]; 853 if [ ! -z "${eextra}" ];
842 then 854 then
843 einfo "Extra options are not supported on macos yet" 855 einfo "Extra options are not supported on macos yet"
844 einfo "Please report the ebuild along with the info below" 856 einfo "Please report the ebuild along with the info below"
882} 894}
883 895
884# Make a desktop file ! 896# Make a desktop file !
885# Great for making those icons in kde/gnome startmenu ! 897# Great for making those icons in kde/gnome startmenu !
886# Amaze your friends ! Get the women ! Join today ! 898# Amaze your friends ! Get the women ! Join today !
887# gnome2 /usr/share/applications
888# gnome1 /usr/share/gnome/apps/
889# KDE ${KDEDIR}/share/applnk /usr/share/applnk
890# 899#
891# make_desktop_entry(<binary>, [name], [icon], [type], [path]) 900# make_desktop_entry(<binary>, [name], [icon], [type], [path])
892# 901#
893# binary: what binary does the app run with ? 902# binary: what binary does the app run with ?
894# name: the name that will show up in the menu 903# name: the name that will show up in the menu
895# icon: give your little like a pretty little icon ... 904# icon: give your little like a pretty little icon ...
896# this can be relative (to /usr/share/pixmaps) or 905# this can be relative (to /usr/share/pixmaps) or
897# a full path to an icon 906# a full path to an icon
898# type: what kind of application is this ? for categories: 907# type: what kind of application is this ? for categories:
899# http://www.freedesktop.org/standards/menu-spec/ 908# http://www.freedesktop.org/standards/menu-spec/
900# path: if your app needs to startup in a specific dir 909# path: if your app needs to startup in a specific dir
901make_desktop_entry() { 910make_desktop_entry() {
902 [ -z "$1" ] && eerror "You must specify the executable" && return 1 911 [ -z "$1" ] && eerror "make_desktop_entry: You must specify the executable" && return 1
903 912
904 local exec="${1}" 913 local exec="${1}"
905 local name="${2:-${PN}}" 914 local name="${2:-${PN}}"
906 local icon="${3:-${PN}.png}" 915 local icon="${3:-${PN}.png}"
907 local type="${4}" 916 local type="${4}"
939Exec=${exec} 948Exec=${exec}
940Path=${path} 949Path=${path}
941Icon=${icon} 950Icon=${icon}
942Categories=Application;${type};" > "${desktop}" 951Categories=Application;${type};" > "${desktop}"
943 952
944 if [ -d "/usr/share/applications" ]
945 then
946 insinto /usr/share/applications 953 insinto /usr/share/applications
947 doins "${desktop}" 954 doins "${desktop}"
948 fi
949
950 #if [ -d "/usr/share/gnome/apps" ]
951 #then
952 # insinto /usr/share/gnome/apps/Games
953 # doins ${desktop}
954 #fi
955
956 #if [ ! -z "`ls /usr/kde/* 2>/dev/null`" ]
957 #then
958 # for ver in /usr/kde/*
959 # do
960 # insinto ${ver}/share/applnk/Games
961 # doins ${desktop}
962 # done
963 #fi
964
965 if [ -d "/usr/share/applnk" ]
966 then
967 insinto /usr/share/applnk/${subdir}
968 doins "${desktop}"
969 fi
970 955
971 return 0 956 return 0
972} 957}
973 958
974# for internal use only (unpack_pdv and unpack_makeself) 959# for internal use only (unpack_pdv and unpack_makeself)
1023 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1008 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1024 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"` 1009 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"`
1025 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"` 1010 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"`
1026 1011
1027 # grab metadata for debug reasons 1012 # grab metadata for debug reasons
1028 local metafile="`mymktemp ${T}`" 1013 local metafile="$(emktemp)"
1029 tail -c +$((${metaskip}+1)) ${src} > ${metafile} 1014 tail -c +$((${metaskip}+1)) ${src} > ${metafile}
1030 1015
1031 # rip out the final file name from the metadata 1016 # rip out the final file name from the metadata
1032 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`" 1017 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`"
1033 datafile="`basename ${datafile}`" 1018 datafile="`basename ${datafile}`"
1034 1019
1035 # now lets uncompress/untar the file if need be 1020 # now lets uncompress/untar the file if need be
1036 local tmpfile="`mymktemp ${T}`" 1021 local tmpfile="$(emktemp)"
1037 tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile} 1022 tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile}
1038 1023
1039 local iscompressed="`file -b ${tmpfile}`" 1024 local iscompressed="`file -b ${tmpfile}`"
1040 if [ "${iscompressed:0:8}" == "compress" ] ; then 1025 if [ "${iscompressed:0:8}" == "compress" ] ; then
1041 iscompressed=1 1026 iscompressed=1
1143 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; 1128 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";;
1144 *) die "makeself cant handle exe '${exe}'" 1129 *) die "makeself cant handle exe '${exe}'"
1145 esac 1130 esac
1146 1131
1147 # lets grab the first few bytes of the file to figure out what kind of archive it is 1132 # lets grab the first few bytes of the file to figure out what kind of archive it is
1148 local tmpfile="$(mymktemp "${T}")" 1133 local tmpfile="$(emktemp)"
1149 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" 1134 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}"
1150 local filetype="$(file -b "${tmpfile}")" 1135 local filetype="$(file -b "${tmpfile}")"
1151 case ${filetype} in 1136 case ${filetype} in
1152 *tar\ archive) 1137 *tar\ archive)
1153 eval ${exe} | tar --no-same-owner -xf - 1138 eval ${exe} | tar --no-same-owner -xf -
1200 return 0 1185 return 0
1201 fi 1186 fi
1202 done 1187 done
1203 set +o noglob; set -$shopts #reset old shell opts 1188 set +o noglob; set -$shopts #reset old shell opts
1204 1189
1205 local licmsg="`mymktemp ${T}`" 1190 local licmsg="$(emktemp)"
1206 cat << EOF > ${licmsg} 1191 cat << EOF > ${licmsg}
1207********************************************************** 1192**********************************************************
1208The following license outlines the terms of use of this 1193The following license outlines the terms of use of this
1209package. You MUST accept this license for installation to 1194package. You MUST accept this license for installation to
1210continue. When you are done viewing, hit 'q'. If you 1195continue. When you are done viewing, hit 'q'. If you
1521 einfo "is not being removed. In order to make full use of this newer version," 1506 einfo "is not being removed. In order to make full use of this newer version,"
1522 einfo "you will need to execute the following command:" 1507 einfo "you will need to execute the following command:"
1523 einfo " revdep-rebuild --soname ${SONAME}" 1508 einfo " revdep-rebuild --soname ${SONAME}"
1524 einfo 1509 einfo
1525 einfo "After doing that, you can safely remove ${LIB}" 1510 einfo "After doing that, you can safely remove ${LIB}"
1511 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild"
1526 fi 1512 fi
1527} 1513}

Legend:
Removed from v.1.113  
changed lines
  Added in v.1.118

  ViewVC Help
Powered by ViewVC 1.1.20