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

Diff of /eclass/eutils.eclass

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

Revision 1.195 Revision 1.200
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.195 2005/09/01 05:56:35 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.200 2005/09/23 20:44:26 wolf31o2 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 portability
13 13
14DEPEND="!bootstrap? ( sys-devel/patch )" 14DEPEND="!bootstrap? ( sys-devel/patch )"
15# sys-apps/shadow is needed for useradd, etc, bug #94745. 15# sys-apps/shadow is needed for useradd, etc, bug #94745.
16 16
17DESCRIPTION="Based on the ${ECLASS} eclass" 17DESCRIPTION="Based on the ${ECLASS} eclass"
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 local pwrange 482 for euid in $(seq 101 999) ; do
483 if [[ ${USERLAND} == "BSD" ]] ; then
484 pwrange=$(jot 898 101)
485 else
486 pwrange=$(seq 101 999)
487 fi
488 for euid in ${pwrange} ; do
489 [[ -z $(egetent passwd ${euid}) ]] && break 483 [[ -z $(egetent passwd ${euid}) ]] && break
490 done 484 done
491 fi 485 fi
492 opts="${opts} -u ${euid}" 486 opts="${opts} -u ${euid}"
493 einfo " - Userid: ${euid}" 487 einfo " - Userid: ${euid}"
498 if [[ ! -e ${eshell} ]] ; then 492 if [[ ! -e ${eshell} ]] ; then
499 eerror "A shell was specified but it does not exist !" 493 eerror "A shell was specified but it does not exist !"
500 die "${eshell} does not exist" 494 die "${eshell} does not exist"
501 fi 495 fi
502 else 496 else
503 case ${USERLAND} in 497 for shell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null; do
504 Darwin) eshell="/usr/bin/false";; 498 [[ -x ${ROOT}${shell} ]] && break;
505 BSD) eshell="/usr/sbin/nologin";; 499 done
506 *) eshell="/bin/false";; 500
507 esac 501 if [[ ${shell} == "/dev/null" ]]; then
502 eerror "Unable to identify the shell to use"
503 die "Unable to identify the shell to use"
504 fi
505
506 eshell=${shell}
508 fi 507 fi
509 einfo " - Shell: ${eshell}" 508 einfo " - Shell: ${eshell}"
510 opts="${opts} -s ${eshell}" 509 opts="${opts} -s ${eshell}"
511 510
512 # handle homedir 511 # handle homedir
677 fi 676 fi
678 677
679 # If we need the next available 678 # If we need the next available
680 case ${egid} in 679 case ${egid} in
681 *[!0-9]*) # Non numeric 680 *[!0-9]*) # Non numeric
682 for egid in `jot 898 101`; do 681 for egid in $(seq 101 999); do
683 [ -z "`egetent group ${egid}`" ] && break 682 [ -z "`egetent group ${egid}`" ] && break
684 done 683 done
685 esac 684 esac
686 dscl . create /groups/${egroup} gid ${egid} 685 dscl . create /groups/${egroup} gid ${egid}
687 dscl . create /groups/${egroup} passwd '*' 686 dscl . create /groups/${egroup} passwd '*'
688 elif [[ "${USERLAND}" == "BSD" ]] ; then 687 elif [[ "${USERLAND}" == "BSD" ]] ; then
689 case ${egid} in 688 case ${egid} in
690 *[!0-9]*) # Non numeric 689 *[!0-9]*) # Non numeric
691 for egid in `jot 898 101`; do 690 for egid in $(seq 101 999); do
692 [ -z "`egetent group ${egid}`" ] && break 691 [ -z "`egetent group ${egid}`" ] && break
693 done 692 done
694 esac 693 esac
695 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed" 694 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
696 else 695 else
931############################################################## 930##############################################################
932 931
933 932
934# for internal use only (unpack_pdv and unpack_makeself) 933# for internal use only (unpack_pdv and unpack_makeself)
935find_unpackable_file() { 934find_unpackable_file() {
936 local src="$1" 935 local src=$1
937 if [ -z "${src}" ] 936 if [[ -z ${src} ]] ; then
938 then
939 src="${DISTDIR}/${A}" 937 src=${DISTDIR}/${A}
940 else 938 else
941 if [ -e "${DISTDIR}/${src}" ] 939 if [[ -e ${DISTDIR}/${src} ]] ; then
942 then
943 src="${DISTDIR}/${src}" 940 src=${DISTDIR}/${src}
944 elif [ -e "${PWD}/${src}" ] 941 elif [[ -e ${PWD}/${src} ]] ; then
945 then
946 src="${PWD}/${src}" 942 src=${PWD}/${src}
947 elif [ -e "${src}" ] 943 elif [[ -e ${src} ]] ; then
948 then
949 src="${src}" 944 src=${src}
950 fi
951 fi 945 fi
952 [ ! -e "${src}" ] && die "Could not find requested archive ${src}" 946 fi
947 [[ ! -e ${src} ]] && return 1
953 echo "${src}" 948 echo "${src}"
954} 949}
955 950
956# Unpack those pesky pdv generated files ... 951# Unpack those pesky pdv generated files ...
957# They're self-unpacking programs with the binary package stuffed in 952# They're self-unpacking programs with the binary package stuffed in
972# lseek 967# lseek
973# root@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin 968# root@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin
974# lseek(3, -4, SEEK_END) = 2981250 969# lseek(3, -4, SEEK_END) = 2981250
975# thus we would pass in the value of '4' as the second parameter. 970# thus we would pass in the value of '4' as the second parameter.
976unpack_pdv() { 971unpack_pdv() {
977 local src="`find_unpackable_file $1`" 972 local src=$(find_unpackable_file $1)
978 local sizeoff_t="$2" 973 local sizeoff_t=$2
979 974
975 [[ -z ${src} ]] && die "Could not locate source for '$1'"
980 [ -z "${sizeoff_t}" ] && die "No idea what off_t size was used for this pdv :(" 976 [[ -z ${sizeoff_t} ]] && die "No idea what off_t size was used for this pdv :("
981 977
982 local shrtsrc="`basename ${src}`" 978 local shrtsrc="`basename ${src}`"
983 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 979 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
984 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"` 980 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"`
985 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"` 981 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"`
1051# Usage: unpack_makeself [file to unpack] [offset] [tail|dd] 1047# Usage: unpack_makeself [file to unpack] [offset] [tail|dd]
1052# - If the file is not specified then unpack will utilize ${A}. 1048# - If the file is not specified then unpack will utilize ${A}.
1053# - If the offset is not specified then we will attempt to extract 1049# - If the offset is not specified then we will attempt to extract
1054# the proper offset from the script itself. 1050# the proper offset from the script itself.
1055unpack_makeself() { 1051unpack_makeself() {
1056 local src="$(find_unpackable_file "$1")" 1052 local src=$(find_unpackable_file "$1")
1057 local skip="$2" 1053 local skip=$2
1058 local exe="$3" 1054 local exe=$3
1059 1055
1056 [[ -z ${src} ]] && die "Could not locate source for '$1'"
1057
1060 local shrtsrc="$(basename "${src}")" 1058 local shrtsrc=$(basename "${src}")
1061 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1059 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1062 if [ -z "${skip}" ] 1060 if [ -z "${skip}" ]
1063 then 1061 then
1064 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`" 1062 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`"
1065 local skip=0 1063 local skip=0
1136check_license() { 1134check_license() {
1137 local lic=$1 1135 local lic=$1
1138 if [ -z "${lic}" ] ; then 1136 if [ -z "${lic}" ] ; then
1139 lic="${PORTDIR}/licenses/${LICENSE}" 1137 lic="${PORTDIR}/licenses/${LICENSE}"
1140 else 1138 else
1141 if [ -e "${PORTDIR}/licenses/${src}" ] ; then 1139 if [ -e "${PORTDIR}/licenses/${lic}" ] ; then
1142 lic="${PORTDIR}/licenses/${src}" 1140 lic="${PORTDIR}/licenses/${lic}"
1143 elif [ -e "${PWD}/${src}" ] ; then 1141 elif [ -e "${PWD}/${lic}" ] ; then
1144 lic="${PWD}/${src}" 1142 lic="${PWD}/${lic}"
1145 elif [ -e "${src}" ] ; then 1143 elif [ -e "${lic}" ] ; then
1146 lic="${src}" 1144 lic="${lic}"
1147 fi
1148 fi 1145 fi
1146 fi
1149 [ ! -f "${lic}" ] && die "Could not find requested license ${src}" 1147 [ ! -f "${lic}" ] && die "Could not find requested license ${lic}"
1150 local l="`basename ${lic}`" 1148 local l="`basename ${lic}`"
1151 1149
1152 # here is where we check for the licenses the user already 1150 # here is where we check for the licenses the user already
1153 # accepted ... if we don't find a match, we make the user accept 1151 # accepted ... if we don't find a match, we make the user accept
1154 local shopts=$- 1152 local shopts=$-

Legend:
Removed from v.1.195  
changed lines
  Added in v.1.200

  ViewVC Help
Powered by ViewVC 1.1.20