| 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.268 2007/01/13 19:36:14 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! |
| … | |
… | |
| 253 | einfo "${EPATCH_SINGLE_MSG}" |
253 | einfo "${EPATCH_SINGLE_MSG}" |
| 254 | else |
254 | else |
| 255 | einfo "Applying ${patchname} ..." |
255 | einfo "Applying ${patchname} ..." |
| 256 | fi |
256 | fi |
| 257 | else |
257 | else |
| 258 | einfo " ${patchname} ..." |
258 | einfo " ${patchname} ..." |
| 259 | fi |
259 | fi |
| 260 | |
260 | |
| 261 | echo "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} |
261 | echo "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} |
| 262 | echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} |
262 | echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} |
| 263 | |
263 | |
| … | |
… | |
| 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), |
| … | |
… | |
| 892 | if [ "${SLOT}" == "0" ] ; then |
891 | if [ "${SLOT}" == "0" ] ; then |
| 893 | local desktop_name="${PN}" |
892 | local desktop_name="${PN}" |
| 894 | else |
893 | else |
| 895 | local desktop_name="${PN}-${SLOT}" |
894 | local desktop_name="${PN}-${SLOT}" |
| 896 | fi |
895 | fi |
| 897 | local desktop=${T}/${exec%% *}-${desktop_name}.desktop |
896 | local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop" |
| 898 | # local desktop=${T}/${exec%% *:-${desktop_name}}.desktop |
897 | #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop |
| 899 | |
898 | |
|
|
899 | cat <<-EOF > "${desktop}" |
| 900 | echo "[Desktop Entry] |
900 | [Desktop Entry] |
| 901 | Encoding=UTF-8 |
901 | Encoding=UTF-8 |
| 902 | Version=0.9.2 |
902 | Version=0.9.2 |
| 903 | Name=${name} |
903 | Name=${name} |
| 904 | Type=Application |
904 | Type=Application |
| 905 | Comment=${DESCRIPTION} |
905 | Comment=${DESCRIPTION} |
| 906 | Exec=${exec} |
906 | Exec=${exec} |
| 907 | TryExec=${exec%% *} |
907 | TryExec=${exec%% *} |
| 908 | Path=${path} |
908 | Path=${path} |
| 909 | Icon=${icon} |
909 | Icon=${icon} |
| 910 | Categories=Application;${type};" > "${desktop}" |
910 | Categories=Application;${type}; |
|
|
911 | EOF |
| 911 | |
912 | |
| 912 | ( |
913 | ( |
| 913 | # wrap the env here so that the 'insinto' call |
914 | # wrap the env here so that the 'insinto' call |
| 914 | # doesn't corrupt the env of the caller |
915 | # doesn't corrupt the env of the caller |
| 915 | insinto /usr/share/applications |
916 | insinto /usr/share/applications |
| 916 | doins "${desktop}" |
917 | doins "${desktop}" |
| 917 | ) |
918 | ) |
| 918 | } |
919 | } |
| 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 | |
|
|
927 | validate_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 | |
|
|
949 | |
| 920 | # Make a GDM/KDM Session file |
950 | # Make a GDM/KDM Session file |
| 921 | # |
951 | # |
| 922 | # make_session_desktop(<title>, <command>) |
952 | # make_session_desktop(<title>, <command>) |
| 923 | # title: File to execute to start the Window Manager |
953 | # title: File to execute to start the Window Manager |
| 924 | # command: Name of the Window Manager |
954 | # command: Name of the Window Manager |
| … | |
… | |
| 929 | |
959 | |
| 930 | local title=$1 |
960 | local title=$1 |
| 931 | local command=$2 |
961 | local command=$2 |
| 932 | local desktop=${T}/${wm}.desktop |
962 | local desktop=${T}/${wm}.desktop |
| 933 | |
963 | |
|
|
964 | cat <<-EOF > "${desktop}" |
| 934 | echo "[Desktop Entry] |
965 | [Desktop Entry] |
| 935 | Encoding=UTF-8 |
966 | Encoding=UTF-8 |
| 936 | Name=${title} |
967 | Name=${title} |
| 937 | Comment=This session logs you into ${title} |
968 | Comment=This session logs you into ${title} |
| 938 | Exec=${command} |
969 | Exec=${command} |
| 939 | TryExec=${command} |
970 | TryExec=${command} |
| 940 | Type=Application" > "${desktop}" |
971 | Type=Application |
|
|
972 | EOF |
| 941 | |
973 | |
|
|
974 | ( |
|
|
975 | # wrap the env here so that the 'insinto' call |
|
|
976 | # doesn't corrupt the env of the caller |
| 942 | insinto /usr/share/xsessions |
977 | insinto /usr/share/xsessions |
| 943 | doins "${desktop}" |
978 | doins "${desktop}" |
|
|
979 | ) |
| 944 | } |
980 | } |
| 945 | |
981 | |
| 946 | domenu() { |
982 | domenu() { |
|
|
983 | ( |
|
|
984 | # wrap the env here so that the 'insinto' call |
|
|
985 | # doesn't corrupt the env of the caller |
| 947 | local i j |
986 | local i j ret=0 |
| 948 | insinto /usr/share/applications |
987 | insinto /usr/share/applications |
| 949 | for i in "$@" ; do |
988 | for i in "$@" ; do |
| 950 | if [[ -f ${i} ]] ; then |
989 | if [[ -f ${i} ]] ; then |
| 951 | doins "${i}" |
990 | doins "${i}" |
|
|
991 | ((ret+=$?)) |
| 952 | elif [[ -d ${i} ]] ; then |
992 | elif [[ -d ${i} ]] ; then |
| 953 | for j in "${i}"/*.desktop ; do |
993 | for j in "${i}"/*.desktop ; do |
| 954 | doins "${j}" |
994 | doins "${j}" |
|
|
995 | ((ret+=$?)) |
| 955 | done |
996 | done |
| 956 | fi |
997 | fi |
| 957 | done |
998 | done |
|
|
999 | exit ${ret} |
|
|
1000 | ) |
| 958 | } |
1001 | } |
| 959 | newmenu() { |
1002 | newmenu() { |
|
|
1003 | ( |
|
|
1004 | # wrap the env here so that the 'insinto' call |
|
|
1005 | # doesn't corrupt the env of the caller |
| 960 | insinto /usr/share/applications |
1006 | insinto /usr/share/applications |
| 961 | newins "$1" "$2" |
1007 | newins "$@" |
|
|
1008 | ) |
| 962 | } |
1009 | } |
| 963 | |
1010 | |
| 964 | doicon() { |
1011 | doicon() { |
|
|
1012 | ( |
|
|
1013 | # wrap the env here so that the 'insinto' call |
|
|
1014 | # doesn't corrupt the env of the caller |
| 965 | local i j |
1015 | local i j ret |
| 966 | insinto /usr/share/pixmaps |
1016 | insinto /usr/share/pixmaps |
| 967 | for i in "$@" ; do |
1017 | for i in "$@" ; do |
| 968 | if [[ -f ${i} ]] ; then |
1018 | if [[ -f ${i} ]] ; then |
| 969 | doins "${i}" |
1019 | doins "${i}" |
|
|
1020 | ((ret+=$?)) |
| 970 | elif [[ -d ${i} ]] ; then |
1021 | elif [[ -d ${i} ]] ; then |
| 971 | for j in "${i}"/*.png ; do |
1022 | for j in "${i}"/*.png ; do |
| 972 | doins "${j}" |
1023 | doins "${j}" |
|
|
1024 | ((ret+=$?)) |
| 973 | done |
1025 | done |
| 974 | fi |
1026 | fi |
| 975 | done |
1027 | done |
|
|
1028 | exit ${ret} |
|
|
1029 | ) |
| 976 | } |
1030 | } |
| 977 | newicon() { |
1031 | newicon() { |
|
|
1032 | ( |
|
|
1033 | # wrap the env here so that the 'insinto' call |
|
|
1034 | # doesn't corrupt the env of the caller |
| 978 | insinto /usr/share/pixmaps |
1035 | insinto /usr/share/pixmaps |
| 979 | newins "$1" "$2" |
1036 | newins "$@" |
|
|
1037 | ) |
| 980 | } |
1038 | } |
| 981 | |
1039 | |
| 982 | ############################################################## |
1040 | ############################################################## |
| 983 | # END: Handle .desktop files and menu entries # |
1041 | # END: Handle .desktop files and menu entries # |
| 984 | ############################################################## |
1042 | ############################################################## |
| … | |
… | |
| 1021 | # lseek |
1079 | # lseek |
| 1022 | # root@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin |
1080 | # root@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin |
| 1023 | # lseek(3, -4, SEEK_END) = 2981250 |
1081 | # lseek(3, -4, SEEK_END) = 2981250 |
| 1024 | # thus we would pass in the value of '4' as the second parameter. |
1082 | # thus we would pass in the value of '4' as the second parameter. |
| 1025 | unpack_pdv() { |
1083 | unpack_pdv() { |
| 1026 | local src=$(find_unpackable_file $1) |
1084 | local src=$(find_unpackable_file "$1") |
| 1027 | local sizeoff_t=$2 |
1085 | local sizeoff_t=$2 |
| 1028 | |
1086 | |
| 1029 | [[ -z ${src} ]] && die "Could not locate source for '$1'" |
1087 | [[ -z ${src} ]] && die "Could not locate source for '$1'" |
| 1030 | [[ -z ${sizeoff_t} ]] && die "No idea what off_t size was used for this pdv :(" |
1088 | [[ -z ${sizeoff_t} ]] && die "No idea what off_t size was used for this pdv :(" |
| 1031 | |
1089 | |
| 1032 | local shrtsrc=$(basename "${src}") |
1090 | local shrtsrc=$(basename "${src}") |
| 1033 | echo ">>> Unpacking ${shrtsrc} to ${PWD}" |
1091 | echo ">>> Unpacking ${shrtsrc} to ${PWD}" |
| 1034 | local metaskip=`tail -c ${sizeoff_t} ${src} | hexdump -e \"%i\"` |
1092 | local metaskip=$(tail -c ${sizeoff_t} "${src}" | hexdump -e \"%i\") |
| 1035 | local tailskip=`tail -c $((${sizeoff_t}*2)) ${src} | head -c ${sizeoff_t} | hexdump -e \"%i\"` |
1093 | local tailskip=$(tail -c $((${sizeoff_t}*2)) "${src}" | head -c ${sizeoff_t} | hexdump -e \"%i\") |
| 1036 | |
1094 | |
| 1037 | # grab metadata for debug reasons |
1095 | # grab metadata for debug reasons |
| 1038 | local metafile="$(emktemp)" |
1096 | local metafile=$(emktemp) |
| 1039 | tail -c +$((${metaskip}+1)) ${src} > ${metafile} |
1097 | tail -c +$((${metaskip}+1)) "${src}" > "${metafile}" |
| 1040 | |
1098 | |
| 1041 | # rip out the final file name from the metadata |
1099 | # rip out the final file name from the metadata |
| 1042 | local datafile="`tail -c +$((${metaskip}+1)) ${src} | strings | head -n 1`" |
1100 | local datafile=$(tail -c +$((${metaskip}+1)) "${src}" | strings | head -n 1) |
| 1043 | datafile="`basename ${datafile}`" |
1101 | datafile=$(basename "${datafile}") |
| 1044 | |
1102 | |
| 1045 | # now lets uncompress/untar the file if need be |
1103 | # now lets uncompress/untar the file if need be |
| 1046 | local tmpfile="$(emktemp)" |
1104 | local tmpfile=$(emktemp) |
| 1047 | tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile} |
1105 | tail -c +$((${tailskip}+1)) ${src} 2>/dev/null | head -c 512 > ${tmpfile} |
| 1048 | |
1106 | |
| 1049 | local iscompressed="`file -b ${tmpfile}`" |
1107 | local iscompressed=$(file -b "${tmpfile}") |
| 1050 | if [ "${iscompressed:0:8}" == "compress" ] ; then |
1108 | if [[ ${iscompressed:0:8} == "compress" ]] ; then |
| 1051 | iscompressed=1 |
1109 | iscompressed=1 |
| 1052 | mv ${tmpfile}{,.Z} |
1110 | mv ${tmpfile}{,.Z} |
| 1053 | gunzip ${tmpfile} |
1111 | gunzip ${tmpfile} |
| 1054 | else |
1112 | else |
| 1055 | iscompressed=0 |
1113 | iscompressed=0 |
| 1056 | fi |
1114 | fi |
| 1057 | local istar="`file -b ${tmpfile}`" |
1115 | local istar=$(file -b "${tmpfile}") |
| 1058 | if [ "${istar:0:9}" == "POSIX tar" ] ; then |
1116 | if [[ ${istar:0:9} == "POSIX tar" ]] ; then |
| 1059 | istar=1 |
1117 | istar=1 |
| 1060 | else |
1118 | else |
| 1061 | istar=0 |
1119 | istar=0 |
| 1062 | fi |
1120 | fi |
| 1063 | |
1121 | |
| … | |
… | |
| 1155 | dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; |
1213 | dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; |
| 1156 | *) die "makeself cant handle exe '${exe}'" |
1214 | *) die "makeself cant handle exe '${exe}'" |
| 1157 | esac |
1215 | esac |
| 1158 | |
1216 | |
| 1159 | # lets grab the first few bytes of the file to figure out what kind of archive it is |
1217 | # lets grab the first few bytes of the file to figure out what kind of archive it is |
| 1160 | local tmpfile="$(emktemp)" |
1218 | local tmpfile=$(emktemp) |
| 1161 | eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" |
1219 | eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" |
| 1162 | local filetype="$(file -b "${tmpfile}")" |
1220 | local filetype=$(file -b "${tmpfile}") |
| 1163 | case ${filetype} in |
1221 | case ${filetype} in |
| 1164 | *tar\ archive*) |
1222 | *tar\ archive*) |
| 1165 | eval ${exe} | tar --no-same-owner -xf - |
1223 | eval ${exe} | tar --no-same-owner -xf - |
| 1166 | ;; |
1224 | ;; |
| 1167 | bzip2*) |
1225 | bzip2*) |
| … | |
… | |
| 1212 | return 0 |
1270 | return 0 |
| 1213 | fi |
1271 | fi |
| 1214 | done |
1272 | done |
| 1215 | set +o noglob; set -$shopts #reset old shell opts |
1273 | set +o noglob; set -$shopts #reset old shell opts |
| 1216 | |
1274 | |
| 1217 | local licmsg="$(emktemp)" |
1275 | local licmsg=$(emktemp) |
| 1218 | cat << EOF > ${licmsg} |
1276 | cat <<-EOF > ${licmsg} |
| 1219 | ********************************************************** |
1277 | ********************************************************** |
| 1220 | The following license outlines the terms of use of this |
1278 | The following license outlines the terms of use of this |
| 1221 | package. You MUST accept this license for installation to |
1279 | package. You MUST accept this license for installation to |
| 1222 | continue. When you are done viewing, hit 'q'. If you |
1280 | continue. When you are done viewing, hit 'q'. If you |
| 1223 | CTRL+C out of this, the install will not run! |
1281 | CTRL+C out of this, the install will not run! |
| 1224 | ********************************************************** |
1282 | ********************************************************** |
| 1225 | |
1283 | |
| 1226 | EOF |
1284 | EOF |
| 1227 | cat ${lic} >> ${licmsg} |
1285 | cat ${lic} >> ${licmsg} |
| 1228 | ${PAGER:-less} ${licmsg} || die "Could not execute pager (${PAGER}) to accept ${lic}" |
1286 | ${PAGER:-less} ${licmsg} || die "Could not execute pager (${PAGER}) to accept ${lic}" |
| 1229 | einfon "Do you accept the terms of this license (${l})? [yes/no] " |
1287 | einfon "Do you accept the terms of this license (${l})? [yes/no] " |
| 1230 | read alic |
1288 | read alic |
| 1231 | case ${alic} in |
1289 | case ${alic} in |
| … | |
… | |
| 1400 | local dir=$(dirname ${cdset[${i}]}) |
1458 | local dir=$(dirname ${cdset[${i}]}) |
| 1401 | local file=$(basename ${cdset[${i}]}) |
1459 | local file=$(basename ${cdset[${i}]}) |
| 1402 | |
1460 | |
| 1403 | local point= node= fs= foo= |
1461 | local point= node= fs= foo= |
| 1404 | while read point node fs foo ; do |
1462 | while read point node fs foo ; do |
| 1405 | [[ " cd9660 iso9660 " != *" ${fs} "* ]] && \ |
1463 | [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && \ |
| 1406 | ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \ |
1464 | ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \ |
| 1407 | && continue |
1465 | && continue |
| 1408 | point=${point//\040/ } |
1466 | point=${point//\040/ } |
| 1409 | [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue |
1467 | [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue |
| 1410 | export CDROM_ROOT=${point} |
1468 | export CDROM_ROOT=${point} |
| … | |
… | |
| 1551 | # } |
1609 | # } |
| 1552 | |
1610 | |
| 1553 | preserve_old_lib() { |
1611 | preserve_old_lib() { |
| 1554 | if [[ ${EBUILD_PHASE} != "preinst" ]] ; then |
1612 | if [[ ${EBUILD_PHASE} != "preinst" ]] ; then |
| 1555 | eerror "preserve_old_lib() must be called from pkg_preinst() only" |
1613 | eerror "preserve_old_lib() must be called from pkg_preinst() only" |
| 1556 | # die "Invalid preserve_old_lib() usage" |
1614 | die "Invalid preserve_old_lib() usage" |
| 1557 | fi |
1615 | fi |
| 1558 | [[ -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]" |
| 1559 | |
1617 | |
| 1560 | local lib dir |
1618 | local lib dir |
| 1561 | for lib in "$@" ; do |
1619 | for lib in "$@" ; do |
| … | |
… | |
| 1568 | } |
1626 | } |
| 1569 | |
1627 | |
| 1570 | preserve_old_lib_notify() { |
1628 | preserve_old_lib_notify() { |
| 1571 | if [[ ${EBUILD_PHASE} != "postinst" ]] ; then |
1629 | if [[ ${EBUILD_PHASE} != "postinst" ]] ; then |
| 1572 | 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" |
| 1573 | # die "Invalid preserve_old_lib_notify() usage" |
1631 | die "Invalid preserve_old_lib_notify() usage" |
| 1574 | fi |
1632 | fi |
| 1575 | |
1633 | |
| 1576 | local lib notice=0 |
1634 | local lib notice=0 |
| 1577 | for lib in "$@" ; do |
1635 | for lib in "$@" ; do |
| 1578 | [[ -e ${ROOT}/${lib} ]] || continue |
1636 | [[ -e ${ROOT}/${lib} ]] || continue |
| … | |
… | |
| 1590 | } |
1648 | } |
| 1591 | |
1649 | |
| 1592 | # Hack for people to figure out if a package was built with |
1650 | # Hack for people to figure out if a package was built with |
| 1593 | # certain USE flags |
1651 | # certain USE flags |
| 1594 | # |
1652 | # |
| 1595 | # Usage: built_with_use [-a|-o] <DEPEND ATOM> <List of USE flags> |
1653 | # Usage: built_with_use [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags> |
| 1596 | # ex: built_with_use xchat gtk2 |
1654 | # ex: built_with_use xchat gtk2 |
| 1597 | # |
1655 | # |
| 1598 | # Flags: -a all USE flags should be utilized |
1656 | # Flags: -a all USE flags should be utilized |
| 1599 | # -o at least one USE flag should be utilized |
1657 | # -o at least one USE flag should be utilized |
|
|
1658 | # --missing peform the specified action if the flag is not in IUSE (true/false/die) |
|
|
1659 | # --hidden USE flag we're checking is hidden expanded so it isnt in IUSE |
| 1600 | # Note: the default flag is '-a' |
1660 | # Note: the default flag is '-a' |
| 1601 | built_with_use() { |
1661 | built_with_use() { |
|
|
1662 | local hidden="no" |
|
|
1663 | if [[ $1 == "--hidden" ]] ; then |
|
|
1664 | hidden="yes" |
|
|
1665 | shift |
|
|
1666 | fi |
|
|
1667 | |
|
|
1668 | local missing_action="die" |
|
|
1669 | if [[ $1 == "--missing" ]] ; then |
|
|
1670 | missing_action=$2 |
|
|
1671 | shift ; shift |
|
|
1672 | case ${missing_action} in |
|
|
1673 | true|false|die) ;; |
|
|
1674 | *) die "unknown action '${missing_action}'";; |
|
|
1675 | esac |
|
|
1676 | fi |
|
|
1677 | |
| 1602 | local opt=$1 |
1678 | local opt=$1 |
| 1603 | [[ ${opt:0:1} = "-" ]] && shift || opt="-a" |
1679 | [[ ${opt:0:1} = "-" ]] && shift || opt="-a" |
| 1604 | |
1680 | |
| 1605 | local PKG=$(best_version $1) |
1681 | local PKG=$(best_version $1) |
| 1606 | [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package" |
1682 | [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package" |
| 1607 | shift |
1683 | shift |
| 1608 | |
1684 | |
| 1609 | local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE |
1685 | local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE |
| 1610 | local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE |
1686 | local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE |
| 1611 | |
1687 | |
| 1612 | # if the USE file doesnt exist, assume the $PKG is either |
1688 | # if the IUSE file doesn't exist, the read will error out, we need to handle |
| 1613 | # injected or package.provided |
1689 | # this gracefully |
|
|
1690 | if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]] ; then |
|
|
1691 | case ${missing_action} in |
|
|
1692 | true) return 0;; |
|
|
1693 | false) return 1;; |
| 1614 | [[ ! -e ${USEFILE} ]] && die "Unable to determine what USE flags $PKG was built with" |
1694 | die) die "Unable to determine what USE flags $PKG was built with";; |
|
|
1695 | esac |
|
|
1696 | fi |
| 1615 | |
1697 | |
|
|
1698 | if [[ ${hidden} == "no" ]] ; then |
| 1616 | local IUSE_BUILT=$(<${IUSEFILE}) |
1699 | local IUSE_BUILT=$(<${IUSEFILE}) |
| 1617 | # Don't check USE_EXPAND #147237 |
1700 | # Don't check USE_EXPAND #147237 |
| 1618 | local expand |
1701 | local expand |
| 1619 | for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do |
1702 | for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do |
| 1620 | if [[ $1 == ${expand}_* ]] ; then |
1703 | if [[ $1 == ${expand}_* ]] ; then |
| 1621 | expand="" |
1704 | expand="" |
| 1622 | break |
1705 | break |
| 1623 | fi |
1706 | fi |
| 1624 | done |
1707 | done |
| 1625 | if [[ -n ${expand} ]] ; then |
1708 | if [[ -n ${expand} ]] ; then |
|
|
1709 | if ! has $1 ${IUSE_BUILT} ; then |
|
|
1710 | case ${missing_action} in |
|
|
1711 | true) return 0;; |
|
|
1712 | false) return 1;; |
| 1626 | has $1 ${IUSE_BUILT} || die "$PKG does not actually support the $1 USE flag!" |
1713 | die) die "$PKG does not actually support the $1 USE flag!";; |
|
|
1714 | esac |
|
|
1715 | fi |
|
|
1716 | fi |
| 1627 | fi |
1717 | fi |
| 1628 | |
1718 | |
| 1629 | local USE_BUILT=$(<${USEFILE}) |
1719 | local USE_BUILT=$(<${USEFILE}) |
| 1630 | while [[ $# -gt 0 ]] ; do |
1720 | while [[ $# -gt 0 ]] ; do |
| 1631 | if [[ ${opt} = "-o" ]] ; then |
1721 | if [[ ${opt} = "-o" ]] ; then |