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

Diff of /eclass/eutils.eclass

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

Revision 1.116 Revision 1.123
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.116 2004/10/07 06:02:39 eradicator Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.123 2004/11/11 04:10:40 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
542# Cheap replacement for when debianutils (and thus mktemp) 542# Cheap replacement for when debianutils (and thus mktemp)
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 parameter (the directory to create tmpfile in) 546# Takes just 1 optional parameter (the directory to create tmpfile in)
547mymktemp() { 547emktemp() {
548 local exe="touch"
549 [ "$1" == "-d" ] && exe="mkdir" && shift
548 local topdir="$1" 550 local topdir="$1"
549 551
550 [ -z "${topdir}" ] && topdir=/tmp 552 if [ -z "${topdir}" ]
551 if [ "`which mktemp 2>/dev/null`" ]
552 then 553 then
553 mktemp -p ${topdir} 554 [ -z "${T}" ] \
554 else 555 && topdir="/tmp" \
556 || topdir="${T}"
557 fi
558
559 if [ -z "$(type -p mktemp)" ]
560 then
561 local tmp=/
562 while [ -e "${tmp}" ] ; do
555 local tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}" 563 tmp="${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}"
556 touch ${tmp} 564 done
565 ${exe} "${tmp}"
557 echo ${tmp} 566 echo "${tmp}"
567 else
568 [ "${exe}" == "touch" ] \
569 && exe="-p" \
570 || exe="-d"
571 mktemp ${exe} "${topdir}"
558 fi 572 fi
559} 573}
560 574
561# Small wrapper for getent (Linux), nidump (Mac OS X), 575# Small wrapper for getent (Linux), nidump (Mac OS X),
562# and pw (FreeBSD) used in enewuser()/enewgroup() 576# and pw (FreeBSD) used in enewuser()/enewgroup()
563# Joe Jezak <josejx@gmail.com> and usata@gentoo.org 577# Joe Jezak <josejx@gmail.com> and usata@gentoo.org
564# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org> 578# FBSD stuff: Aaron Walker <ka0ttic@gentoo.org>
565# 579#
566# egetent(database, key) 580# egetent(database, key)
567egetent() { 581egetent() {
568 if useq macos || useq ppc-macos ; then 582 if use ppc-macos ; then
569 case "$2" in 583 case "$2" in
570 *[!0-9]*) # Non numeric 584 *[!0-9]*) # Non numeric
571 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }" 585 nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
572 ;; 586 ;;
573 *) # Numeric 587 *) # Numeric
720 734
721 # handle extra and add the user 735 # handle extra and add the user
722 local eextra="$@" 736 local eextra="$@"
723 local oldsandbox="${SANDBOX_ON}" 737 local oldsandbox="${SANDBOX_ON}"
724 export SANDBOX_ON="0" 738 export SANDBOX_ON="0"
725 if useq macos || useq ppc-macos ; 739 if use ppc-macos
726 then 740 then
727 ### Make the user 741 ### Make the user
728 if [ -z "${eextra}" ] 742 if [ -z "${eextra}" ]
729 then 743 then
730 dscl . create /users/${euser} uid ${euid} 744 dscl . create /users/${euser} uid ${euid}
813 then 827 then
814 if [ "${egid}" -gt 0 ] 828 if [ "${egid}" -gt 0 ]
815 then 829 then
816 if [ -z "`egetent group ${egid}`" ] 830 if [ -z "`egetent group ${egid}`" ]
817 then 831 then
818 if useq macos || useq ppc-macos ; then 832 if use ppc-macos ; then
819 opts="${opts} ${egid}" 833 opts="${opts} ${egid}"
820 else 834 else
821 opts="${opts} -g ${egid}" 835 opts="${opts} -g ${egid}"
822 fi 836 fi
823 else 837 else
837 opts="${opts} ${eextra}" 851 opts="${opts} ${eextra}"
838 852
839 # add the group 853 # add the group
840 local oldsandbox="${SANDBOX_ON}" 854 local oldsandbox="${SANDBOX_ON}"
841 export SANDBOX_ON="0" 855 export SANDBOX_ON="0"
842 if useq macos || useq ppc-macos ; 856 if use ppc-macos
843 then 857 then
844 if [ ! -z "${eextra}" ]; 858 if [ ! -z "${eextra}" ];
845 then 859 then
846 einfo "Extra options are not supported on macos yet" 860 einfo "Extra options are not supported on macos yet"
847 einfo "Please report the ebuild along with the info below" 861 einfo "Please report the ebuild along with the info below"
873} 887}
874 888
875# Simple script to replace 'dos2unix' binaries 889# Simple script to replace 'dos2unix' binaries
876# vapier@gentoo.org 890# vapier@gentoo.org
877# 891#
878# edos2unix(file, <more files>...) 892# edos2unix(file, <more files> ...)
879edos2unix() { 893edos2unix() {
880 for f in "$@" 894 for f in "$@"
881 do 895 do
882 cp "${f}" ${T}/edos2unix 896 cp "${f}" ${T}/edos2unix
883 sed 's/\r$//' ${T}/edos2unix > "${f}" 897 sed 's/\r$//' ${T}/edos2unix > "${f}"
885} 899}
886 900
887# Make a desktop file ! 901# Make a desktop file !
888# Great for making those icons in kde/gnome startmenu ! 902# Great for making those icons in kde/gnome startmenu !
889# Amaze your friends ! Get the women ! Join today ! 903# Amaze your friends ! Get the women ! Join today !
890# gnome2 /usr/share/applications
891# gnome1 /usr/share/gnome/apps/
892# KDE ${KDEDIR}/share/applnk /usr/share/applnk
893# 904#
894# make_desktop_entry(<binary>, [name], [icon], [type], [path]) 905# make_desktop_entry(<binary>, [name], [icon], [type], [path])
895# 906#
896# binary: what binary does the app run with ? 907# binary: what binary does the app run with ?
897# name: the name that will show up in the menu 908# name: the name that will show up in the menu
898# icon: give your little like a pretty little icon ... 909# icon: give your little like a pretty little icon ...
899# this can be relative (to /usr/share/pixmaps) or 910# this can be relative (to /usr/share/pixmaps) or
900# a full path to an icon 911# a full path to an icon
901# type: what kind of application is this ? for categories: 912# type: what kind of application is this ? for categories:
902# http://www.freedesktop.org/standards/menu-spec/ 913# http://www.freedesktop.org/standards/menu-spec/
903# path: if your app needs to startup in a specific dir 914# path: if your app needs to startup in a specific dir
904make_desktop_entry() { 915make_desktop_entry() {
905 [ -z "$1" ] && eerror "You must specify the executable" && return 1 916 [ -z "$1" ] && eerror "make_desktop_entry: You must specify the executable" && return 1
906 917
907 local exec="${1}" 918 local exec="${1}"
908 local name="${2:-${PN}}" 919 local name="${2:-${PN}}"
909 local icon="${3:-${PN}.png}" 920 local icon="${3:-${PN}.png}"
910 local type="${4}" 921 local type="${4}"
942Exec=${exec} 953Exec=${exec}
943Path=${path} 954Path=${path}
944Icon=${icon} 955Icon=${icon}
945Categories=Application;${type};" > "${desktop}" 956Categories=Application;${type};" > "${desktop}"
946 957
947 if [ -d "/usr/share/applications" ]
948 then
949 insinto /usr/share/applications 958 insinto /usr/share/applications
950 doins "${desktop}" 959 doins "${desktop}"
951 fi
952
953 #if [ -d "/usr/share/gnome/apps" ]
954 #then
955 # insinto /usr/share/gnome/apps/Games
956 # doins ${desktop}
957 #fi
958
959 #if [ ! -z "`ls /usr/kde/* 2>/dev/null`" ]
960 #then
961 # for ver in /usr/kde/*
962 # do
963 # insinto ${ver}/share/applnk/Games
964 # doins ${desktop}
965 # done
966 #fi
967
968 if [ -d "/usr/share/applnk" ]
969 then
970 insinto /usr/share/applnk/${subdir}
971 doins "${desktop}"
972 fi
973 960
974 return 0 961 return 0
975} 962}
976 963
977# for internal use only (unpack_pdv and unpack_makeself) 964# for internal use only (unpack_pdv and unpack_makeself)
1026 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1013 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1027 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"` 1014 local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"`
1028 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"` 1015 local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"`
1029 1016
1030 # grab metadata for debug reasons 1017 # grab metadata for debug reasons
1031 local metafile="`mymktemp ${T}`" 1018 local metafile="$(emktemp)"
1032 tail -c +$((${metaskip}+1)) ${src} > ${metafile} 1019 tail -c +$((${metaskip}+1)) ${src} > ${metafile}
1033 1020
1034 # rip out the final file name from the metadata 1021 # rip out the final file name from the metadata
1035 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`" 1022 local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`"
1036 datafile="`basename ${datafile}`" 1023 datafile="`basename ${datafile}`"
1037 1024
1038 # now lets uncompress/untar the file if need be 1025 # now lets uncompress/untar the file if need be
1039 local tmpfile="`mymktemp ${T}`" 1026 local tmpfile="$(emktemp)"
1040 tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile} 1027 tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile}
1041 1028
1042 local iscompressed="`file -b ${tmpfile}`" 1029 local iscompressed="`file -b ${tmpfile}`"
1043 if [ "${iscompressed:0:8}" == "compress" ] ; then 1030 if [ "${iscompressed:0:8}" == "compress" ] ; then
1044 iscompressed=1 1031 iscompressed=1
1146 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; 1133 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";;
1147 *) die "makeself cant handle exe '${exe}'" 1134 *) die "makeself cant handle exe '${exe}'"
1148 esac 1135 esac
1149 1136
1150 # lets grab the first few bytes of the file to figure out what kind of archive it is 1137 # lets grab the first few bytes of the file to figure out what kind of archive it is
1151 local tmpfile="$(mymktemp "${T}")" 1138 local tmpfile="$(emktemp)"
1152 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" 1139 eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}"
1153 local filetype="$(file -b "${tmpfile}")" 1140 local filetype="$(file -b "${tmpfile}")"
1154 case ${filetype} in 1141 case ${filetype} in
1155 *tar\ archive) 1142 *tar\ archive)
1156 eval ${exe} | tar --no-same-owner -xf - 1143 eval ${exe} | tar --no-same-owner -xf -
1203 return 0 1190 return 0
1204 fi 1191 fi
1205 done 1192 done
1206 set +o noglob; set -$shopts #reset old shell opts 1193 set +o noglob; set -$shopts #reset old shell opts
1207 1194
1208 local licmsg="`mymktemp ${T}`" 1195 local licmsg="$(emktemp)"
1209 cat << EOF > ${licmsg} 1196 cat << EOF > ${licmsg}
1210********************************************************** 1197**********************************************************
1211The following license outlines the terms of use of this 1198The following license outlines the terms of use of this
1212package. You MUST accept this license for installation to 1199package. You MUST accept this license for installation to
1213continue. When you are done viewing, hit 'q'. If you 1200continue. When you are done viewing, hit 'q'. If you
1441 1428
1442 ls=" ${ls} " 1429 ls=" ${ls} "
1443 newls="" 1430 newls=""
1444 for f in ${LINGUAS} ; do 1431 for f in ${LINGUAS} ; do
1445 if [ "${ls/ ${f} /}" != "${ls}" ] ; then 1432 if [ "${ls/ ${f} /}" != "${ls}" ] ; then
1446 nl="${newls} ${f}" 1433 newls="${newls} ${f}"
1447 else 1434 else
1448 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA" 1435 ewarn "Sorry, but ${PN} does not support the ${f} LINGUA"
1449 fi 1436 fi
1450 done 1437 done
1451 if [ -z "${newls}" ] ; then 1438 if [ -z "${newls}" ] ; then

Legend:
Removed from v.1.116  
changed lines
  Added in v.1.123

  ViewVC Help
Powered by ViewVC 1.1.20