| 1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2009 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.338 2010/03/07 02:52:25 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.349 2010/08/19 21:32:26 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: eutils.eclass |
5 | # @ECLASS: eutils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # base-system@gentoo.org |
7 | # base-system@gentoo.org |
| 8 | # @BLURB: many extra (but common) functions that are used in ebuilds |
8 | # @BLURB: many extra (but common) functions that are used in ebuilds |
| … | |
… | |
| 59 | |
59 | |
| 60 | epause() { |
60 | epause() { |
| 61 | ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org" |
61 | ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org" |
| 62 | } |
62 | } |
| 63 | |
63 | |
|
|
64 | fi |
|
|
65 | |
|
|
66 | # @FUNCTION: eqawarn |
|
|
67 | # @USAGE: [message] |
|
|
68 | # @DESCRIPTION: |
|
|
69 | # Proxy to einfo for package managers that don't provide eqawarn and use the PM |
|
|
70 | # implementation if available. |
|
|
71 | if ! declare -F eqawarn >/dev/null ; then |
|
|
72 | eqawarn() { |
|
|
73 | einfo "$@" |
|
|
74 | } |
| 64 | fi |
75 | fi |
| 65 | |
76 | |
| 66 | # @FUNCTION: ecvs_clean |
77 | # @FUNCTION: ecvs_clean |
| 67 | # @USAGE: [list of dirs] |
78 | # @USAGE: [list of dirs] |
| 68 | # @DESCRIPTION: |
79 | # @DESCRIPTION: |
| … | |
… | |
| 422 | EPATCH_SOURCE=${EPATCH_SOURCE} \ |
433 | EPATCH_SOURCE=${EPATCH_SOURCE} \ |
| 423 | EPATCH_SUFFIX="patch" \ |
434 | EPATCH_SUFFIX="patch" \ |
| 424 | EPATCH_FORCE="yes" \ |
435 | EPATCH_FORCE="yes" \ |
| 425 | EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." \ |
436 | EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." \ |
| 426 | epatch |
437 | epatch |
| 427 | break |
438 | return 0 |
| 428 | fi |
439 | fi |
| 429 | done |
440 | done |
|
|
441 | return 1 |
| 430 | } |
442 | } |
| 431 | |
443 | |
| 432 | # @FUNCTION: emktemp |
444 | # @FUNCTION: emktemp |
| 433 | # @USAGE: [temp dir] |
445 | # @USAGE: [temp dir] |
| 434 | # @DESCRIPTION: |
446 | # @DESCRIPTION: |
| … | |
… | |
| 706 | fi |
718 | fi |
| 707 | ;; |
719 | ;; |
| 708 | |
720 | |
| 709 | *) |
721 | *) |
| 710 | if [[ -z $@ ]] ; then |
722 | if [[ -z $@ ]] ; then |
| 711 | useradd ${opts} \ |
723 | useradd -r ${opts} \ |
| 712 | -c "added by portage for ${PN}" \ |
724 | -c "added by portage for ${PN}" \ |
| 713 | ${euser} \ |
725 | ${euser} \ |
| 714 | || die "enewuser failed" |
726 | || die "enewuser failed" |
| 715 | else |
727 | else |
| 716 | einfo " - Extra: $@" |
728 | einfo " - Extra: $@" |
| 717 | useradd ${opts} "$@" \ |
729 | useradd -r ${opts} "$@" \ |
| 718 | ${euser} \ |
730 | ${euser} \ |
| 719 | || die "enewuser failed" |
731 | || die "enewuser failed" |
| 720 | fi |
732 | fi |
| 721 | ;; |
733 | ;; |
| 722 | esac |
734 | esac |
| … | |
… | |
| 835 | esac |
847 | esac |
| 836 | groupadd -g ${egid} ${egroup} || die "enewgroup failed" |
848 | groupadd -g ${egid} ${egroup} || die "enewgroup failed" |
| 837 | ;; |
849 | ;; |
| 838 | |
850 | |
| 839 | *) |
851 | *) |
|
|
852 | # We specify -r so that we get a GID in the system range from login.defs |
| 840 | groupadd ${opts} ${egroup} || die "enewgroup failed" |
853 | groupadd -r ${opts} ${egroup} || die "enewgroup failed" |
| 841 | ;; |
854 | ;; |
| 842 | esac |
855 | esac |
| 843 | export SANDBOX_ON="${oldsandbox}" |
856 | export SANDBOX_ON="${oldsandbox}" |
| 844 | } |
857 | } |
| 845 | |
858 | |
| … | |
… | |
| 856 | |
869 | |
| 857 | # Make a desktop file ! |
870 | # Make a desktop file ! |
| 858 | # Great for making those icons in kde/gnome startmenu ! |
871 | # Great for making those icons in kde/gnome startmenu ! |
| 859 | # Amaze your friends ! Get the women ! Join today ! |
872 | # Amaze your friends ! Get the women ! Join today ! |
| 860 | # |
873 | # |
| 861 | # make_desktop_entry(<command>, [name], [icon], [type], [path]) |
874 | # make_desktop_entry(<command>, [name], [icon], [type], [fields]) |
| 862 | # |
875 | # |
| 863 | # binary: what command does the app run with ? |
876 | # binary: what command does the app run with ? |
| 864 | # name: the name that will show up in the menu |
877 | # name: the name that will show up in the menu |
| 865 | # icon: give your little like a pretty little icon ... |
878 | # icon: give your little like a pretty little icon ... |
| 866 | # this can be relative (to /usr/share/pixmaps) or |
879 | # this can be relative (to /usr/share/pixmaps) or |
| 867 | # a full path to an icon |
880 | # a full path to an icon |
| 868 | # type: what kind of application is this ? for categories: |
881 | # type: what kind of application is this ? for categories: |
| 869 | # http://standards.freedesktop.org/menu-spec/latest/apa.html |
882 | # http://standards.freedesktop.org/menu-spec/latest/apa.html |
| 870 | # path: if your app needs to startup in a specific dir |
883 | # fields: extra fields to append to the desktop file; a printf string |
| 871 | make_desktop_entry() { |
884 | make_desktop_entry() { |
| 872 | [[ -z $1 ]] && eerror "make_desktop_entry: You must specify the executable" && return 1 |
885 | [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable" |
| 873 | |
886 | |
| 874 | local exec=${1} |
887 | local exec=${1} |
| 875 | local name=${2:-${PN}} |
888 | local name=${2:-${PN}} |
| 876 | local icon=${3:-${PN}} |
889 | local icon=${3:-${PN}} |
| 877 | local type=${4} |
890 | local type=${4} |
| 878 | local path=${5} |
891 | local fields=${5} |
| 879 | |
892 | |
| 880 | if [[ -z ${type} ]] ; then |
893 | if [[ -z ${type} ]] ; then |
| 881 | local catmaj=${CATEGORY%%-*} |
894 | local catmaj=${CATEGORY%%-*} |
| 882 | local catmin=${CATEGORY##*-} |
895 | local catmin=${CATEGORY##*-} |
| 883 | case ${catmaj} in |
896 | case ${catmaj} in |
| … | |
… | |
| 935 | type="Network;Email" |
948 | type="Network;Email" |
| 936 | ;; |
949 | ;; |
| 937 | |
950 | |
| 938 | media) |
951 | media) |
| 939 | case ${catmin} in |
952 | case ${catmin} in |
|
|
953 | gfx) |
| 940 | gfx) type=Graphics;; |
954 | type=Graphics |
|
|
955 | ;; |
|
|
956 | *) |
|
|
957 | case ${catmin} in |
| 941 | radio) type=Tuner;; |
958 | radio) type=Tuner;; |
| 942 | sound) type=Audio;; |
959 | sound) type=Audio;; |
| 943 | tv) type=TV;; |
960 | tv) type=TV;; |
| 944 | video) type=Video;; |
961 | video) type=Video;; |
|
|
962 | esac |
|
|
963 | type="AudioVideo;${type}" |
|
|
964 | ;; |
| 945 | esac |
965 | esac |
| 946 | type="AudioVideo;${type}" |
|
|
| 947 | ;; |
966 | ;; |
| 948 | |
967 | |
| 949 | net) |
968 | net) |
| 950 | case ${catmin} in |
969 | case ${catmin} in |
| 951 | dialup) type=Dialup;; |
970 | dialup) type=Dialup;; |
| … | |
… | |
| 1020 | TryExec=${exec%% *} |
1039 | TryExec=${exec%% *} |
| 1021 | Icon=${icon} |
1040 | Icon=${icon} |
| 1022 | Categories=${type} |
1041 | Categories=${type} |
| 1023 | EOF |
1042 | EOF |
| 1024 | |
1043 | |
| 1025 | [[ ${path} ]] && echo "Path=${path}" >> "${desktop}" |
1044 | if [[ ${fields:-=} != *=* ]] ; then |
|
|
1045 | # 5th arg used to be value to Path= |
|
|
1046 | ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}" |
|
|
1047 | fields="Path=${fields}" |
|
|
1048 | fi |
|
|
1049 | [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}" |
| 1026 | |
1050 | |
| 1027 | ( |
1051 | ( |
| 1028 | # wrap the env here so that the 'insinto' call |
1052 | # wrap the env here so that the 'insinto' call |
| 1029 | # doesn't corrupt the env of the caller |
1053 | # doesn't corrupt the env of the caller |
| 1030 | insinto /usr/share/applications |
1054 | insinto /usr/share/applications |
| 1031 | doins "${desktop}" |
1055 | doins "${desktop}" |
| 1032 | ) |
1056 | ) || die "installing desktop file failed" |
| 1033 | } |
1057 | } |
| 1034 | |
1058 | |
| 1035 | # @FUNCTION: validate_desktop_entries |
1059 | # @FUNCTION: validate_desktop_entries |
| 1036 | # @USAGE: [directories] |
1060 | # @USAGE: [directories] |
| 1037 | # @MAINTAINER: |
1061 | # @MAINTAINER: |
| … | |
… | |
| 1316 | [[ -z ${src} ]] && die "Could not locate source for '${src_input}'" |
1340 | [[ -z ${src} ]] && die "Could not locate source for '${src_input}'" |
| 1317 | |
1341 | |
| 1318 | local shrtsrc=$(basename "${src}") |
1342 | local shrtsrc=$(basename "${src}") |
| 1319 | echo ">>> Unpacking ${shrtsrc} to ${PWD}" |
1343 | echo ">>> Unpacking ${shrtsrc} to ${PWD}" |
| 1320 | if [[ -z ${skip} ]] ; then |
1344 | if [[ -z ${skip} ]] ; then |
| 1321 | local ver=$(grep -a '#.*Makeself' "${src}" | awk '{print $NF}') |
1345 | local ver=$(grep -m1 -a '#.*Makeself' "${src}" | awk '{print $NF}') |
| 1322 | local skip=0 |
1346 | local skip=0 |
| 1323 | exe=tail |
1347 | exe=tail |
| 1324 | case ${ver} in |
1348 | case ${ver} in |
| 1325 | 1.5.*|1.6.0-nv) # tested 1.5.{3,4,5} ... guessing 1.5.x series is same |
1349 | 1.5.*|1.6.0-nv) # tested 1.5.{3,4,5} ... guessing 1.5.x series is same |
| 1326 | skip=$(grep -a ^skip= "${src}" | cut -d= -f2) |
1350 | skip=$(grep -a ^skip= "${src}" | cut -d= -f2) |
| … | |
… | |
| 1328 | 2.0|2.0.1) |
1352 | 2.0|2.0.1) |
| 1329 | skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-) |
1353 | skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-) |
| 1330 | ;; |
1354 | ;; |
| 1331 | 2.1.1) |
1355 | 2.1.1) |
| 1332 | skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-) |
1356 | skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-) |
| 1333 | let skip="skip + 1" |
1357 | (( skip++ )) |
| 1334 | ;; |
1358 | ;; |
| 1335 | 2.1.2) |
1359 | 2.1.2) |
| 1336 | skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1) |
1360 | skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1) |
| 1337 | let skip="skip + 1" |
1361 | (( skip++ )) |
| 1338 | ;; |
1362 | ;; |
| 1339 | 2.1.3) |
1363 | 2.1.3) |
| 1340 | skip=`grep -a ^offset= "${src}" | awk '{print $3}'` |
1364 | skip=`grep -a ^offset= "${src}" | awk '{print $3}'` |
| 1341 | let skip="skip + 1" |
1365 | (( skip++ )) |
| 1342 | ;; |
1366 | ;; |
| 1343 | 2.1.4|2.1.5) |
1367 | 2.1.4|2.1.5) |
| 1344 | skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1) |
1368 | skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1) |
| 1345 | skip=$(head -n ${skip} "${src}" | wc -c) |
1369 | skip=$(head -n ${skip} "${src}" | wc -c) |
| 1346 | exe="dd" |
1370 | exe="dd" |
| … | |
… | |
| 1355 | esac |
1379 | esac |
| 1356 | debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" |
1380 | debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" |
| 1357 | fi |
1381 | fi |
| 1358 | case ${exe} in |
1382 | case ${exe} in |
| 1359 | tail) exe="tail -n +${skip} '${src}'";; |
1383 | tail) exe="tail -n +${skip} '${src}'";; |
| 1360 | dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; |
1384 | dd) exe="dd ibs=${skip} skip=1 if='${src}'";; |
| 1361 | *) die "makeself cant handle exe '${exe}'" |
1385 | *) die "makeself cant handle exe '${exe}'" |
| 1362 | esac |
1386 | esac |
| 1363 | |
1387 | |
| 1364 | # lets grab the first few bytes of the file to figure out what kind of archive it is |
1388 | # lets grab the first few bytes of the file to figure out what kind of archive it is |
| 1365 | local tmpfile=$(emktemp) |
1389 | local tmpfile=$(emktemp) |
| … | |
… | |
| 1498 | export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}} |
1522 | export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}} |
| 1499 | einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" |
1523 | einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" |
| 1500 | export CDROM_SET=-1 |
1524 | export CDROM_SET=-1 |
| 1501 | for f in ${CDROM_CHECK_1//:/ } ; do |
1525 | for f in ${CDROM_CHECK_1//:/ } ; do |
| 1502 | ((++CDROM_SET)) |
1526 | ((++CDROM_SET)) |
| 1503 | [[ -e ${CD_ROOT}/${f} ]] && break |
1527 | [[ -e ${CDROM_ROOT}/${f} ]] && break |
| 1504 | done |
1528 | done |
| 1505 | export CDROM_MATCH=${f} |
1529 | export CDROM_MATCH=${f} |
| 1506 | return |
1530 | return |
| 1507 | fi |
1531 | fi |
| 1508 | |
1532 | |