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

Diff of /eclass/eutils.eclass

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

Revision 1.144 Revision 1.157
1# Copyright 1999-2004 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.144 2005/02/03 22:11:33 chriswhite Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.157 2005/03/07 17:45:07 carlo 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.
32# CPU_FLAGS=(mmx mmx2 sse sse2) 32# CPU_FLAGS=(mmx mmx2 sse sse2)
33# ecpu_check CPU_FLAGS 33# ecpu_check CPU_FLAGS
34# Chris White <chriswhite@gentoo.org> (03 Feb 2005) 34# Chris White <chriswhite@gentoo.org> (03 Feb 2005)
35 35
36ecpu_check() { 36ecpu_check() {
37 # Think about changing below to: if [ "${CROSSCOMPILE}" -ne 1 -a -e "/proc/cpuinfo" ]
38 # and dropping the else if you do not plan on adding anything to that
39 # empty block ....
40 # PS: also try to add some quoting, and consider rather using ${foo} than $foo ...
41 if [ "${CROSSCOMPILE}" != "1" -a -e "/proc/cpuinfo" ]
42 then
37 CPU_FLAGS=$1 43 CPU_FLAGS=${1}
38 USER_CPU=`grep "flags" /proc/cpuinfo` 44 USER_CPU=`grep "flags" /proc/cpuinfo`
39 45
40 for flags in `seq 1 ${#CPU_FLAGS[@]}` 46 for flags in `seq 1 ${#CPU_FLAGS[@]}`
41 do 47 do
42 if has ${CPU_FLAGS[$flags - 1]} $USER_CPU && ! has ${CPU_FLAGS[$flags - 1]} $USE 48 if has ${CPU_FLAGS[${flags} - 1]} ${USER_CPU} && ! has ${CPU_FLAGS[${flags} - 1]} ${USE}
43 then 49 then
44 ewarn "Your system is ${CPU_FLAGS[$flags - 1]} capable but you don't have it enabled!" 50 ewarn "Your system is ${CPU_FLAGS[${flags} - 1]} capable but you don't have it enabled!"
45 ewarn "You might be cross compiling (in this case set CROSSCOMPILE to 1 to disable this warning." 51 ewarn "You might be cross compiling (in this case set CROSSCOMPILE to 1 to disable this warning."
46 fi 52 fi
47 53
48 if ! has ${CPU_FLAGS[$flags - 1]} $USER_CPU && has ${CPU_FLAGS[$flags -1]} $USE 54 if ! has ${CPU_FLAGS[${flags} - 1]} ${USER_CPU} && has ${CPU_FLAGS[${flags} -1]} ${USE}
49 then 55 then
50 ewarn "You have ${CPU_FLAGS[$flags - 1]} support enabled but your processor doesn't" 56 ewarn "You have ${CPU_FLAGS[${flags} - 1]} support enabled but your processor doesn't"
51 ewarn "Seem to support it! You might be cross compiling or do not have /proc filesystem" 57 ewarn "Seem to support it! You might be cross compiling or do not have /proc filesystem"
52 ewarn "enabled. If either is the case, set CROSSCOMPILE to 1 to disable this warning." 58 ewarn "enabled. If either is the case, set CROSSCOMPILE to 1 to disable this warning."
53 fi 59 fi
54 done 60 done
61 fi
55} 62}
56 63
57# Wait for the supplied number of seconds. If no argument is supplied, defaults 64# Wait for the supplied number of seconds. If no argument is supplied, defaults
58# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not 65# to five seconds. If the EPAUSE_IGNORE env var is set, don't wait. If we're not
59# outputting to a terminal, don't wait. For compatability purposes, the argument 66# outputting to a terminal, don't wait. For compatability purposes, the argument
285 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ 292 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \
286 [ "${EPATCH_FORCE}" = "yes" ]) 293 [ "${EPATCH_FORCE}" = "yes" ])
287 then 294 then
288 local count=0 295 local count=0
289 local popts="${EPATCH_OPTS}" 296 local popts="${EPATCH_OPTS}"
297 local patchname=${x##*/}
290 298
291 if [ -n "${EPATCH_EXCLUDE}" ] 299 if [ -n "${EPATCH_EXCLUDE}" ]
292 then 300 then
293 if [ "`eval echo \$\{EPATCH_EXCLUDE/${x##*/}\}`" != "${EPATCH_EXCLUDE}" ] 301 if [ "${EPATCH_EXCLUDE/${patchname}}" != "${EPATCH_EXCLUDE}" ]
294 then 302 then
295 continue 303 continue
296 fi 304 fi
297 fi 305 fi
298 306
300 then 308 then
301 if [ -n "${EPATCH_SINGLE_MSG}" ] 309 if [ -n "${EPATCH_SINGLE_MSG}" ]
302 then 310 then
303 einfo "${EPATCH_SINGLE_MSG}" 311 einfo "${EPATCH_SINGLE_MSG}"
304 else 312 else
305 einfo "Applying ${x##*/} ..." 313 einfo "Applying ${patchname} ..."
306 fi 314 fi
307 else 315 else
308 einfo " ${x##*/} ..." 316 einfo " ${patchname} ..."
309 fi 317 fi
310 318
311 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 319 echo "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
312 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 320 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
313 321
314 # Allow for prefix to differ ... im lazy, so shoot me :/ 322 # Allow for prefix to differ ... im lazy, so shoot me :/
315 while [ "${count}" -lt 5 ] 323 while [ "${count}" -lt 5 ]
316 do 324 do
317 # Generate some useful debug info ... 325 # Generate some useful debug info ...
318 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 326 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
319 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 327 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
320 328
321 if [ "${PATCH_SUFFIX}" != "patch" ] 329 if [ "${PATCH_SUFFIX}" != "patch" ]
322 then 330 then
323 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 331 echo -n "PIPE_COMMAND: " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
324 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 332 echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
325 else 333 else
326 PATCH_TARGET="${x}" 334 PATCH_TARGET="${x}"
327 fi 335 fi
328 336
329 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 337 echo -n "PATCH COMMAND: " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
330 echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 338 echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
331 339
332 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 340 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
333 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 341 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
334 342
335 if [ "${PATCH_SUFFIX}" != "patch" ] 343 if [ "${PATCH_SUFFIX}" != "patch" ]
336 then 344 then
337 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 345 if ! (${PIPE_CMD} ${x} > ${PATCH_TARGET}) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1
338 then 346 then
339 echo 347 echo
340 eerror "Could not extract patch!" 348 eerror "Could not extract patch!"
341 #die "Could not extract patch!" 349 #die "Could not extract patch!"
342 count=5 350 count=5
343 break 351 break
344 fi 352 fi
345 fi 353 fi
346 354
347 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 355 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1
348 then 356 then
349 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 357 draw_line "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
350 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 358 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
351 echo "ACTUALLY APPLYING ${x##*/} ..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 359 echo "ACTUALLY APPLYING ${patchname} ..." >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
352 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 360 echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
353 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 361 draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
354 362
355 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1 363 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real 2>&1
356 364
357 if [ "$?" -ne 0 ] 365 if [ "$?" -ne 0 ]
358 then 366 then
359 cat ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 367 cat ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
360 echo 368 echo
361 eerror "A dry-run of patch command succeeded, but actually" 369 eerror "A dry-run of patch command succeeded, but actually"
362 eerror "applying the patch failed!" 370 eerror "applying the patch failed!"
363 #die "Real world sux compared to the dreamworld!" 371 #die "Real world sux compared to the dreamworld!"
364 count=5 372 count=5
365 fi 373 fi
366 374
367 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 375 rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real
368 376
369 break 377 break
370 fi 378 fi
371 379
372 count=$((count + 1)) 380 count=$((count + 1))
378 fi 386 fi
379 387
380 if [ "${count}" -eq 5 ] 388 if [ "${count}" -eq 5 ]
381 then 389 then
382 echo 390 echo
383 eerror "Failed Patch: ${x##*/}!" 391 eerror "Failed Patch: ${patchname}!"
384 eerror 392 eerror
385 eerror "Include in your bugreport the contents of:" 393 eerror "Include in your bugreport the contents of:"
386 eerror 394 eerror
387 eerror " ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}" 395 eerror " ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}"
388 echo 396 echo
389 die "Failed Patch: ${x##*/}!" 397 die "Failed Patch: ${patchname}!"
390 fi 398 fi
391 399
392 rm -f ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 400 rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}
393 401
394 eend 0 402 eend 0
395 fi 403 fi
396 done 404 done
397 if [ "${SINGLE_PATCH}" = "no" ] 405 if [ "${SINGLE_PATCH}" = "no" ]
901# name: the name that will show up in the menu 909# name: the name that will show up in the menu
902# icon: give your little like a pretty little icon ... 910# icon: give your little like a pretty little icon ...
903# this can be relative (to /usr/share/pixmaps) or 911# this can be relative (to /usr/share/pixmaps) or
904# a full path to an icon 912# a full path to an icon
905# type: what kind of application is this ? for categories: 913# type: what kind of application is this ? for categories:
906# http://www.freedesktop.org/standards/menu-spec/ 914# http://www.freedesktop.org/wiki/Standards_2fmenu_2dspec
907# path: if your app needs to startup in a specific dir 915# path: if your app needs to startup in a specific dir
908make_desktop_entry() { 916make_desktop_entry() {
909 [ -z "$1" ] && eerror "make_desktop_entry: You must specify the executable" && return 1 917 [ -z "$1" ] && eerror "make_desktop_entry: You must specify the executable" && return 1
910 918
911 local exec="${1}" 919 local exec="${1}"
933 type= 941 type=
934 subdir= 942 subdir=
935 ;; 943 ;;
936 esac 944 esac
937 fi 945 fi
938 local desktop="${T}/${exec}.desktop" 946 local desktop="${T}/${exec%% *}-${P}.desktop"
939 947
940echo "[Desktop Entry] 948echo "[Desktop Entry]
941Encoding=UTF-8 949Encoding=UTF-8
942Version=0.9.2 950Version=0.9.2
943Name=${name} 951Name=${name}
1471# directories and uses the intersection of the lists. 1479# directories and uses the intersection of the lists.
1472# The -u builds a list of po files found in all the 1480# The -u builds a list of po files found in all the
1473# directories and uses the union of the lists. 1481# directories and uses the union of the lists.
1474strip-linguas() { 1482strip-linguas() {
1475 local ls newls 1483 local ls newls
1476 if [ "$1" == "-i" ] || [ "$1" == "-u" ] ; then 1484 if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then
1477 local op="$1"; shift 1485 local op=$1; shift
1478 ls=" $(find "$1" -name '*.po' -printf '%f ') "; shift 1486 ls=" $(find "$1" -name '*.po' -printf '%f ') "; shift
1479 local d f 1487 local d f
1480 for d in "$@" ; do 1488 for d in "$@" ; do
1481 if [ "${op}" == "-u" ] ; then 1489 if [[ ${op} == "-u" ]] ; then
1482 newls="${ls}" 1490 newls=${ls}
1483 else 1491 else
1484 newls="" 1492 newls=""
1485 fi 1493 fi
1486 for f in $(find "$d" -name '*.po' -printf '%f ') ; do 1494 for f in $(find "$d" -name '*.po' -printf '%f ') ; do
1487 if [ "${op}" == "-i" ] ; then 1495 if [[ ${op} == "-i" ]] ; then
1488 [ "${ls/ ${f} /}" != "${ls}" ] && newls="${newls} ${f}" 1496 [[ ${ls/ ${f} /} != ${ls} ]] && newls="${newls} ${f}"
1489 else 1497 else
1490 [ "${ls/ ${f} /}" == "${ls}" ] && newls="${newls} ${f}" 1498 [[ ${ls/ ${f} /} == ${ls} ]] && newls="${newls} ${f}"
1491 fi 1499 fi
1492 done 1500 done
1493 ls="${newls}" 1501 ls=${newls}
1494 done 1502 done
1495 ls="${ls//.po}" 1503 ls=${ls//.po}
1496 else 1504 else
1497 ls="$@" 1505 ls=$@
1498 fi 1506 fi
1499 1507
1500 ls=" ${ls} " 1508 ls=" ${ls} "
1501 newls="" 1509 newls=""
1502 for f in ${LINGUAS} ; do 1510 for f in ${LINGUAS} ; do
1503 if [ "${ls/ ${f} /}" != "${ls}" ] ; then 1511 if [[ ${ls/ ${f} /} != ${ls} ]] ; then
1504 newls="${newls} ${f}" 1512 newls="${newls} ${f}"
1505 else 1513 else
1506 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" 1514 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA"
1507 fi 1515 fi
1508 done 1516 done
1509 if [ -z "${newls}" ] ; then 1517 if [[ -z ${newls} ]] ; then
1510 unset LINGUAS 1518 unset LINGUAS
1511 else 1519 else
1512 export LINGUAS="${newls}" 1520 export LINGUAS=${newls:1}
1513 fi 1521 fi
1514} 1522}
1515 1523
1516# moved from kernel.eclass since they are generally useful outside of 1524# moved from kernel.eclass since they are generally useful outside of
1517# kernel.eclass -iggy (20041002) 1525# kernel.eclass -iggy (20041002)
1639 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null 1647 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null
1640 done 1648 done
1641 eend 0 1649 eend 0
1642} 1650}
1643 1651
1644# dopamd [ file ] [ new file ] 1652# dopamd <file> [more files]
1645# 1653#
1646# Install pam auth config file in /etc/pam.d 1654# Install pam auth config file in /etc/pam.d
1647#
1648# The first argument, 'file' is required. Install as 'new file', if
1649# specified.
1650
1651dopamd() { 1655dopamd() {
1652 local pamd="$1" newpamd="${2:-$1}"
1653 [[ -z "$1" ]] && die "dopamd requires at least one argument." 1656 [[ -z $1 ]] && die "dopamd requires at least one argument"
1654 1657
1655 use pam || return 0 1658 use pam || return 0
1656 1659
1657 insinto /etc/pam.d 1660 insinto /etc/pam.d
1658 # these are the default doins options, but be explicit just in case 1661 # these are the default doins options, but be explicit just in case
1659 insopts -m 0644 -o root -g root 1662 insopts -m 0644 -o root -g root
1660 newins ${pamd} ${newpamd} || die "failed to install ${newpamd}" 1663 doins "$@" || die "failed to install $@"
1661} 1664}
1665# newpamd <old name> <new name>
1666#
1667# Install pam file <old name> as <new name> in /etc/pam.d
1668newpamd() {
1669 [[ $# -ne 2 ]] && die "newpamd requires two arguements"
1670
1671 use pam || return 0
1672
1673 insinto /etc/pam.d
1674 # these are the default doins options, but be explicit just in case
1675 insopts -m 0644 -o root -g root
1676 newins "$1" "$2" || die "failed to install $1 as $2"
1677}

Legend:
Removed from v.1.144  
changed lines
  Added in v.1.157

  ViewVC Help
Powered by ViewVC 1.1.20