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

Diff of /eclass/eutils.eclass

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

Revision 1.194 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.194 2005/08/09 22:40:39 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"
172 local STDERR_TARGET="${T}/$$.out" 172 local STDERR_TARGET="${T}/$$.out"
173 local PATCH_TARGET="${T}/$$.patch" 173 local PATCH_TARGET="${T}/$$.patch"
174 local PATCH_SUFFIX="" 174 local PATCH_SUFFIX=""
175 local SINGLE_PATCH="no" 175 local SINGLE_PATCH="no"
176 local x="" 176 local x=""
177
178 unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402
177 179
178 if [ "$#" -gt 1 ] 180 if [ "$#" -gt 1 ]
179 then 181 then
180 local m="" 182 local m=""
181 for m in "$@" ; do 183 for m in "$@" ; do
475 fi 477 fi
476 else 478 else
477 euid="next" 479 euid="next"
478 fi 480 fi
479 if [[ ${euid} == "next" ]] ; then 481 if [[ ${euid} == "next" ]] ; then
480 local pwrange 482 for euid in $(seq 101 999) ; do
481 if [[ ${USERLAND} == "BSD" ]] ; then
482 pwrange=$(jot 898 101)
483 else
484 pwrange=$(seq 101 999)
485 fi
486 for euid in ${pwrange} ; do
487 [[ -z $(egetent passwd ${euid}) ]] && break 483 [[ -z $(egetent passwd ${euid}) ]] && break
488 done 484 done
489 fi 485 fi
490 opts="${opts} -u ${euid}" 486 opts="${opts} -u ${euid}"
491 einfo " - Userid: ${euid}" 487 einfo " - Userid: ${euid}"
496 if [[ ! -e ${eshell} ]] ; then 492 if [[ ! -e ${eshell} ]] ; then
497 eerror "A shell was specified but it does not exist !" 493 eerror "A shell was specified but it does not exist !"
498 die "${eshell} does not exist" 494 die "${eshell} does not exist"
499 fi 495 fi
500 else 496 else
501 case ${USERLAND} in 497 for shell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null; do
502 Darwin) eshell="/usr/bin/false";; 498 [[ -x ${ROOT}${shell} ]] && break;
503 BSD) eshell="/usr/sbin/nologin";; 499 done
504 *) eshell="/bin/false";; 500
505 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}
506 fi 507 fi
507 einfo " - Shell: ${eshell}" 508 einfo " - Shell: ${eshell}"
508 opts="${opts} -s ${eshell}" 509 opts="${opts} -s ${eshell}"
509 510
510 # handle homedir 511 # handle homedir
675 fi 676 fi
676 677
677 # If we need the next available 678 # If we need the next available
678 case ${egid} in 679 case ${egid} in
679 *[!0-9]*) # Non numeric 680 *[!0-9]*) # Non numeric
680 for egid in `jot 898 101`; do 681 for egid in $(seq 101 999); do
681 [ -z "`egetent group ${egid}`" ] && break 682 [ -z "`egetent group ${egid}`" ] && break
682 done 683 done
683 esac 684 esac
684 dscl . create /groups/${egroup} gid ${egid} 685 dscl . create /groups/${egroup} gid ${egid}
685 dscl . create /groups/${egroup} passwd '*' 686 dscl . create /groups/${egroup} passwd '*'
686 elif [[ "${USERLAND}" == "BSD" ]] ; then 687 elif [[ "${USERLAND}" == "BSD" ]] ; then
687 case ${egid} in 688 case ${egid} in
688 *[!0-9]*) # Non numeric 689 *[!0-9]*) # Non numeric
689 for egid in `jot 898 101`; do 690 for egid in $(seq 101 999); do
690 [ -z "`egetent group ${egid}`" ] && break 691 [ -z "`egetent group ${egid}`" ] && break
691 done 692 done
692 esac 693 esac
693 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed" 694 pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
694 else 695 else
929############################################################## 930##############################################################
930 931
931 932
932# for internal use only (unpack_pdv and unpack_makeself) 933# for internal use only (unpack_pdv and unpack_makeself)
933find_unpackable_file() { 934find_unpackable_file() {
934 local src="$1" 935 local src=$1
935 if [ -z "${src}" ] 936 if [[ -z ${src} ]] ; then
936 then
937 src="${DISTDIR}/${A}" 937 src=${DISTDIR}/${A}
938 else 938 else
939 if [ -e "${DISTDIR}/${src}" ] 939 if [[ -e ${DISTDIR}/${src} ]] ; then
940 then
941 src="${DISTDIR}/${src}" 940 src=${DISTDIR}/${src}
942 elif [ -e "${PWD}/${src}" ] 941 elif [[ -e ${PWD}/${src} ]] ; then
943 then
944 src="${PWD}/${src}" 942 src=${PWD}/${src}
945 elif [ -e "${src}" ] 943 elif [[ -e ${src} ]] ; then
946 then
947 src="${src}" 944 src=${src}
948 fi
949 fi 945 fi
950 [ ! -e "${src}" ] && die "Could not find requested archive ${src}" 946 fi
947 [[ ! -e ${src} ]] && return 1
951 echo "${src}" 948 echo "${src}"
952} 949}
953 950
954# Unpack those pesky pdv generated files ... 951# Unpack those pesky pdv generated files ...
955# They're self-unpacking programs with the binary package stuffed in 952# They're self-unpacking programs with the binary package stuffed in
970# lseek 967# lseek
971# root@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin 968# root@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin
972# lseek(3, -4, SEEK_END) = 2981250 969# lseek(3, -4, SEEK_END) = 2981250
973# 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.
974unpack_pdv() { 971unpack_pdv() {
975 local src="`find_unpackable_file $1`" 972 local src=$(find_unpackable_file $1)
976 local sizeoff_t="$2" 973 local sizeoff_t=$2
977 974
975 [[ -z ${src} ]] && die "Could not locate source for '$1'"
978 [ -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 :("
979 977
980 local shrtsrc="`basename ${src}`" 978 local shrtsrc="`basename ${src}`"
981 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 979 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
982 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"` 980 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"`
983 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\"`
1049# Usage: unpack_makeself [file to unpack] [offset] [tail|dd] 1047# Usage: unpack_makeself [file to unpack] [offset] [tail|dd]
1050# - If the file is not specified then unpack will utilize ${A}. 1048# - If the file is not specified then unpack will utilize ${A}.
1051# - 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
1052# the proper offset from the script itself. 1050# the proper offset from the script itself.
1053unpack_makeself() { 1051unpack_makeself() {
1054 local src="$(find_unpackable_file "$1")" 1052 local src=$(find_unpackable_file "$1")
1055 local skip="$2" 1053 local skip=$2
1056 local exe="$3" 1054 local exe=$3
1057 1055
1056 [[ -z ${src} ]] && die "Could not locate source for '$1'"
1057
1058 local shrtsrc="$(basename "${src}")" 1058 local shrtsrc=$(basename "${src}")
1059 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1059 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1060 if [ -z "${skip}" ] 1060 if [ -z "${skip}" ]
1061 then 1061 then
1062 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`" 1062 local ver="`grep -a '#.*Makeself' ${src} | awk '{print $NF}'`"
1063 local skip=0 1063 local skip=0
1134check_license() { 1134check_license() {
1135 local lic=$1 1135 local lic=$1
1136 if [ -z "${lic}" ] ; then 1136 if [ -z "${lic}" ] ; then
1137 lic="${PORTDIR}/licenses/${LICENSE}" 1137 lic="${PORTDIR}/licenses/${LICENSE}"
1138 else 1138 else
1139 if [ -e "${PORTDIR}/licenses/${src}" ] ; then 1139 if [ -e "${PORTDIR}/licenses/${lic}" ] ; then
1140 lic="${PORTDIR}/licenses/${src}" 1140 lic="${PORTDIR}/licenses/${lic}"
1141 elif [ -e "${PWD}/${src}" ] ; then 1141 elif [ -e "${PWD}/${lic}" ] ; then
1142 lic="${PWD}/${src}" 1142 lic="${PWD}/${lic}"
1143 elif [ -e "${src}" ] ; then 1143 elif [ -e "${lic}" ] ; then
1144 lic="${src}" 1144 lic="${lic}"
1145 fi
1146 fi 1145 fi
1146 fi
1147 [ ! -f "${lic}" ] && die "Could not find requested license ${src}" 1147 [ ! -f "${lic}" ] && die "Could not find requested license ${lic}"
1148 local l="`basename ${lic}`" 1148 local l="`basename ${lic}`"
1149 1149
1150 # here is where we check for the licenses the user already 1150 # here is where we check for the licenses the user already
1151 # 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
1152 local shopts=$- 1152 local shopts=$-

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

  ViewVC Help
Powered by ViewVC 1.1.20