/[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.132
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.132 2004/12/26 22:23:35 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
1296 einfo "If you do not have the CD, but have the data files" 1296 einfo "If you do not have the CD, but have the data files"
1297 einfo "mounted somewhere on your filesystem, just export" 1297 einfo "mounted somewhere on your filesystem, just export"
1298 einfo "the variable CD_ROOT so that it points to the" 1298 einfo "the variable CD_ROOT so that it points to the"
1299 einfo "directory containing the files." 1299 einfo "directory containing the files."
1300 echo 1300 echo
1301 einfo "For example:"
1302 einfo "export CD_ROOT=/mnt/cdrom"
1303 echo
1301 else 1304 else
1302 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds." 1305 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds."
1303 cdcnt=0 1306 cdcnt=0
1304 while [ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ] ; do 1307 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1305 cdcnt=$((cdcnt + 1)) 1308 cdcnt=$((cdcnt + 1))
1306 var="CDROM_NAME_${cdcnt}" 1309 var="CDROM_NAME_${cdcnt}"
1307 [ ! -z "${!var}" ] && einfo " CD ${cdcnt}: ${!var}" 1310 [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}"
1308 done 1311 done
1309 echo 1312 echo
1310 einfo "If you do not have the CDs, but have the data files" 1313 einfo "If you do not have the CDs, but have the data files"
1311 einfo "mounted somewhere on your filesystem, just export" 1314 einfo "mounted somewhere on your filesystem, just export"
1312 einfo "the following variables so they point to the right place:" 1315 einfo "the following variables so they point to the right place:"
1313 einfon "" 1316 einfon ""
1314 cdcnt=0 1317 cdcnt=0
1315 while [ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ] ; do 1318 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1316 cdcnt=$((cdcnt + 1)) 1319 cdcnt=$((cdcnt + 1))
1317 echo -n " CD_ROOT_${cdcnt}" 1320 echo -n " CD_ROOT_${cdcnt}"
1318 done 1321 done
1319 echo 1322 echo
1320 einfo "Or, if you have all the files in the same place, or" 1323 einfo "Or, if you have all the files in the same place, or"
1321 einfo "you only have one cdrom, you can export CD_ROOT" 1324 einfo "you only have one cdrom, you can export CD_ROOT"
1322 einfo "and that place will be used as the same data source" 1325 einfo "and that place will be used as the same data source"
1323 einfo "for all the CDs." 1326 einfo "for all the CDs."
1324 echo 1327 echo
1328 einfo "For example:"
1329 einfo "export CD_ROOT_1=/mnt/cdrom"
1330 echo
1325 fi 1331 fi
1326 export CDROM_CURRENT_CD=0 1332 export CDROM_CURRENT_CD=0
1327 cdrom_load_next_cd 1333 cdrom_load_next_cd
1328} 1334}
1329 1335
1333# remember, you can only go forward in the cd chain, you can't go back. 1339# remember, you can only go forward in the cd chain, you can't go back.
1334cdrom_load_next_cd() { 1340cdrom_load_next_cd() {
1335 export CDROM_CURRENT_CD=$((CDROM_CURRENT_CD + 1)) 1341 export CDROM_CURRENT_CD=$((CDROM_CURRENT_CD + 1))
1336 local var= 1342 local var=
1337 1343
1338 if [ ! -z "${CD_ROOT}" ] ; then 1344 if [[ ! -z ${CD_ROOT} ]] ; then
1339 einfo "Using same root as before for CD #${CDROM_CURRENT_CD}" 1345 einfo "Using same root as before for CD #${CDROM_CURRENT_CD}"
1340 return 1346 return
1341 fi 1347 fi
1342 1348
1343 unset CDROM_ROOT 1349 unset CDROM_ROOT
1344 var=CDROM_ROOTS_${CDROM_CURRENT_CD} 1350 var=CDROM_ROOTS_${CDROM_CURRENT_CD}
1345 if [ -z "${!var}" ] ; then 1351 if [[ -z ${!var} ]] ; then
1346 var="CDROM_CHECK_${CDROM_CURRENT_CD}" 1352 var="CDROM_CHECK_${CDROM_CURRENT_CD}"
1347 cdrom_locate_file_on_cd ${!var} 1353 cdrom_locate_file_on_cd ${!var}
1348 else 1354 else
1349 export CDROM_ROOT="${!var}" 1355 export CDROM_ROOT=${!var}
1350 fi 1356 fi
1351 1357
1352 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1358 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1353} 1359}
1354 1360
1358# found, then a message asking for the user to insert the cdrom will be 1364# found, then a message asking for the user to insert the cdrom will be
1359# displayed and we'll hang out here until: 1365# displayed and we'll hang out here until:
1360# (1) the file is found on a mounted cdrom 1366# (1) the file is found on a mounted cdrom
1361# (2) the user hits CTRL+C 1367# (2) the user hits CTRL+C
1362cdrom_locate_file_on_cd() { 1368cdrom_locate_file_on_cd() {
1363 while [ -z "${CDROM_ROOT}" ] ; do 1369 while [[ -z ${CDROM_ROOT} ]] ; do
1364 local dir="$(dirname ${@})" 1370 local dir="$(dirname ${@})"
1365 local file="$(basename ${@})" 1371 local file="$(basename ${@})"
1366 local mline="" 1372 local mline=""
1367 local showedmsg=0 1373 local showedmsg=0
1368 1374
1369 for mline in `mount | egrep -e '(iso|cdrom)' | awk '{print $3}'` ; do 1375 for mline in $(mount | egrep -e '(iso|cdrom)' | awk '{print $3}') ; do
1370 [ -d "${mline}/${dir}" ] || continue 1376 [[ -d ${mline}/${dir} ]] || continue
1371 [ ! -z "$(find ${mline}/${dir} -iname ${file} -maxdepth 1)" ] \ 1377 [[ ! -z $(find ${mline}/${dir} -iname ${file} -maxdepth 1) ]] \
1372 && export CDROM_ROOT=${mline} 1378 && export CDROM_ROOT=${mline}
1373 done 1379 done
1374 1380
1375 if [ -z "${CDROM_ROOT}" ] ; then 1381 if [[ -z ${CDROM_ROOT} ]] ; then
1376 echo 1382 echo
1377 if [ ${showedmsg} -eq 0 ] ; then 1383 if [[ ${showedmsg} -eq 0 ]] ; then
1378 if [ ${CDROM_TOTAL_CDS} -eq 1 ] ; then 1384 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1379 if [ -z "${CDROM_NAME}" ] ; then 1385 if [[ -z ${CDROM_NAME} ]] ; then
1380 einfo "Please insert the cdrom for ${PN} now !" 1386 einfo "Please insert the cdrom for ${PN} now !"
1381 else 1387 else
1382 einfo "Please insert the ${CDROM_NAME} cdrom now !" 1388 einfo "Please insert the ${CDROM_NAME} cdrom now !"
1383 fi 1389 fi
1384 else 1390 else
1385 if [ -z "${CDROM_NAME_1}" ] ; then 1391 if [[ -z ${CDROM_NAME_1} ]] ; then
1386 einfo "Please insert cd #${CDROM_CURRENT_CD} for ${PN} now !" 1392 einfo "Please insert cd #${CDROM_CURRENT_CD} for ${PN} now !"
1387 else 1393 else
1388 local var="CDROM_NAME_${CDROM_CURRENT_CD}" 1394 local var="CDROM_NAME_${CDROM_CURRENT_CD}"
1389 einfo "Please insert+mount the ${!var} cdrom now !" 1395 einfo "Please insert+mount the ${!var} cdrom now !"
1390 fi 1396 fi
1528} 1534}
1529 1535
1530# Hack for people to figure out if a package was built with 1536# Hack for people to figure out if a package was built with
1531# certain USE flags 1537# certain USE flags
1532# 1538#
1533# Usage: built_with_use <DEPEND ATOM> <List of USE flags> 1539# Usage: built_with_use [-a|-o] <DEPEND ATOM> <List of USE flags>
1534# ex: built_with_use xchat gtk2 1540# ex: built_with_use xchat gtk2
1541#
1542# Flags: -a all USE flags should be utilized
1543# -o at least one USE flag should be utilized
1544# Note: the default flag is '-a'
1535built_with_use() { 1545built_with_use() {
1546 local opt=$1
1547 [[ ${opt:0:1} = "-" ]] && shift || opt="-a"
1548
1536 local PKG=$(portageq best_version ${ROOT} $1) 1549 local PKG=$(best_version $1)
1550 shift
1551
1537 local USEFILE="${ROOT}/var/db/pkg/${PKG}/USE" 1552 local USEFILE="${ROOT}/var/db/pkg/${PKG}/USE"
1538 [[ ! -e ${USEFILE} ]] && return 1 1553 [[ ! -e ${USEFILE} ]] && return 1
1539 1554
1540 local USE_BUILT=$(<${USEFILE}) 1555 local USE_BUILT=$(<${USEFILE})
1541
1542 shift
1543 while [ $# -gt 0 ] ; do 1556 while [[ $# -gt 0 ]] ; do
1557 if [[ ${opt} = "-o" ]] ; then
1558 has $1 ${USE_BUILT} && return 0
1559 else
1544 has $1 ${USE_BUILT} || return 1 1560 has $1 ${USE_BUILT} || return 1
1561 fi
1545 shift 1562 shift
1546 done 1563 done
1547 return 0 1564 [[ ${opt} = "-a" ]]
1548} 1565}
1549 1566
1550# Many configure scripts wrongly bail when a C++ compiler 1567# Many configure scripts wrongly bail when a C++ compiler
1551# could not be detected. #73450 1568# could not be detected. #73450
1552epunt_cxx() { 1569epunt_cxx() {
1586 elif [ -n "${ABI}" ]; then 1603 elif [ -n "${ABI}" ]; then
1587 abi=${ABI} 1604 abi=${ABI}
1588 elif [ -n "${DEFAULT_ABI}" ]; then 1605 elif [ -n "${DEFAULT_ABI}" ]; then
1589 abi=${DEFAULT_ABI} 1606 abi=${DEFAULT_ABI}
1590 else 1607 else
1591 return "" 1608 return 1
1592 fi 1609 fi
1593 eval echo \${${flag}_${abi}} 1610 eval echo \${${flag}_${abi}}
1594} 1611}
1595 1612
1596get_abi_CFLAGS() { get_abi_var CFLAGS $1; } 1613get_abi_CFLAGS() { get_abi_var CFLAGS $1; }

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

  ViewVC Help
Powered by ViewVC 1.1.20