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

Diff of /eclass/eutils.eclass

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

Revision 1.275 Revision 1.281
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2007 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.275 2007/02/17 00:17:39 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.281 2007/06/05 15:59:26 nyhm Exp $
4# 4#
5# This eclass is for general purpose functions that most ebuilds 5# This eclass is for general purpose functions that most ebuilds
6# have to implement themselves. 6# have to implement themselves.
7# 7#
8# NB: If you add anything, please comment it! 8# NB: If you add anything, please comment it!
366 [[ -z ${T} ]] \ 366 [[ -z ${T} ]] \
367 && topdir="/tmp" \ 367 && topdir="/tmp" \
368 || topdir=${T} 368 || topdir=${T}
369 fi 369 fi
370 370
371 if [[ -z $(type -p mktemp) ]] ; then 371 if ! type -P mktemp > /dev/null ; then
372 # system lacks `mktemp` so we have to fake it
372 local tmp=/ 373 local tmp=/
373 while [[ -e ${tmp} ]] ; do 374 while [[ -e ${tmp} ]] ; do
374 tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM} 375 tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}
375 done 376 done
376 ${exe} "${tmp}" || ${exe} -p "${tmp}" 377 ${exe} "${tmp}" || ${exe} -p "${tmp}"
377 echo "${tmp}" 378 echo "${tmp}"
378 else 379 else
380 # the args here will give slightly wierd names on BSD,
381 # but should produce a usable file on all userlands
379 if [[ ${exe} == "touch" ]] ; then 382 if [[ ${exe} == "touch" ]] ; then
380 [[ ${USERLAND} == "GNU" ]] \
381 && mktemp -p "${topdir}" \
382 || TMPDIR="${topdir}" mktemp -t tmp 383 TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX
383 else 384 else
384 [[ ${USERLAND} == "GNU" ]] \
385 && mktemp -d "${topdir}" \
386 || TMPDIR="${topdir}" mktemp -dt tmp 385 TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX
387 fi 386 fi
388 fi 387 fi
389} 388}
390 389
391# Small wrapper for getent (Linux), nidump (Mac OS X), 390# Small wrapper for getent (Linux), nidump (Mac OS X),
916 # doesn't corrupt the env of the caller 915 # doesn't corrupt the env of the caller
917 insinto /usr/share/applications 916 insinto /usr/share/applications
918 doins "${desktop}" 917 doins "${desktop}"
919 ) 918 )
920} 919}
920
921
922# Validate desktop entries using desktop-file-utils
923# Carsten Lohrke <carlo@gentoo.org>
924#
925# Usage: validate_desktop_entries [directory ...]
926
927validate_desktop_entries() {
928 if [[ -x /usr/bin/desktop-file-validate ]] ; then
929 einfo "Checking desktop entry validity"
930 local directories=""
931 for d in /usr/share/applications $@ ; do
932 [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}"
933 done
934 if [[ -n ${directories} ]] ; then
935 for FILE in $(find ${directories} -name "*\.desktop" \
936 -not -path '*.hidden*' | sort -u 2>/dev/null)
937 do
938 local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | \
939 sed -e "s|error: ||" -e "s|${FILE}:|--|g" )
940 [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:}
941 done
942 fi
943 echo ""
944 else
945 einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo."
946 fi
947}
948
921 949
922# Make a GDM/KDM Session file 950# Make a GDM/KDM Session file
923# 951#
924# make_session_desktop(<title>, <command>) 952# make_session_desktop(<title>, <command>)
925# title: File to execute to start the Window Manager 953# title: File to execute to start the Window Manager
1430 local dir=$(dirname ${cdset[${i}]}) 1458 local dir=$(dirname ${cdset[${i}]})
1431 local file=$(basename ${cdset[${i}]}) 1459 local file=$(basename ${cdset[${i}]})
1432 1460
1433 local point= node= fs= foo= 1461 local point= node= fs= foo=
1434 while read point node fs foo ; do 1462 while read point node fs foo ; do
1435 [[ " cd9660 iso9660 " != *" ${fs} "* ]] && \ 1463 [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && \
1436 ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \ 1464 ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \
1437 && continue 1465 && continue
1438 point=${point//\040/ } 1466 point=${point//\040/ }
1439 [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue 1467 [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue
1440 export CDROM_ROOT=${point} 1468 export CDROM_ROOT=${point}
1581# } 1609# }
1582 1610
1583preserve_old_lib() { 1611preserve_old_lib() {
1584 if [[ ${EBUILD_PHASE} != "preinst" ]] ; then 1612 if [[ ${EBUILD_PHASE} != "preinst" ]] ; then
1585 eerror "preserve_old_lib() must be called from pkg_preinst() only" 1613 eerror "preserve_old_lib() must be called from pkg_preinst() only"
1586# die "Invalid preserve_old_lib() usage" 1614 die "Invalid preserve_old_lib() usage"
1587 fi 1615 fi
1588 [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]" 1616 [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]"
1589 1617
1590 local lib dir 1618 local lib dir
1591 for lib in "$@" ; do 1619 for lib in "$@" ; do
1598} 1626}
1599 1627
1600preserve_old_lib_notify() { 1628preserve_old_lib_notify() {
1601 if [[ ${EBUILD_PHASE} != "postinst" ]] ; then 1629 if [[ ${EBUILD_PHASE} != "postinst" ]] ; then
1602 eerror "preserve_old_lib_notify() must be called from pkg_postinst() only" 1630 eerror "preserve_old_lib_notify() must be called from pkg_postinst() only"
1603# die "Invalid preserve_old_lib_notify() usage" 1631 die "Invalid preserve_old_lib_notify() usage"
1604 fi 1632 fi
1605 1633
1606 local lib notice=0 1634 local lib notice=0
1607 for lib in "$@" ; do 1635 for lib in "$@" ; do
1608 [[ -e ${ROOT}/${lib} ]] || continue 1636 [[ -e ${ROOT}/${lib} ]] || continue

Legend:
Removed from v.1.275  
changed lines
  Added in v.1.281

  ViewVC Help
Powered by ViewVC 1.1.20