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

Diff of /eclass/eutils.eclass

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

Revision 1.128 Revision 1.131
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.128 2004/12/23 09:20:45 eradicator Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.131 2004/12/26 07:09:59 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.
1258 export CDROM_TOTAL_CDS=${cdcnt} 1258 export CDROM_TOTAL_CDS=${cdcnt}
1259 export CDROM_CURRENT_CD=1 1259 export CDROM_CURRENT_CD=1
1260 1260
1261 # now we see if the user gave use CD_ROOT ... 1261 # now we see if the user gave use CD_ROOT ...
1262 # if they did, let's just believe them that it's correct 1262 # if they did, let's just believe them that it's correct
1263 if [ ! -z "${CD_ROOT}" ] ; then 1263 if [[ ! -z ${CD_ROOT} ]] ; then
1264 export CDROM_ROOT="${CD_ROOT}" 1264 export CDROM_ROOT=${CD_ROOT}
1265 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1265 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1266 return 1266 return
1267 fi 1267 fi
1268 # do the same for CD_ROOT_X 1268 # do the same for CD_ROOT_X
1269 if [ ! -z "${CD_ROOT_1}" ] ; then 1269 if [[ ! -z ${CD_ROOT_1} ]] ; then
1270 local var= 1270 local var=
1271 cdcnt=0 1271 cdcnt=0
1272 while [ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ] ; do 1272 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1273 cdcnt=$((cdcnt + 1)) 1273 cdcnt=$((cdcnt + 1))
1274 var="CD_ROOT_${cdcnt}" 1274 var="CD_ROOT_${cdcnt}"
1275 if [ -z "${!var}" ] ; then 1275 if [[ -z ${!var} ]] ; then
1276 eerror "You must either use just the CD_ROOT" 1276 eerror "You must either use just the CD_ROOT"
1277 eerror "or specify ALL the CD_ROOT_X variables." 1277 eerror "or specify ALL the CD_ROOT_X variables."
1278 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables." 1278 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables."
1279 die "could not locate CD_ROOT_${cdcnt}" 1279 die "could not locate CD_ROOT_${cdcnt}"
1280 fi 1280 fi
1283 export CDROM_ROOT=${CDROM_ROOTS_1} 1283 export CDROM_ROOT=${CDROM_ROOTS_1}
1284 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1284 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1285 return 1285 return
1286 fi 1286 fi
1287 1287
1288 if [ ${CDROM_TOTAL_CDS} -eq 1 ] ; then 1288 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1289 einfon "This ebuild will need the " 1289 einfon "This ebuild will need the "
1290 if [ -z "${CDROM_NAME}" ] ; then 1290 if [[ -z ${CDROM_NAME} ]] ; then
1291 echo "cdrom for ${PN}." 1291 echo "cdrom for ${PN}."
1292 else 1292 else
1293 echo "${CDROM_NAME}." 1293 echo "${CDROM_NAME}."
1294 fi 1294 fi
1295 echo 1295 echo
1299 einfo "directory containing the files." 1299 einfo "directory containing the files."
1300 echo 1300 echo
1301 else 1301 else
1302 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds." 1302 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds."
1303 cdcnt=0 1303 cdcnt=0
1304 while [ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ] ; do 1304 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1305 cdcnt=$((cdcnt + 1)) 1305 cdcnt=$((cdcnt + 1))
1306 var="CDROM_NAME_${cdcnt}" 1306 var="CDROM_NAME_${cdcnt}"
1307 [ ! -z "${!var}" ] && einfo " CD ${cdcnt}: ${!var}" 1307 [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}"
1308 done 1308 done
1309 echo 1309 echo
1310 einfo "If you do not have the CDs, but have the data files" 1310 einfo "If you do not have the CDs, but have the data files"
1311 einfo "mounted somewhere on your filesystem, just export" 1311 einfo "mounted somewhere on your filesystem, just export"
1312 einfo "the following variables so they point to the right place:" 1312 einfo "the following variables so they point to the right place:"
1313 einfon "" 1313 einfon ""
1314 cdcnt=0 1314 cdcnt=0
1315 while [ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ] ; do 1315 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1316 cdcnt=$((cdcnt + 1)) 1316 cdcnt=$((cdcnt + 1))
1317 echo -n " CD_ROOT_${cdcnt}" 1317 echo -n " CD_ROOT_${cdcnt}"
1318 done 1318 done
1319 echo 1319 echo
1320 einfo "Or, if you have all the files in the same place, or" 1320 einfo "Or, if you have all the files in the same place, or"
1333# remember, you can only go forward in the cd chain, you can't go back. 1333# remember, you can only go forward in the cd chain, you can't go back.
1334cdrom_load_next_cd() { 1334cdrom_load_next_cd() {
1335 export CDROM_CURRENT_CD=$((CDROM_CURRENT_CD + 1)) 1335 export CDROM_CURRENT_CD=$((CDROM_CURRENT_CD + 1))
1336 local var= 1336 local var=
1337 1337
1338 if [ ! -z "${CD_ROOT}" ] ; then 1338 if [[ ! -z ${CD_ROOT} ]] ; then
1339 einfo "Using same root as before for CD #${CDROM_CURRENT_CD}" 1339 einfo "Using same root as before for CD #${CDROM_CURRENT_CD}"
1340 return 1340 return
1341 fi 1341 fi
1342 1342
1343 unset CDROM_ROOT 1343 unset CDROM_ROOT
1344 var=CDROM_ROOTS_${CDROM_CURRENT_CD} 1344 var=CDROM_ROOTS_${CDROM_CURRENT_CD}
1345 if [ -z "${!var}" ] ; then 1345 if [[ -z ${!var} ]] ; then
1346 var="CDROM_CHECK_${CDROM_CURRENT_CD}" 1346 var="CDROM_CHECK_${CDROM_CURRENT_CD}"
1347 cdrom_locate_file_on_cd ${!var} 1347 cdrom_locate_file_on_cd ${!var}
1348 else 1348 else
1349 export CDROM_ROOT="${!var}" 1349 export CDROM_ROOT=${!var}
1350 fi 1350 fi
1351 1351
1352 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1352 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1353} 1353}
1354 1354
1358# found, then a message asking for the user to insert the cdrom will be 1358# found, then a message asking for the user to insert the cdrom will be
1359# displayed and we'll hang out here until: 1359# displayed and we'll hang out here until:
1360# (1) the file is found on a mounted cdrom 1360# (1) the file is found on a mounted cdrom
1361# (2) the user hits CTRL+C 1361# (2) the user hits CTRL+C
1362cdrom_locate_file_on_cd() { 1362cdrom_locate_file_on_cd() {
1363 while [ -z "${CDROM_ROOT}" ] ; do 1363 while [[ -z ${CDROM_ROOT} ]] ; do
1364 local dir="$(dirname ${@})" 1364 local dir="$(dirname ${@})"
1365 local file="$(basename ${@})" 1365 local file="$(basename ${@})"
1366 local mline="" 1366 local mline=""
1367 local showedmsg=0 1367 local showedmsg=0
1368 1368
1369 for mline in `mount | egrep -e '(iso|cdrom)' | awk '{print $3}'` ; do 1369 for mline in $(mount | egrep -e '(iso|cdrom)' | awk '{print $3}') ; do
1370 [ -d "${mline}/${dir}" ] || continue 1370 [[ -d ${mline}/${dir} ]] || continue
1371 [ ! -z "$(find ${mline}/${dir} -iname ${file} -maxdepth 1)" ] \ 1371 [[ ! -z $(find ${mline}/${dir} -iname ${file} -maxdepth 1) ]] \
1372 && export CDROM_ROOT=${mline} 1372 && export CDROM_ROOT=${mline}
1373 done 1373 done
1374 1374
1375 if [ -z "${CDROM_ROOT}" ] ; then 1375 if [[ -z ${CDROM_ROOT} ]] ; then
1376 echo 1376 echo
1377 if [ ${showedmsg} -eq 0 ] ; then 1377 if [[ ${showedmsg} -eq 0 ]] ; then
1378 if [ ${CDROM_TOTAL_CDS} -eq 1 ] ; then 1378 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1379 if [ -z "${CDROM_NAME}" ] ; then 1379 if [[ -z ${CDROM_NAME} ]] ; then
1380 einfo "Please insert the cdrom for ${PN} now !" 1380 einfo "Please insert the cdrom for ${PN} now !"
1381 else 1381 else
1382 einfo "Please insert the ${CDROM_NAME} cdrom now !" 1382 einfo "Please insert the ${CDROM_NAME} cdrom now !"
1383 fi 1383 fi
1384 else 1384 else
1385 if [ -z "${CDROM_NAME_1}" ] ; then 1385 if [[ -z ${CDROM_NAME_1} ]] ; then
1386 einfo "Please insert cd #${CDROM_CURRENT_CD} for ${PN} now !" 1386 einfo "Please insert cd #${CDROM_CURRENT_CD} for ${PN} now !"
1387 else 1387 else
1388 local var="CDROM_NAME_${CDROM_CURRENT_CD}" 1388 local var="CDROM_NAME_${CDROM_CURRENT_CD}"
1389 einfo "Please insert+mount the ${!var} cdrom now !" 1389 einfo "Please insert+mount the ${!var} cdrom now !"
1390 fi 1390 fi
1528} 1528}
1529 1529
1530# Hack for people to figure out if a package was built with 1530# Hack for people to figure out if a package was built with
1531# certain USE flags 1531# certain USE flags
1532# 1532#
1533# Usage: built_with_use <DEPEND ATOM> <List of USE flags> 1533# Usage: built_with_use [-a|-o] <DEPEND ATOM> <List of USE flags>
1534# ex: built_with_use xchat gtk2 1534# ex: built_with_use xchat gtk2
1535#
1536# Flags: -a all USE flags should be utilized
1537# -o at least one USE flag should be utilized
1538# Note: the default flag is '-a'
1535built_with_use() { 1539built_with_use() {
1540 local opt=$1
1541 [[ ${opt:0:1} = "-" ]] && shift || opt="-a"
1542
1536 local PKG=$(portageq best_version ${ROOT} $1) 1543 local PKG=$(best_version $1)
1544 shift
1545
1537 local USEFILE="${ROOT}/var/db/pkg/${PKG}/USE" 1546 local USEFILE="${ROOT}/var/db/pkg/${PKG}/USE"
1538 [[ ! -e ${USEFILE} ]] && return 1 1547 [[ ! -e ${USEFILE} ]] && return 1
1539 1548
1540 local USE_BUILT=$(<${USEFILE}) 1549 local USE_BUILT=$(<${USEFILE})
1541
1542 shift
1543 while [ $# -gt 0 ] ; do 1550 while [[ $# -gt 0 ]] ; do
1551 if [[ ${opt} = "-o" ]] ; then
1552 has $1 ${USE_BUILT} && return 0
1553 else
1544 has $1 ${USE_BUILT} || return 1 1554 has $1 ${USE_BUILT} || return 1
1555 fi
1545 shift 1556 shift
1546 done 1557 done
1547 return 0 1558 [[ ${opt} = "-a" ]]
1548} 1559}
1549 1560
1550# Many configure scripts wrongly bail when a C++ compiler 1561# Many configure scripts wrongly bail when a C++ compiler
1551# could not be detected. #73450 1562# could not be detected. #73450
1552epunt_cxx() { 1563epunt_cxx() {
1586 elif [ -n "${ABI}" ]; then 1597 elif [ -n "${ABI}" ]; then
1587 abi=${ABI} 1598 abi=${ABI}
1588 elif [ -n "${DEFAULT_ABI}" ]; then 1599 elif [ -n "${DEFAULT_ABI}" ]; then
1589 abi=${DEFAULT_ABI} 1600 abi=${DEFAULT_ABI}
1590 else 1601 else
1591 return "" 1602 return 1
1592 fi 1603 fi
1593 eval echo \${${flag}_${abi}} 1604 eval echo \${${flag}_${abi}}
1594} 1605}
1595 1606
1596get_abi_CFLAGS() { get_abi_var CFLAGS $1; } 1607get_abi_CFLAGS() { get_abi_var CFLAGS $1; }

Legend:
Removed from v.1.128  
changed lines
  Added in v.1.131

  ViewVC Help
Powered by ViewVC 1.1.20