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

Diff of /eclass/eutils.eclass

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

Revision 1.118 Revision 1.127
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.118 2004/10/13 14:33:01 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.127 2004/12/11 21:09:23 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.
221 local x="" 221 local x=""
222 222
223 if [ "$#" -gt 1 ] 223 if [ "$#" -gt 1 ]
224 then 224 then
225 local m="" 225 local m=""
226 einfo "${#} patches to apply..." 226 einfo "${#} patches to apply ..."
227 for m in "$@" ; do 227 for m in "$@" ; do
228 epatch "${m}" 228 epatch "${m}"
229 done 229 done
230 return 0 230 return 0
231 fi 231 fi
245 local EPATCH_SOURCE="$1/*" 245 local EPATCH_SOURCE="$1/*"
246 else 246 else
247 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}" 247 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
248 fi 248 fi
249 else 249 else
250 if [ ! -d ${EPATCH_SOURCE} ] 250 if [ ! -d ${EPATCH_SOURCE} ] || [ -n "$1" ]
251 then 251 then
252 if [ -n "$1" -a "${EPATCH_SOURCE}" = "${WORKDIR}/patch" ] 252 if [ -n "$1" -a "${EPATCH_SOURCE}" = "${WORKDIR}/patch" ]
253 then 253 then
254 EPATCH_SOURCE="$1" 254 EPATCH_SOURCE="$1"
255 fi 255 fi
284 ;; 284 ;;
285 esac 285 esac
286 286
287 if [ "${SINGLE_PATCH}" = "no" ] 287 if [ "${SINGLE_PATCH}" = "no" ]
288 then 288 then
289 einfo "Applying various patches (bugfixes/updates)..." 289 einfo "Applying various patches (bugfixes/updates) ..."
290 fi 290 fi
291 for x in ${EPATCH_SOURCE} 291 for x in ${EPATCH_SOURCE}
292 do 292 do
293 # New ARCH dependant patch naming scheme... 293 # New ARCH dependant patch naming scheme ...
294 # 294 #
295 # ???_arch_foo.patch 295 # ???_arch_foo.patch
296 # 296 #
297 if [ -f ${x} ] && \ 297 if [ -f ${x} ] && \
298 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \ 298 ([ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] || \
313 then 313 then
314 if [ -n "${EPATCH_SINGLE_MSG}" ] 314 if [ -n "${EPATCH_SINGLE_MSG}" ]
315 then 315 then
316 einfo "${EPATCH_SINGLE_MSG}" 316 einfo "${EPATCH_SINGLE_MSG}"
317 else 317 else
318 einfo "Applying ${x##*/}..." 318 einfo "Applying ${x##*/} ..."
319 fi 319 fi
320 else 320 else
321 einfo " ${x##*/}..." 321 einfo " ${x##*/} ..."
322 fi 322 fi
323 323
324 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 324 echo "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
325 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 325 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}
326 326
359 359
360 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1 360 if (cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f) >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/} 2>&1
361 then 361 then
362 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 362 draw_line "***** ${x##*/} *****" > ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
363 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 363 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
364 echo "ACTUALLY APPLYING ${x##*/}..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 364 echo "ACTUALLY APPLYING ${x##*/} ..." >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
365 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 365 echo >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
366 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 366 draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real
367 367
368 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1 368 cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${x##*/}-${STDERR_TARGET##*/}.real 2>&1
369 369
438 438
439 return 1; 439 return 1;
440 } 440 }
441 END 441 END
442 442
443 einfon "Checking for _CS_GNU_LIBPTHREAD_VERSION support in glibc ... " 443 einfon "Checking for _CS_GNU_LIBPTHREAD_VERSION support in glibc ..."
444 if gcc -o ${T}/nptl ${T}/test-nptl.c &> /dev/null 444 if gcc -o ${T}/nptl ${T}/test-nptl.c &> /dev/null
445 then 445 then
446 echo "yes" 446 echo "yes"
447 einfon "Checking what PTHREADS implementation we have ... " 447 einfon "Checking what PTHREADS implementation we have ..."
448 if ${T}/nptl 448 if ${T}/nptl
449 then 449 then
450 return 0 450 return 0
451 else 451 else
452 return 1 452 return 1
528 528
529 if [ -n "${ADMINPARAM}" ] 529 if [ -n "${ADMINPARAM}" ]
530 then 530 then
531 if [ "${jobs}" -gt "${ADMINPARAM}" ] 531 if [ "${jobs}" -gt "${ADMINPARAM}" ]
532 then 532 then
533 einfo "Setting make jobs to \"-j${ADMINPARAM}\" to ensure successful merge..." 533 einfo "Setting make jobs to \"-j${ADMINPARAM}\" to ensure successful merge ..."
534 export MAKEOPTS="${MAKEOPTS} -j${ADMINPARAM}" 534 export MAKEOPTS="${MAKEOPTS} -j${ADMINPARAM}"
535 else 535 else
536 einfo "Setting make jobs to \"-j${jobs}\" to ensure successful merge..." 536 einfo "Setting make jobs to \"-j${jobs}\" to ensure successful merge ..."
537 export MAKEOPTS="${MAKEOPTS} -j${jobs}" 537 export MAKEOPTS="${MAKEOPTS} -j${jobs}"
538 fi 538 fi
539 fi 539 fi
540} 540}
541 541
543# does not exist on the users system 543# does not exist on the users system
544# vapier@gentoo.org 544# vapier@gentoo.org
545# 545#
546# Takes just 1 optional parameter (the directory to create tmpfile in) 546# Takes just 1 optional parameter (the directory to create tmpfile in)
547emktemp() { 547emktemp() {
548 local exe="touch"
549 [ "$1" == "-d" ] && exe="mkdir" && shift
548 local topdir="$1" 550 local topdir="$1"
549 551
550 if [ -z "${topdir}" ] 552 if [ -z "${topdir}" ]
551 then 553 then
552 [ -z "${T}" ] \ 554 [ -z "${T}" ] \
558 then 560 then
559 local tmp=/ 561 local tmp=/
560 while [ -e "${tmp}" ] ; do 562 while [ -e "${tmp}" ] ; do
561 tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}" 563 tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}"
562 done 564 done
563 touch "${tmp}" 565 ${exe} "${tmp}"
564 echo "${tmp}" 566 echo "${tmp}"
565 else 567 else
568 [ "${exe}" == "touch" ] \
569 && exe="-p" \
570 || exe="-d"
566 mktemp -p "${topdir}" 571 mktemp ${exe} "${topdir}"
567 fi 572 fi
568} 573}
569 574
570# Small wrapper for getent (Linux), nidump (Mac OS X), 575# Small wrapper for getent (Linux), nidump (Mac OS X),
571# and pw (FreeBSD) used in enewuser()/enewgroup() 576# and pw (FreeBSD) used in enewuser()/enewgroup()
572# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 577# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
573# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> 578# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
574# 579#
575# egetent(database, key) 580# egetent(database, key)
576egetent() { 581egetent() {
577 if useq macos || useq ppc-macos ; then 582 if useq ppc-macos ; then
578 case "$2" in 583 case "$2" in
579 *[!0-9]*) # Non numeric 584 *[!0-9]*) # Non numeric
580 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 585 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
581 ;; 586 ;;
582 *) # Numeric 587 *) # Numeric
729 734
730 # handle extra and add the user 735 # handle extra and add the user
731 local eextra="$@" 736 local eextra="$@"
732 local oldsandbox="${SANDBOX_ON}" 737 local oldsandbox="${SANDBOX_ON}"
733 export SANDBOX_ON="0" 738 export SANDBOX_ON="0"
734 if useq macos || useq ppc-macos ; 739 if useq ppc-macos
735 then 740 then
736 ### Make the user 741 ### Make the user
737 if [ -z "${eextra}" ] 742 if [ -z "${eextra}" ]
738 then 743 then
739 dscl . create /users/${euser} uid ${euid} 744 dscl . create /users/${euser} uid ${euid}
822 then 827 then
823 if [ "${egid}" -gt 0 ] 828 if [ "${egid}" -gt 0 ]
824 then 829 then
825 if [ -z "`egetent group ${egid}`" ] 830 if [ -z "`egetent group ${egid}`" ]
826 then 831 then
827 if useq macos || useq ppc-macos ; then 832 if useq ppc-macos ; then
828 opts="${opts} ${egid}" 833 opts="${opts} ${egid}"
829 else 834 else
830 opts="${opts} -g ${egid}" 835 opts="${opts} -g ${egid}"
831 fi 836 fi
832 else 837 else
846 opts="${opts} ${eextra}" 851 opts="${opts} ${eextra}"
847 852
848 # add the group 853 # add the group
849 local oldsandbox="${SANDBOX_ON}" 854 local oldsandbox="${SANDBOX_ON}"
850 export SANDBOX_ON="0" 855 export SANDBOX_ON="0"
851 if useq macos || useq ppc-macos ; 856 if useq ppc-macos ; then
852 then
853 if [ ! -z "${eextra}" ]; 857 if [ ! -z "${eextra}" ];
854 then 858 then
855 einfo "Extra options are not supported on macos yet" 859 einfo "Extra options are not supported on macos yet"
856 einfo "Please report the ebuild along with the info below" 860 einfo "Please report the ebuild along with the info below"
857 einfo "eextra: ${eextra}" 861 einfo "eextra: ${eextra}"
882} 886}
883 887
884# Simple script to replace 'dos2unix' binaries 888# Simple script to replace 'dos2unix' binaries
885# vapier@gentoo.org 889# vapier@gentoo.org
886# 890#
887# edos2unix(file, <more files>...) 891# edos2unix(file, <more files> ...)
888edos2unix() { 892edos2unix() {
889 for f in "$@" 893 for f in "$@"
890 do 894 do
891 cp "${f}" ${T}/edos2unix 895 cp "${f}" ${T}/edos2unix
892 sed 's/\r$//' ${T}/edos2unix > "${f}" 896 sed 's/\r$//' ${T}/edos2unix > "${f}"
1423 1427
1424 ls=" ${ls} " 1428 ls=" ${ls} "
1425 newls="" 1429 newls=""
1426 for f in ${LINGUAS} ; do 1430 for f in ${LINGUAS} ; do
1427 if [ "${ls/ ${f} /}" != "${ls}" ] ; then 1431 if [ "${ls/ ${f} /}" != "${ls}" ] ; then
1428 nl="${newls} ${f}" 1432 newls="${newls} ${f}"
1429 else 1433 else
1430 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" 1434 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA"
1431 fi 1435 fi
1432 done 1436 done
1433 if [ -z "${newls}" ] ; then 1437 if [ -z "${newls}" ] ; then
1509 einfo 1513 einfo
1510 einfo "After doing that, you can safely remove ${LIB}" 1514 einfo "After doing that, you can safely remove ${LIB}"
1511 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild" 1515 einfo "Note: 'emerge gentoolkit' to get revdep-rebuild"
1512 fi 1516 fi
1513} 1517}
1518
1519# Hack for people to figure out if a package was built with
1520# certain USE flags
1521#
1522# Usage: built_with_use <DEPEND ATOM> <List of USE flags>
1523# ex: built_with_use xchat gtk2
1524built_with_use() {
1525 local PKG=$(portageq best_version ${ROOT} $1)
1526 local USEFILE="${ROOT}/var/db/pkg/${PKG}/USE"
1527 [[ ! -e ${USEFILE} ]] && return 1
1528
1529 local USE_BUILT=$(<${USEFILE})
1530
1531 shift
1532 while [ $# -gt 0 ] ; do
1533 has $1 ${USE_BUILT} || return 1
1534 shift
1535 done
1536 return 0
1537}
1538
1539# Many configure scripts wrongly bail when a C++ compiler
1540# could not be detected. #73450
1541epunt_cxx() {
1542 local dir=$1
1543 [[ -z ${dir} ]] && dir=${S}
1544 ebegin "Removing useless C++ checks"
1545 local f
1546 for f in $(find ${dir} -name configure) ; do
1547 patch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null
1548 done
1549 eend 0
1550}

Legend:
Removed from v.1.118  
changed lines
  Added in v.1.127

  ViewVC Help
Powered by ViewVC 1.1.20