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

Diff of /eclass/eutils.eclass

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

Revision 1.214 Revision 1.218
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.214 2005/10/26 00:39:12 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.218 2005/11/22 11:15:34 flameeyes 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.
432 [[ ${action} == "user" ]] && opts="-u" || opts="-g" 432 [[ ${action} == "user" ]] && opts="-u" || opts="-g"
433 fi 433 fi
434 434
435 pw show ${action} ${opts} "$2" -q 435 pw show ${action} ${opts} "$2" -q
436 ;; 436 ;;
437 *-netbsd*) 437 *-netbsd*|*-openbsd*)
438 grep "$2:\*:" /etc/$1 438 grep "$2:\*:" /etc/$1
439 ;; 439 ;;
440 *) 440 *)
441 type -p nscd >& /dev/null && nscd -i "$1" 441 type -p nscd >& /dev/null && nscd -i "$1"
442 getent "$1" "$2" 442 getent "$1" "$2"
600 else 600 else
601 einfo " - Extra: $@" 601 einfo " - Extra: $@"
602 useradd ${opts} ${euser} "$@" || die "enewuser failed" 602 useradd ${opts} ${euser} "$@" || die "enewuser failed"
603 fi 603 fi
604 ;; 604 ;;
605
606 *-openbsd*)
607 if [[ -z $@ ]] ; then
608 useradd -u ${euid} -s ${eshell} \
609 -d ${ehome} -c "Added by portage for ${PN}" \
610 -g ${egroups} ${euser} || die "enewuser failed"
611 else
612 einfo " - Extra: $@"
613 useradd -u ${euid} -s ${eshell} \
614 -d ${ehome} -c "Added by portage for ${PN}" \
615 -g ${egroups} ${euser} "$@" || die "enewuser failed"
616 fi
617 ;;
618
605 *) 619 *)
606 if [[ -z $@ ]] ; then 620 if [[ -z $@ ]] ; then
607 useradd ${opts} ${euser} \ 621 useradd ${opts} ${euser} \
608 -c "added by portage for ${PN}" \ 622 -c "added by portage for ${PN}" \
609 || die "enewuser failed" 623 || die "enewuser failed"
848 type="Network;${type}" 862 type="Network;${type}"
849 ;; 863 ;;
850 864
851 sci) 865 sci)
852 case ${catmin} in 866 case ${catmin} in
853 astro*) type=Astronomoy;; 867 astro*) type=Astronomy;;
854 bio*) type=Biology;; 868 bio*) type=Biology;;
855 calc*) type=Calculator;; 869 calc*) type=Calculator;;
856 chem*) type=Chemistry;; 870 chem*) type=Chemistry;;
857 geo*) type=Geology;; 871 geo*) type=Geology;;
858 math*) type=Math;; 872 math*) type=Math;;
1084# Usage: unpack_makeself [file to unpack] [offset] [tail|dd] 1098# Usage: unpack_makeself [file to unpack] [offset] [tail|dd]
1085# - If the file is not specified then unpack will utilize ${A}. 1099# - If the file is not specified then unpack will utilize ${A}.
1086# - If the offset is not specified then we will attempt to extract 1100# - If the offset is not specified then we will attempt to extract
1087# the proper offset from the script itself. 1101# the proper offset from the script itself.
1088unpack_makeself() { 1102unpack_makeself() {
1103 local src_input=${1:-${A}}
1089 local src=$(find_unpackable_file "$1") 1104 local src=$(find_unpackable_file "${src_input}")
1090 local skip=$2 1105 local skip=$2
1091 local exe=$3 1106 local exe=$3
1092 1107
1093 [[ -z ${src} ]] && die "Could not locate source for '$1'" 1108 [[ -z ${src} ]] && die "Could not locate source for '${src_input}'"
1094 1109
1095 local shrtsrc=$(basename "${src}") 1110 local shrtsrc=$(basename "${src}")
1096 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1111 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1097 if [[ -z ${skip} ]] ; then 1112 if [[ -z ${skip} ]] ; then
1098 local ver=$(grep -a '#.*Makeself' "${src}" | awk '{print $NF}') 1113 local ver=$(grep -a '#.*Makeself' "${src}" | awk '{print $NF}')
1252 export CDROM_TOTAL_CDS=${cdcnt} 1267 export CDROM_TOTAL_CDS=${cdcnt}
1253 export CDROM_CURRENT_CD=1 1268 export CDROM_CURRENT_CD=1
1254 1269
1255 # now we see if the user gave use CD_ROOT ... 1270 # now we see if the user gave use CD_ROOT ...
1256 # if they did, let's just believe them that it's correct 1271 # if they did, let's just believe them that it's correct
1257 if [[ ! -z ${CD_ROOT} ]] ; then
1258 export CDROM_ROOT=${CD_ROOT}
1259 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1260 return
1261 fi
1262 # do the same for CD_ROOT_X
1263 if [[ ! -z ${CD_ROOT_1} ]] ; then 1272 if [[ -n ${CD_ROOT}${CD_ROOT_1} ]] ; then
1264 local var= 1273 local var=
1265 cdcnt=0 1274 cdcnt=0
1266 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do 1275 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1267 ((++cdcnt)) 1276 ((++cdcnt))
1268 var="CD_ROOT_${cdcnt}" 1277 var="CD_ROOT_${cdcnt}"
1278 [[ -z ${!var} ]] && var="CD_ROOT"
1269 if [[ -z ${!var} ]] ; then 1279 if [[ -z ${!var} ]] ; then
1270 eerror "You must either use just the CD_ROOT" 1280 eerror "You must either use just the CD_ROOT"
1271 eerror "or specify ALL the CD_ROOT_X variables." 1281 eerror "or specify ALL the CD_ROOT_X variables."
1272 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables." 1282 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables."
1273 die "could not locate CD_ROOT_${cdcnt}" 1283 die "could not locate CD_ROOT_${cdcnt}"
1274 fi 1284 fi
1275 export CDROM_ROOTS_${cdcnt}="${!var}"
1276 done 1285 done
1277 export CDROM_ROOT=${CDROM_ROOTS_1} 1286 export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}}
1278 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1287 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1288 export CDROM_SET=-1
1289 for f in ${CDROM_CHECK_1//:/ } ; do
1290 ((++CDROM_SET))
1291 [[ -e ${CD_ROOT}/${f} ]] && break
1292 done
1293 export CDROM_MATCH=${f}
1279 return 1294 return
1280 fi 1295 fi
1281 1296
1297 # User didn't help us out so lets make sure they know they can
1298 # simplify the whole process ...
1282 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then 1299 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1283 einfon "This ebuild will need the " 1300 einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}"
1284 if [[ -z ${CDROM_NAME} ]] ; then
1285 echo "cdrom for ${PN}."
1286 else
1287 echo "${CDROM_NAME}."
1288 fi
1289 echo 1301 echo
1290 einfo "If you do not have the CD, but have the data files" 1302 einfo "If you do not have the CD, but have the data files"
1291 einfo "mounted somewhere on your filesystem, just export" 1303 einfo "mounted somewhere on your filesystem, just export"
1292 einfo "the variable CD_ROOT so that it points to the" 1304 einfo "the variable CD_ROOT so that it points to the"
1293 einfo "directory containing the files." 1305 einfo "directory containing the files."
1321 echo 1333 echo
1322 einfo "For example:" 1334 einfo "For example:"
1323 einfo "export CD_ROOT_1=/mnt/cdrom" 1335 einfo "export CD_ROOT_1=/mnt/cdrom"
1324 echo 1336 echo
1325 fi 1337 fi
1338
1326 export CDROM_SET="" 1339 export CDROM_SET=""
1327 export CDROM_CURRENT_CD=0 1340 export CDROM_CURRENT_CD=0
1328 cdrom_load_next_cd 1341 cdrom_load_next_cd
1329} 1342}
1330 1343
1331# this is only used when you need access to more than one cd. 1344# this is only used when you need access to more than one cd.
1332# when you have finished using the first cd, just call this function. 1345# when you have finished using the first cd, just call this function.
1333# when it returns, CDROM_ROOT will be pointing to the second cd. 1346# when it returns, CDROM_ROOT will be pointing to the second cd.
1334# remember, you can only go forward in the cd chain, you can't go back. 1347# remember, you can only go forward in the cd chain, you can't go back.
1335cdrom_load_next_cd() { 1348cdrom_load_next_cd() {
1336 export CDROM_CURRENT_CD=$((CDROM_CURRENT_CD + 1))
1337 local var= 1349 local var
1338 1350 ((++CDROM_CURRENT_CD))
1339 if [[ ! -z ${CD_ROOT} ]] ; then
1340 einfo "Using same root as before for CD #${CDROM_CURRENT_CD}"
1341 return
1342 fi
1343 1351
1344 unset CDROM_ROOT 1352 unset CDROM_ROOT
1345 var=CDROM_ROOTS_${CDROM_CURRENT_CD} 1353 var=CD_ROOT_${CDROM_CURRENT_CD}
1354 [[ -z ${!var} ]] && var="CD_ROOT"
1346 if [[ -z ${!var} ]] ; then 1355 if [[ -z ${!var} ]] ; then
1347 var="CDROM_CHECK_${CDROM_CURRENT_CD}" 1356 var="CDROM_CHECK_${CDROM_CURRENT_CD}"
1348 cdrom_locate_file_on_cd ${!var} 1357 _cdrom_locate_file_on_cd ${!var}
1349 else 1358 else
1350 export CDROM_ROOT=${!var} 1359 export CDROM_ROOT=${!var}
1351 fi 1360 fi
1352 1361
1353 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1362 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1358# all it does is try to locate a give file on a cd ... if the cd isn't 1367# all it does is try to locate a give file on a cd ... if the cd isn't
1359# found, then a message asking for the user to insert the cdrom will be 1368# found, then a message asking for the user to insert the cdrom will be
1360# displayed and we'll hang out here until: 1369# displayed and we'll hang out here until:
1361# (1) the file is found on a mounted cdrom 1370# (1) the file is found on a mounted cdrom
1362# (2) the user hits CTRL+C 1371# (2) the user hits CTRL+C
1363cdrom_locate_file_on_cd() { 1372_cdrom_locate_file_on_cd() {
1364 local mline="" 1373 local mline=""
1365 local showedmsg=0 1374 local showedmsg=0
1366 1375
1367 while [[ -z ${CDROM_ROOT} ]] ; do 1376 while [[ -z ${CDROM_ROOT} ]] ; do
1368 local i=0 1377 local i=0

Legend:
Removed from v.1.214  
changed lines
  Added in v.1.218

  ViewVC Help
Powered by ViewVC 1.1.20