/[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.134
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.134 2004/12/30 21:48:23 seemant 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.
906 cp "${f}" ${T}/edos2unix 906 cp "${f}" ${T}/edos2unix
907 sed 's/\r$//' ${T}/edos2unix > "${f}" 907 sed 's/\r$//' ${T}/edos2unix > "${f}"
908 done 908 done
909} 909}
910 910
911
912##############################################################
913# START: Handle .desktop files and menu entries #
914# maybe this should be separated into a new eclass some time #
915# lanius@gentoo.org #
916##############################################################
917
911# Make a desktop file ! 918# Make a desktop file !
912# Great for making those icons in kde/gnome startmenu ! 919# Great for making those icons in kde/gnome startmenu !
913# Amaze your friends ! Get the women ! Join today ! 920# Amaze your friends ! Get the women ! Join today !
914# 921#
915# make_desktop_entry(<binary>, [name], [icon], [type], [path]) 922# make_desktop_entry(<binary>, [name], [icon], [type], [path])
968 insinto /usr/share/applications 975 insinto /usr/share/applications
969 doins "${desktop}" 976 doins "${desktop}"
970 977
971 return 0 978 return 0
972} 979}
980
981# Make a GDM/KDM Session file
982#
983# make_desktop_entry(<title>, <command>)
984# title: File to execute to start the Window Manager
985# command: Name of the Window Manager
986
987make_session_desktop() {
988
989 [ -z "$1" ] && eerror "make_session_desktop: You must specify the title" && return 1
990 [ -z "$2" ] && eerror "make_session_desktop: You must specify the command" && return 1
991
992 local title="${1}"
993 local command="${2}"
994 local desktop="${T}/${wm}.desktop"
995
996echo "[Desktop Entry]
997Encoding=UTF-8
998Name=${title}
999Comment=This session logs you into ${title}
1000Exec=${command}
1001TryExec=${command}
1002Type=Application" > "${desktop}"
1003
1004 insinto /usr/share/xsessions
1005 doins "${desktop}"
1006
1007 return 0
1008}
1009
1010domenu() {
1011 local i
1012 local j
1013 insinto /usr/share/applications
1014 for i in ${@}
1015 do
1016 if [ -f "${i}" ];
1017 then
1018 doins ${i}
1019 elif [ -d "${i}" ];
1020 then
1021 for j in ${i}/*.desktop
1022 do
1023 doins ${j}
1024 done
1025 fi
1026 done
1027}
1028
1029doicon() {
1030 local i
1031 local j
1032 insinto /usr/share/pixmaps
1033 for i in ${@}
1034 do
1035 if [ -f "${i}" ];
1036 then
1037 doins ${i}
1038 elif [ -d "${i}" ];
1039 then
1040 for j in ${i}/*.png
1041 do
1042 doins ${j}
1043 done
1044 fi
1045 done
1046}
1047
1048##############################################################
1049# END: Handle .desktop files and menu entries #
1050##############################################################
1051
973 1052
974# for internal use only (unpack_pdv and unpack_makeself) 1053# for internal use only (unpack_pdv and unpack_makeself)
975find_unpackable_file() { 1054find_unpackable_file() {
976 local src="$1" 1055 local src="$1"
977 if [ -z "${src}" ] 1056 if [ -z "${src}" ]
1258 export CDROM_TOTAL_CDS=${cdcnt} 1337 export CDROM_TOTAL_CDS=${cdcnt}
1259 export CDROM_CURRENT_CD=1 1338 export CDROM_CURRENT_CD=1
1260 1339
1261 # now we see if the user gave use CD_ROOT ... 1340 # now we see if the user gave use CD_ROOT ...
1262 # if they did, let's just believe them that it's correct 1341 # if they did, let's just believe them that it's correct
1263 if [ ! -z "${CD_ROOT}" ] ; then 1342 if [[ ! -z ${CD_ROOT} ]] ; then
1264 export CDROM_ROOT="${CD_ROOT}" 1343 export CDROM_ROOT=${CD_ROOT}
1265 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1344 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1266 return 1345 return
1267 fi 1346 fi
1268 # do the same for CD_ROOT_X 1347 # do the same for CD_ROOT_X
1269 if [ ! -z "${CD_ROOT_1}" ] ; then 1348 if [[ ! -z ${CD_ROOT_1} ]] ; then
1270 local var= 1349 local var=
1271 cdcnt=0 1350 cdcnt=0
1272 while [ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ] ; do 1351 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1273 cdcnt=$((cdcnt + 1)) 1352 cdcnt=$((cdcnt + 1))
1274 var="CD_ROOT_${cdcnt}" 1353 var="CD_ROOT_${cdcnt}"
1275 if [ -z "${!var}" ] ; then 1354 if [[ -z ${!var} ]] ; then
1276 eerror "You must either use just the CD_ROOT" 1355 eerror "You must either use just the CD_ROOT"
1277 eerror "or specify ALL the CD_ROOT_X variables." 1356 eerror "or specify ALL the CD_ROOT_X variables."
1278 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables." 1357 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables."
1279 die "could not locate CD_ROOT_${cdcnt}" 1358 die "could not locate CD_ROOT_${cdcnt}"
1280 fi 1359 fi
1283 export CDROM_ROOT=${CDROM_ROOTS_1} 1362 export CDROM_ROOT=${CDROM_ROOTS_1}
1284 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1363 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1285 return 1364 return
1286 fi 1365 fi
1287 1366
1288 if [ ${CDROM_TOTAL_CDS} -eq 1 ] ; then 1367 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1289 einfon "This ebuild will need the " 1368 einfon "This ebuild will need the "
1290 if [ -z "${CDROM_NAME}" ] ; then 1369 if [[ -z ${CDROM_NAME} ]] ; then
1291 echo "cdrom for ${PN}." 1370 echo "cdrom for ${PN}."
1292 else 1371 else
1293 echo "${CDROM_NAME}." 1372 echo "${CDROM_NAME}."
1294 fi 1373 fi
1295 echo 1374 echo
1296 einfo "If you do not have the CD, but have the data files" 1375 einfo "If you do not have the CD, but have the data files"
1297 einfo "mounted somewhere on your filesystem, just export" 1376 einfo "mounted somewhere on your filesystem, just export"
1298 einfo "the variable CD_ROOT so that it points to the" 1377 einfo "the variable CD_ROOT so that it points to the"
1299 einfo "directory containing the files." 1378 einfo "directory containing the files."
1300 echo 1379 echo
1380 einfo "For example:"
1381 einfo "export CD_ROOT=/mnt/cdrom"
1382 echo
1301 else 1383 else
1302 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds." 1384 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds."
1303 cdcnt=0 1385 cdcnt=0
1304 while [ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ] ; do 1386 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1305 cdcnt=$((cdcnt + 1)) 1387 cdcnt=$((cdcnt + 1))
1306 var="CDROM_NAME_${cdcnt}" 1388 var="CDROM_NAME_${cdcnt}"
1307 [ ! -z "${!var}" ] && einfo " CD ${cdcnt}: ${!var}" 1389 [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}"
1308 done 1390 done
1309 echo 1391 echo
1310 einfo "If you do not have the CDs, but have the data files" 1392 einfo "If you do not have the CDs, but have the data files"
1311 einfo "mounted somewhere on your filesystem, just export" 1393 einfo "mounted somewhere on your filesystem, just export"
1312 einfo "the following variables so they point to the right place:" 1394 einfo "the following variables so they point to the right place:"
1313 einfon "" 1395 einfon ""
1314 cdcnt=0 1396 cdcnt=0
1315 while [ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ] ; do 1397 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1316 cdcnt=$((cdcnt + 1)) 1398 cdcnt=$((cdcnt + 1))
1317 echo -n " CD_ROOT_${cdcnt}" 1399 echo -n " CD_ROOT_${cdcnt}"
1318 done 1400 done
1319 echo 1401 echo
1320 einfo "Or, if you have all the files in the same place, or" 1402 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" 1403 einfo "you only have one cdrom, you can export CD_ROOT"
1322 einfo "and that place will be used as the same data source" 1404 einfo "and that place will be used as the same data source"
1323 einfo "for all the CDs." 1405 einfo "for all the CDs."
1324 echo 1406 echo
1407 einfo "For example:"
1408 einfo "export CD_ROOT_1=/mnt/cdrom"
1409 echo
1325 fi 1410 fi
1326 export CDROM_CURRENT_CD=0 1411 export CDROM_CURRENT_CD=0
1327 cdrom_load_next_cd 1412 cdrom_load_next_cd
1328} 1413}
1329 1414
1333# remember, you can only go forward in the cd chain, you can't go back. 1418# remember, you can only go forward in the cd chain, you can't go back.
1334cdrom_load_next_cd() { 1419cdrom_load_next_cd() {
1335 export CDROM_CURRENT_CD=$((CDROM_CURRENT_CD + 1)) 1420 export CDROM_CURRENT_CD=$((CDROM_CURRENT_CD + 1))
1336 local var= 1421 local var=
1337 1422
1338 if [ ! -z "${CD_ROOT}" ] ; then 1423 if [[ ! -z ${CD_ROOT} ]] ; then
1339 einfo "Using same root as before for CD #${CDROM_CURRENT_CD}" 1424 einfo "Using same root as before for CD #${CDROM_CURRENT_CD}"
1340 return 1425 return
1341 fi 1426 fi
1342 1427
1343 unset CDROM_ROOT 1428 unset CDROM_ROOT
1344 var=CDROM_ROOTS_${CDROM_CURRENT_CD} 1429 var=CDROM_ROOTS_${CDROM_CURRENT_CD}
1345 if [ -z "${!var}" ] ; then 1430 if [[ -z ${!var} ]] ; then
1346 var="CDROM_CHECK_${CDROM_CURRENT_CD}" 1431 var="CDROM_CHECK_${CDROM_CURRENT_CD}"
1347 cdrom_locate_file_on_cd ${!var} 1432 cdrom_locate_file_on_cd ${!var}
1348 else 1433 else
1349 export CDROM_ROOT="${!var}" 1434 export CDROM_ROOT=${!var}
1350 fi 1435 fi
1351 1436
1352 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 1437 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1353} 1438}
1354 1439
1358# found, then a message asking for the user to insert the cdrom will be 1443# found, then a message asking for the user to insert the cdrom will be
1359# displayed and we'll hang out here until: 1444# displayed and we'll hang out here until:
1360# (1) the file is found on a mounted cdrom 1445# (1) the file is found on a mounted cdrom
1361# (2) the user hits CTRL+C 1446# (2) the user hits CTRL+C
1362cdrom_locate_file_on_cd() { 1447cdrom_locate_file_on_cd() {
1363 while [ -z "${CDROM_ROOT}" ] ; do 1448 while [[ -z ${CDROM_ROOT} ]] ; do
1364 local dir="$(dirname ${@})" 1449 local dir="$(dirname ${@})"
1365 local file="$(basename ${@})" 1450 local file="$(basename ${@})"
1366 local mline="" 1451 local mline=""
1367 local showedmsg=0 1452 local showedmsg=0
1368 1453
1369 for mline in `mount | egrep -e '(iso|cdrom)' | awk '{print $3}'` ; do 1454 for mline in $(mount | egrep -e '(iso|cdrom)' | awk '{print $3}') ; do
1370 [ -d "${mline}/${dir}" ] || continue 1455 [[ -d ${mline}/${dir} ]] || continue
1371 [ ! -z "$(find ${mline}/${dir} -iname ${file} -maxdepth 1)" ] \ 1456 [[ ! -z $(find ${mline}/${dir} -iname ${file} -maxdepth 1) ]] \
1372 && export CDROM_ROOT=${mline} 1457 && export CDROM_ROOT=${mline}
1373 done 1458 done
1374 1459
1375 if [ -z "${CDROM_ROOT}" ] ; then 1460 if [[ -z ${CDROM_ROOT} ]] ; then
1376 echo 1461 echo
1377 if [ ${showedmsg} -eq 0 ] ; then 1462 if [[ ${showedmsg} -eq 0 ]] ; then
1378 if [ ${CDROM_TOTAL_CDS} -eq 1 ] ; then 1463 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1379 if [ -z "${CDROM_NAME}" ] ; then 1464 if [[ -z ${CDROM_NAME} ]] ; then
1380 einfo "Please insert the cdrom for ${PN} now !" 1465 einfo "Please insert the cdrom for ${PN} now !"
1381 else 1466 else
1382 einfo "Please insert the ${CDROM_NAME} cdrom now !" 1467 einfo "Please insert the ${CDROM_NAME} cdrom now !"
1383 fi 1468 fi
1384 else 1469 else
1385 if [ -z "${CDROM_NAME_1}" ] ; then 1470 if [[ -z ${CDROM_NAME_1} ]] ; then
1386 einfo "Please insert cd #${CDROM_CURRENT_CD} for ${PN} now !" 1471 einfo "Please insert cd #${CDROM_CURRENT_CD} for ${PN} now !"
1387 else 1472 else
1388 local var="CDROM_NAME_${CDROM_CURRENT_CD}" 1473 local var="CDROM_NAME_${CDROM_CURRENT_CD}"
1389 einfo "Please insert+mount the ${!var} cdrom now !" 1474 einfo "Please insert+mount the ${!var} cdrom now !"
1390 fi 1475 fi
1509 touch ${D}${LIB} 1594 touch ${D}${LIB}
1510 fi 1595 fi
1511} 1596}
1512 1597
1513preserve_old_lib_notify() { 1598preserve_old_lib_notify() {
1514 LIB=$1 1599 LIB=$1
1515 1600
1516 if [ -n "${LIB}" -a -f "${ROOT}${LIB}" ]; then 1601 if [ -n "${LIB}" -a -f "${ROOT}${LIB}" ]; then
1517 SONAME=`basename ${LIB}` 1602 SONAME=`basename ${LIB}`
1518 1603
1519 einfo "An old version of an installed library was detected on your system." 1604 einfo "An old version of an installed library was detected on your system."
1520 einfo "In order to avoid breaking packages that link against is, this older version" 1605 einfo "In order to avoid breaking packages that link against is, this older version"
1521 einfo "is not being removed. In order to make full use of this newer version," 1606 einfo "is not being removed. In order to make full use of this newer version,"
1522 einfo "you will need to execute the following command:" 1607 einfo "you will need to execute the following command:"
1523 einfo " revdep-rebuild --soname ${SONAME}" 1608 einfo " revdep-rebuild --soname ${SONAME}"
1524 einfo 1609 einfo
1525 einfo "After doing that, you can safely remove ${LIB}" 1610 einfo "After doing that, you can safely remove ${LIB}"
1526 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild" 1611 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild"
1527 fi 1612 fi
1528} 1613}
1529 1614
1530# Hack for people to figure out if a package was built with 1615# Hack for people to figure out if a package was built with
1531# certain USE flags 1616# certain USE flags
1532# 1617#
1533# Usage: built_with_use <DEPEND ATOM> <List of USE flags> 1618# Usage: built_with_use [-a|-o] <DEPEND ATOM> <List of USE flags>
1534# ex: built_with_use xchat gtk2 1619# ex: built_with_use xchat gtk2
1620#
1621# Flags: -a all USE flags should be utilized
1622# -o at least one USE flag should be utilized
1623# Note: the default flag is '-a'
1535built_with_use() { 1624built_with_use() {
1625 local opt=$1
1626 [[ ${opt:0:1} = "-" ]] && shift || opt="-a"
1627
1536 local PKG=$(portageq best_version ${ROOT} $1) 1628 local PKG=$(best_version $1)
1629 shift
1630
1537 local USEFILE="${ROOT}/var/db/pkg/${PKG}/USE" 1631 local USEFILE="${ROOT}/var/db/pkg/${PKG}/USE"
1538 [[ ! -e ${USEFILE} ]] && return 1 1632 [[ ! -e ${USEFILE} ]] && return 1
1539 1633
1540 local USE_BUILT=$(<${USEFILE}) 1634 local USE_BUILT=$(<${USEFILE})
1541
1542 shift
1543 while [ $# -gt 0 ] ; do 1635 while [[ $# -gt 0 ]] ; do
1636 if [[ ${opt} = "-o" ]] ; then
1637 has $1 ${USE_BUILT} && return 0
1638 else
1544 has $1 ${USE_BUILT} || return 1 1639 has $1 ${USE_BUILT} || return 1
1640 fi
1545 shift 1641 shift
1546 done 1642 done
1547 return 0 1643 [[ ${opt} = "-a" ]]
1548} 1644}
1549 1645
1550# Many configure scripts wrongly bail when a C++ compiler 1646# Many configure scripts wrongly bail when a C++ compiler
1551# could not be detected. #73450 1647# could not be detected. #73450
1552epunt_cxx() { 1648epunt_cxx() {
1586 elif [ -n "${ABI}" ]; then 1682 elif [ -n "${ABI}" ]; then
1587 abi=${ABI} 1683 abi=${ABI}
1588 elif [ -n "${DEFAULT_ABI}" ]; then 1684 elif [ -n "${DEFAULT_ABI}" ]; then
1589 abi=${DEFAULT_ABI} 1685 abi=${DEFAULT_ABI}
1590 else 1686 else
1591 return "" 1687 return 1
1592 fi 1688 fi
1593 eval echo \${${flag}_${abi}} 1689 eval echo \${${flag}_${abi}}
1594} 1690}
1595 1691
1596get_abi_CFLAGS() { get_abi_var CFLAGS $1; } 1692get_abi_CFLAGS() { get_abi_var CFLAGS $1; }

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

  ViewVC Help
Powered by ViewVC 1.1.20