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.334 2010/02/26 03:15:26 abcd 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 |
… | |
… | |
52 | } |
52 | } |
53 | |
53 | |
54 | else |
54 | else |
55 | |
55 | |
56 | ebeep() { |
56 | ebeep() { |
57 | [[ $(type -t eqawarn) == function ]] && \ |
|
|
58 | eqawarn "QA Notice: ebeep is not defined in EAPI=3, please file a bug at http://bugs.gentoo.org" |
57 | ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org" |
59 | } |
58 | } |
60 | |
59 | |
61 | epause() { |
60 | epause() { |
62 | [[ $(type -t eqawarn) == function ]] && \ |
|
|
63 | eqawarn "QA Notice: epause is not defined in EAPI=3, 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" |
64 | } |
62 | } |
65 | |
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 | } |
66 | fi |
75 | fi |
67 | |
76 | |
68 | # @FUNCTION: ecvs_clean |
77 | # @FUNCTION: ecvs_clean |
69 | # @USAGE: [list of dirs] |
78 | # @USAGE: [list of dirs] |
70 | # @DESCRIPTION: |
79 | # @DESCRIPTION: |
… | |
… | |
424 | EPATCH_SOURCE=${EPATCH_SOURCE} \ |
433 | EPATCH_SOURCE=${EPATCH_SOURCE} \ |
425 | EPATCH_SUFFIX="patch" \ |
434 | EPATCH_SUFFIX="patch" \ |
426 | EPATCH_FORCE="yes" \ |
435 | EPATCH_FORCE="yes" \ |
427 | EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." \ |
436 | EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." \ |
428 | epatch |
437 | epatch |
429 | break |
438 | return 0 |
430 | fi |
439 | fi |
431 | done |
440 | done |
|
|
441 | return 1 |
432 | } |
442 | } |
433 | |
443 | |
434 | # @FUNCTION: emktemp |
444 | # @FUNCTION: emktemp |
435 | # @USAGE: [temp dir] |
445 | # @USAGE: [temp dir] |
436 | # @DESCRIPTION: |
446 | # @DESCRIPTION: |
… | |
… | |
708 | fi |
718 | fi |
709 | ;; |
719 | ;; |
710 | |
720 | |
711 | *) |
721 | *) |
712 | if [[ -z $@ ]] ; then |
722 | if [[ -z $@ ]] ; then |
713 | useradd ${opts} \ |
723 | useradd -r ${opts} \ |
714 | -c "added by portage for ${PN}" \ |
724 | -c "added by portage for ${PN}" \ |
715 | ${euser} \ |
725 | ${euser} \ |
716 | || die "enewuser failed" |
726 | || die "enewuser failed" |
717 | else |
727 | else |
718 | einfo " - Extra: $@" |
728 | einfo " - Extra: $@" |
719 | useradd ${opts} "$@" \ |
729 | useradd -r ${opts} "$@" \ |
720 | ${euser} \ |
730 | ${euser} \ |
721 | || die "enewuser failed" |
731 | || die "enewuser failed" |
722 | fi |
732 | fi |
723 | ;; |
733 | ;; |
724 | esac |
734 | esac |
… | |
… | |
837 | esac |
847 | esac |
838 | groupadd -g ${egid} ${egroup} || die "enewgroup failed" |
848 | groupadd -g ${egid} ${egroup} || die "enewgroup failed" |
839 | ;; |
849 | ;; |
840 | |
850 | |
841 | *) |
851 | *) |
|
|
852 | # We specify -r so that we get a GID in the system range from login.defs |
842 | groupadd ${opts} ${egroup} || die "enewgroup failed" |
853 | groupadd -r ${opts} ${egroup} || die "enewgroup failed" |
843 | ;; |
854 | ;; |
844 | esac |
855 | esac |
845 | export SANDBOX_ON="${oldsandbox}" |
856 | export SANDBOX_ON="${oldsandbox}" |
846 | } |
857 | } |
847 | |
858 | |
… | |
… | |
858 | |
869 | |
859 | # Make a desktop file ! |
870 | # Make a desktop file ! |
860 | # Great for making those icons in kde/gnome startmenu ! |
871 | # Great for making those icons in kde/gnome startmenu ! |
861 | # Amaze your friends ! Get the women ! Join today ! |
872 | # Amaze your friends ! Get the women ! Join today ! |
862 | # |
873 | # |
863 | # make_desktop_entry(<command>, [name], [icon], [type], [path]) |
874 | # make_desktop_entry(<command>, [name], [icon], [type], [fields]) |
864 | # |
875 | # |
865 | # binary: what command does the app run with ? |
876 | # binary: what command does the app run with ? |
866 | # name: the name that will show up in the menu |
877 | # name: the name that will show up in the menu |
867 | # icon: give your little like a pretty little icon ... |
878 | # icon: give your little like a pretty little icon ... |
868 | # this can be relative (to /usr/share/pixmaps) or |
879 | # this can be relative (to /usr/share/pixmaps) or |
869 | # a full path to an icon |
880 | # a full path to an icon |
870 | # type: what kind of application is this ? for categories: |
881 | # type: what kind of application is this ? for categories: |
871 | # http://standards.freedesktop.org/menu-spec/latest/apa.html |
882 | # http://standards.freedesktop.org/menu-spec/latest/apa.html |
872 | # path: if your app needs to startup in a specific dir |
883 | # fields: extra fields to append to the desktop file; a printf string |
873 | make_desktop_entry() { |
884 | make_desktop_entry() { |
874 | [[ -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" |
875 | |
886 | |
876 | local exec=${1} |
887 | local exec=${1} |
877 | local name=${2:-${PN}} |
888 | local name=${2:-${PN}} |
878 | local icon=${3:-${PN}} |
889 | local icon=${3:-${PN}} |
879 | local type=${4} |
890 | local type=${4} |
880 | local path=${5} |
891 | local fields=${5} |
881 | |
892 | |
882 | if [[ -z ${type} ]] ; then |
893 | if [[ -z ${type} ]] ; then |
883 | local catmaj=${CATEGORY%%-*} |
894 | local catmaj=${CATEGORY%%-*} |
884 | local catmin=${CATEGORY##*-} |
895 | local catmin=${CATEGORY##*-} |
885 | case ${catmaj} in |
896 | case ${catmaj} in |
886 | app) |
897 | app) |
887 | case ${catmin} in |
898 | case ${catmin} in |
888 | accessibility) type=Accessibility;; |
899 | accessibility) type=Accessibility;; |
889 | admin) type=System;; |
900 | admin) type=System;; |
890 | antivirus) type=System;; |
901 | antivirus) type=System;; |
891 | arch) type=Archiving;; |
902 | arch) type=Archiving;; |
892 | backup) type=Archiving;; |
903 | backup) type=Archiving;; |
893 | cdr) type=DiscBurning;; |
904 | cdr) type=DiscBurning;; |
894 | dicts) type=Dictionary;; |
905 | dicts) type=Dictionary;; |
895 | doc) type=Documentation;; |
906 | doc) type=Documentation;; |
896 | editors) type=TextEditor;; |
907 | editors) type=TextEditor;; |
897 | emacs) type=TextEditor;; |
908 | emacs) type=TextEditor;; |
898 | emulation) type=Emulator;; |
909 | emulation) type=Emulator;; |
899 | laptop) type=HardwareSettings;; |
910 | laptop) type=HardwareSettings;; |
900 | office) type=Office;; |
911 | office) type=Office;; |
901 | pda) type=PDA;; |
912 | pda) type=PDA;; |
902 | vim) type=TextEditor;; |
913 | vim) type=TextEditor;; |
903 | xemacs) type=TextEditor;; |
914 | xemacs) type=TextEditor;; |
904 | *) type=;; |
|
|
905 | esac |
915 | esac |
906 | ;; |
916 | ;; |
907 | |
917 | |
908 | dev) |
918 | dev) |
909 | type="Development" |
919 | type="Development" |
910 | ;; |
920 | ;; |
911 | |
921 | |
912 | games) |
922 | games) |
913 | case ${catmin} in |
923 | case ${catmin} in |
914 | action|fps) type=ActionGame;; |
924 | action|fps) type=ActionGame;; |
915 | arcade) type=ArcadeGame;; |
925 | arcade) type=ArcadeGame;; |
916 | board) type=BoardGame;; |
926 | board) type=BoardGame;; |
917 | emulation) type=Emulator;; |
927 | emulation) type=Emulator;; |
918 | kids) type=KidsGame;; |
928 | kids) type=KidsGame;; |
919 | puzzle) type=LogicGame;; |
929 | puzzle) type=LogicGame;; |
920 | roguelike) type=RolePlaying;; |
930 | roguelike) type=RolePlaying;; |
921 | rpg) type=RolePlaying;; |
931 | rpg) type=RolePlaying;; |
922 | simulation) type=Simulation;; |
932 | simulation) type=Simulation;; |
923 | sports) type=SportsGame;; |
933 | sports) type=SportsGame;; |
924 | strategy) type=StrategyGame;; |
934 | strategy) type=StrategyGame;; |
925 | *) type=;; |
|
|
926 | esac |
935 | esac |
927 | type="Game;${type}" |
936 | type="Game;${type}" |
928 | ;; |
937 | ;; |
929 | |
938 | |
930 | gnome) |
939 | gnome) |
… | |
… | |
939 | type="Network;Email" |
948 | type="Network;Email" |
940 | ;; |
949 | ;; |
941 | |
950 | |
942 | media) |
951 | media) |
943 | case ${catmin} in |
952 | case ${catmin} in |
|
|
953 | gfx) |
944 | gfx) type=Graphics;; |
954 | type=Graphics |
|
|
955 | ;; |
|
|
956 | *) |
|
|
957 | case ${catmin} in |
945 | radio) type=Tuner;; |
958 | radio) type=Tuner;; |
946 | sound) type=Audio;; |
959 | sound) type=Audio;; |
947 | tv) type=TV;; |
960 | tv) type=TV;; |
948 | video) type=Video;; |
961 | video) type=Video;; |
949 | *) type=;; |
962 | esac |
|
|
963 | type="AudioVideo;${type}" |
|
|
964 | ;; |
950 | esac |
965 | esac |
951 | type="AudioVideo;${type}" |
|
|
952 | ;; |
966 | ;; |
953 | |
967 | |
954 | net) |
968 | net) |
955 | case ${catmin} in |
969 | case ${catmin} in |
956 | dialup) type=Dialup;; |
970 | dialup) type=Dialup;; |
957 | ftp) type=FileTransfer;; |
971 | ftp) type=FileTransfer;; |
958 | im) type=InstantMessaging;; |
972 | im) type=InstantMessaging;; |
959 | irc) type=IRCClient;; |
973 | irc) type=IRCClient;; |
960 | mail) type=Email;; |
974 | mail) type=Email;; |
961 | news) type=News;; |
975 | news) type=News;; |
962 | nntp) type=News;; |
976 | nntp) type=News;; |
963 | p2p) type=FileTransfer;; |
977 | p2p) type=FileTransfer;; |
964 | voip) type=Telephony;; |
978 | voip) type=Telephony;; |
965 | *) type=;; |
|
|
966 | esac |
979 | esac |
967 | type="Network;${type}" |
980 | type="Network;${type}" |
968 | ;; |
981 | ;; |
969 | |
982 | |
970 | sci) |
983 | sci) |
971 | case ${catmin} in |
984 | case ${catmin} in |
972 | astro*) type=Astronomy;; |
985 | astro*) type=Astronomy;; |
973 | bio*) type=Biology;; |
986 | bio*) type=Biology;; |
974 | calc*) type=Calculator;; |
987 | calc*) type=Calculator;; |
975 | chem*) type=Chemistry;; |
988 | chem*) type=Chemistry;; |
976 | elec*) type=Electronics;; |
989 | elec*) type=Electronics;; |
977 | geo*) type=Geology;; |
990 | geo*) type=Geology;; |
978 | math*) type=Math;; |
991 | math*) type=Math;; |
979 | physics) type=Physics;; |
992 | physics) type=Physics;; |
980 | visual*) type=DataVisualization;; |
993 | visual*) type=DataVisualization;; |
981 | *) type=;; |
|
|
982 | esac |
994 | esac |
983 | type="Education;Science;${type}" |
995 | type="Education;Science;${type}" |
984 | ;; |
996 | ;; |
985 | |
997 | |
986 | sys) |
998 | sys) |
… | |
… | |
988 | ;; |
1000 | ;; |
989 | |
1001 | |
990 | www) |
1002 | www) |
991 | case ${catmin} in |
1003 | case ${catmin} in |
992 | client) type=WebBrowser;; |
1004 | client) type=WebBrowser;; |
993 | *) type=;; |
|
|
994 | esac |
1005 | esac |
995 | type="Network;${type}" |
1006 | type="Network;${type}" |
996 | ;; |
1007 | ;; |
997 | |
1008 | |
998 | *) |
1009 | *) |
… | |
… | |
1010 | |
1021 | |
1011 | # Don't append another ";" when a valid category value is provided. |
1022 | # Don't append another ";" when a valid category value is provided. |
1012 | type=${type%;}${type:+;} |
1023 | type=${type%;}${type:+;} |
1013 | |
1024 | |
1014 | eshopts_push -s extglob |
1025 | eshopts_push -s extglob |
1015 | if [[ -n ${icon} && ${icon} != /* && ${icon} == *.@(xpm|png|svg) ]]; then |
1026 | if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then |
1016 | ewarn "As described in the Icon Theme Specification, icon file extensions are not" |
1027 | ewarn "As described in the Icon Theme Specification, icon file extensions are not" |
1017 | ewarn "allowed in .desktop files if the value is not an absolute path." |
1028 | ewarn "allowed in .desktop files if the value is not an absolute path." |
1018 | icon=${icon%.@(xpm|png|svg)} |
1029 | icon=${icon%.@(xpm|png|svg)} |
1019 | fi |
1030 | fi |
1020 | eshopts_pop |
1031 | eshopts_pop |
… | |
… | |
1028 | TryExec=${exec%% *} |
1039 | TryExec=${exec%% *} |
1029 | Icon=${icon} |
1040 | Icon=${icon} |
1030 | Categories=${type} |
1041 | Categories=${type} |
1031 | EOF |
1042 | EOF |
1032 | |
1043 | |
1033 | [[ ${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}" |
1034 | |
1050 | |
1035 | ( |
1051 | ( |
1036 | # wrap the env here so that the 'insinto' call |
1052 | # wrap the env here so that the 'insinto' call |
1037 | # doesn't corrupt the env of the caller |
1053 | # doesn't corrupt the env of the caller |
1038 | insinto /usr/share/applications |
1054 | insinto /usr/share/applications |
1039 | doins "${desktop}" |
1055 | doins "${desktop}" |
1040 | ) |
1056 | ) || die "installing desktop file failed" |
1041 | } |
1057 | } |
1042 | |
1058 | |
1043 | # @FUNCTION: validate_desktop_entries |
1059 | # @FUNCTION: validate_desktop_entries |
1044 | # @USAGE: [directories] |
1060 | # @USAGE: [directories] |
1045 | # @MAINTAINER: |
1061 | # @MAINTAINER: |
… | |
… | |
1324 | [[ -z ${src} ]] && die "Could not locate source for '${src_input}'" |
1340 | [[ -z ${src} ]] && die "Could not locate source for '${src_input}'" |
1325 | |
1341 | |
1326 | local shrtsrc=$(basename "${src}") |
1342 | local shrtsrc=$(basename "${src}") |
1327 | echo ">>> Unpacking ${shrtsrc} to ${PWD}" |
1343 | echo ">>> Unpacking ${shrtsrc} to ${PWD}" |
1328 | if [[ -z ${skip} ]] ; then |
1344 | if [[ -z ${skip} ]] ; then |
1329 | local ver=$(grep -a '#.*Makeself' "${src}" | awk '{print $NF}') |
1345 | local ver=$(grep -m1 -a '#.*Makeself' "${src}" | awk '{print $NF}') |
1330 | local skip=0 |
1346 | local skip=0 |
1331 | exe=tail |
1347 | exe=tail |
1332 | case ${ver} in |
1348 | case ${ver} in |
1333 | 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 |
1334 | skip=$(grep -a ^skip= "${src}" | cut -d= -f2) |
1350 | skip=$(grep -a ^skip= "${src}" | cut -d= -f2) |
… | |
… | |
1336 | 2.0|2.0.1) |
1352 | 2.0|2.0.1) |
1337 | skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-) |
1353 | skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-) |
1338 | ;; |
1354 | ;; |
1339 | 2.1.1) |
1355 | 2.1.1) |
1340 | skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-) |
1356 | skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-) |
1341 | let skip="skip + 1" |
1357 | (( skip++ )) |
1342 | ;; |
1358 | ;; |
1343 | 2.1.2) |
1359 | 2.1.2) |
1344 | skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1) |
1360 | skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1) |
1345 | let skip="skip + 1" |
1361 | (( skip++ )) |
1346 | ;; |
1362 | ;; |
1347 | 2.1.3) |
1363 | 2.1.3) |
1348 | skip=`grep -a ^offset= "${src}" | awk '{print $3}'` |
1364 | skip=`grep -a ^offset= "${src}" | awk '{print $3}'` |
1349 | let skip="skip + 1" |
1365 | (( skip++ )) |
1350 | ;; |
1366 | ;; |
1351 | 2.1.4|2.1.5) |
1367 | 2.1.4|2.1.5) |
1352 | 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) |
1353 | skip=$(head -n ${skip} "${src}" | wc -c) |
1369 | skip=$(head -n ${skip} "${src}" | wc -c) |
1354 | exe="dd" |
1370 | exe="dd" |
… | |
… | |
1363 | esac |
1379 | esac |
1364 | debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" |
1380 | debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" |
1365 | fi |
1381 | fi |
1366 | case ${exe} in |
1382 | case ${exe} in |
1367 | tail) exe="tail -n +${skip} '${src}'";; |
1383 | tail) exe="tail -n +${skip} '${src}'";; |
1368 | dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; |
1384 | dd) exe="dd ibs=${skip} skip=1 if='${src}'";; |
1369 | *) die "makeself cant handle exe '${exe}'" |
1385 | *) die "makeself cant handle exe '${exe}'" |
1370 | esac |
1386 | esac |
1371 | |
1387 | |
1372 | # 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 |
1373 | local tmpfile=$(emktemp) |
1389 | local tmpfile=$(emktemp) |
… | |
… | |
1506 | export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}} |
1522 | export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}} |
1507 | einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" |
1523 | einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" |
1508 | export CDROM_SET=-1 |
1524 | export CDROM_SET=-1 |
1509 | for f in ${CDROM_CHECK_1//:/ } ; do |
1525 | for f in ${CDROM_CHECK_1//:/ } ; do |
1510 | ((++CDROM_SET)) |
1526 | ((++CDROM_SET)) |
1511 | [[ -e ${CD_ROOT}/${f} ]] && break |
1527 | [[ -e ${CDROM_ROOT}/${f} ]] && break |
1512 | done |
1528 | done |
1513 | export CDROM_MATCH=${f} |
1529 | export CDROM_MATCH=${f} |
1514 | return |
1530 | return |
1515 | fi |
1531 | fi |
1516 | |
1532 | |