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

Diff of /eclass/eutils.eclass

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

Revision 1.335 Revision 1.344
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.335 2010/02/26 05:17:24 halcy0n Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.344 2010/05/20 02:21:17 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
54else 54else
55 55
56ebeep() { 56ebeep() {
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
61epause() { 60epause() {
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
66fi 64fi
67 65
68# @FUNCTION: ecvs_clean 66# @FUNCTION: ecvs_clean
858 856
859# Make a desktop file ! 857# Make a desktop file !
860# Great for making those icons in kde/gnome startmenu ! 858# Great for making those icons in kde/gnome startmenu !
861# Amaze your friends ! Get the women ! Join today ! 859# Amaze your friends ! Get the women ! Join today !
862# 860#
863# make_desktop_entry(<command>, [name], [icon], [type], [path]) 861# make_desktop_entry(<command>, [name], [icon], [type], [fields])
864# 862#
865# binary: what command does the app run with ? 863# binary: what command does the app run with ?
866# name: the name that will show up in the menu 864# name: the name that will show up in the menu
867# icon: give your little like a pretty little icon ... 865# icon: give your little like a pretty little icon ...
868# this can be relative (to /usr/share/pixmaps) or 866# this can be relative (to /usr/share/pixmaps) or
869# a full path to an icon 867# a full path to an icon
870# type: what kind of application is this ? for categories: 868# type: what kind of application is this ? for categories:
871# http://standards.freedesktop.org/menu-spec/latest/apa.html 869# http://standards.freedesktop.org/menu-spec/latest/apa.html
872# path: if your app needs to startup in a specific dir 870# fields: extra fields to append to the desktop file; a printf string
873make_desktop_entry() { 871make_desktop_entry() {
874 [[ -z $1 ]] && eerror "make_desktop_entry: You must specify the executable" && return 1 872 [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable"
875 873
876 local exec=${1} 874 local exec=${1}
877 local name=${2:-${PN}} 875 local name=${2:-${PN}}
878 local icon=${3:-${PN}} 876 local icon=${3:-${PN}}
879 local type=${4} 877 local type=${4}
880 local path=${5} 878 local fields=${5}
881 879
882 if [[ -z ${type} ]] ; then 880 if [[ -z ${type} ]] ; then
883 local catmaj=${CATEGORY%%-*} 881 local catmaj=${CATEGORY%%-*}
884 local catmin=${CATEGORY##*-} 882 local catmin=${CATEGORY##*-}
885 case ${catmaj} in 883 case ${catmaj} in
886 app) 884 app)
887 case ${catmin} in 885 case ${catmin} in
888 accessibility) type=Accessibility;; 886 accessibility) type=Accessibility;;
889 admin) type=System;; 887 admin) type=System;;
890 antivirus) type=System;; 888 antivirus) type=System;;
891 arch) type=Archiving;; 889 arch) type=Archiving;;
892 backup) type=Archiving;; 890 backup) type=Archiving;;
893 cdr) type=DiscBurning;; 891 cdr) type=DiscBurning;;
894 dicts) type=Dictionary;; 892 dicts) type=Dictionary;;
895 doc) type=Documentation;; 893 doc) type=Documentation;;
896 editors) type=TextEditor;; 894 editors) type=TextEditor;;
897 emacs) type=TextEditor;; 895 emacs) type=TextEditor;;
898 emulation) type=Emulator;; 896 emulation) type=Emulator;;
899 laptop) type=HardwareSettings;; 897 laptop) type=HardwareSettings;;
900 office) type=Office;; 898 office) type=Office;;
901 pda) type=PDA;; 899 pda) type=PDA;;
902 vim) type=TextEditor;; 900 vim) type=TextEditor;;
903 xemacs) type=TextEditor;; 901 xemacs) type=TextEditor;;
904 *) type=;;
905 esac 902 esac
906 ;; 903 ;;
907 904
908 dev) 905 dev)
909 type="Development" 906 type="Development"
910 ;; 907 ;;
911 908
912 games) 909 games)
913 case ${catmin} in 910 case ${catmin} in
914 action|fps) type=ActionGame;; 911 action|fps) type=ActionGame;;
915 arcade) type=ArcadeGame;; 912 arcade) type=ArcadeGame;;
916 board) type=BoardGame;; 913 board) type=BoardGame;;
917 emulation) type=Emulator;; 914 emulation) type=Emulator;;
918 kids) type=KidsGame;; 915 kids) type=KidsGame;;
919 puzzle) type=LogicGame;; 916 puzzle) type=LogicGame;;
920 roguelike) type=RolePlaying;; 917 roguelike) type=RolePlaying;;
921 rpg) type=RolePlaying;; 918 rpg) type=RolePlaying;;
922 simulation) type=Simulation;; 919 simulation) type=Simulation;;
923 sports) type=SportsGame;; 920 sports) type=SportsGame;;
924 strategy) type=StrategyGame;; 921 strategy) type=StrategyGame;;
925 *) type=;;
926 esac 922 esac
927 type="Game;${type}" 923 type="Game;${type}"
928 ;; 924 ;;
929 925
930 gnome) 926 gnome)
939 type="Network;Email" 935 type="Network;Email"
940 ;; 936 ;;
941 937
942 media) 938 media)
943 case ${catmin} in 939 case ${catmin} in
940 gfx)
944 gfx) type=Graphics;; 941 type=Graphics
942 ;;
943 *)
944 case ${catmin} in
945 radio) type=Tuner;; 945 radio) type=Tuner;;
946 sound) type=Audio;; 946 sound) type=Audio;;
947 tv) type=TV;; 947 tv) type=TV;;
948 video) type=Video;; 948 video) type=Video;;
949 *) type=;; 949 esac
950 type="AudioVideo;${type}"
951 ;;
950 esac 952 esac
951 type="AudioVideo;${type}"
952 ;; 953 ;;
953 954
954 net) 955 net)
955 case ${catmin} in 956 case ${catmin} in
956 dialup) type=Dialup;; 957 dialup) type=Dialup;;
957 ftp) type=FileTransfer;; 958 ftp) type=FileTransfer;;
958 im) type=InstantMessaging;; 959 im) type=InstantMessaging;;
959 irc) type=IRCClient;; 960 irc) type=IRCClient;;
960 mail) type=Email;; 961 mail) type=Email;;
961 news) type=News;; 962 news) type=News;;
962 nntp) type=News;; 963 nntp) type=News;;
963 p2p) type=FileTransfer;; 964 p2p) type=FileTransfer;;
964 *) type=;; 965 voip) type=Telephony;;
965 esac 966 esac
966 type="Network;${type}" 967 type="Network;${type}"
967 ;; 968 ;;
968 969
969 sci) 970 sci)
970 case ${catmin} in 971 case ${catmin} in
971 astro*) type=Astronomy;; 972 astro*) type=Astronomy;;
972 bio*) type=Biology;; 973 bio*) type=Biology;;
973 calc*) type=Calculator;; 974 calc*) type=Calculator;;
974 chem*) type=Chemistry;; 975 chem*) type=Chemistry;;
975 elec*) type=Electronics;; 976 elec*) type=Electronics;;
976 geo*) type=Geology;; 977 geo*) type=Geology;;
977 math*) type=Math;; 978 math*) type=Math;;
978 physics) type=Physics;; 979 physics) type=Physics;;
979 visual*) type=DataVisualization;; 980 visual*) type=DataVisualization;;
980 *) type=;;
981 esac 981 esac
982 type="Science;${type}" 982 type="Education;Science;${type}"
983 ;; 983 ;;
984 984
985 sys) 985 sys)
986 type="System" 986 type="System"
987 ;; 987 ;;
988 988
989 www) 989 www)
990 case ${catmin} in 990 case ${catmin} in
991 client) type=WebBrowser;; 991 client) type=WebBrowser;;
992 *) type=;;
993 esac 992 esac
994 type="Network" 993 type="Network;${type}"
995 ;; 994 ;;
996 995
997 *) 996 *)
998 type= 997 type=
999 ;; 998 ;;
1004 else 1003 else
1005 local desktop_name="${PN}-${SLOT}" 1004 local desktop_name="${PN}-${SLOT}"
1006 fi 1005 fi
1007 local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop" 1006 local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop"
1008 #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop 1007 #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop
1008
1009 # Don't append another ";" when a valid category value is provided.
1010 type=${type%;}${type:+;}
1011
1012 eshopts_push -s extglob
1013 if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
1014 ewarn "As described in the Icon Theme Specification, icon file extensions are not"
1015 ewarn "allowed in .desktop files if the value is not an absolute path."
1016 icon=${icon%.@(xpm|png|svg)}
1017 fi
1018 eshopts_pop
1009 1019
1010 cat <<-EOF > "${desktop}" 1020 cat <<-EOF > "${desktop}"
1011 [Desktop Entry] 1021 [Desktop Entry]
1012 Name=${name} 1022 Name=${name}
1013 Type=Application 1023 Type=Application
1014 Comment=${DESCRIPTION} 1024 Comment=${DESCRIPTION}
1015 Exec=${exec} 1025 Exec=${exec}
1016 TryExec=${exec%% *} 1026 TryExec=${exec%% *}
1017 Icon=${icon} 1027 Icon=${icon}
1018 Categories=${type}; 1028 Categories=${type}
1019 EOF 1029 EOF
1020 1030
1021 [[ ${path} ]] && echo "Path=${path}" >> "${desktop}" 1031 if [[ ${fields:-=} != *=* ]] ; then
1032 # 5th arg used to be value to Path=
1033 ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}"
1034 fields="Path=${fields}"
1035 fi
1036 [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}"
1022 1037
1023 ( 1038 (
1024 # wrap the env here so that the 'insinto' call 1039 # wrap the env here so that the 'insinto' call
1025 # doesn't corrupt the env of the caller 1040 # doesn't corrupt the env of the caller
1026 insinto /usr/share/applications 1041 insinto /usr/share/applications
1027 doins "${desktop}" 1042 doins "${desktop}"
1028 ) 1043 ) || die "installing desktop file failed"
1029} 1044}
1030 1045
1031# @FUNCTION: validate_desktop_entries 1046# @FUNCTION: validate_desktop_entries
1032# @USAGE: [directories] 1047# @USAGE: [directories]
1033# @MAINTAINER: 1048# @MAINTAINER:
1312 [[ -z ${src} ]] && die "Could not locate source for '${src_input}'" 1327 [[ -z ${src} ]] && die "Could not locate source for '${src_input}'"
1313 1328
1314 local shrtsrc=$(basename "${src}") 1329 local shrtsrc=$(basename "${src}")
1315 echo ">>> Unpacking ${shrtsrc} to ${PWD}" 1330 echo ">>> Unpacking ${shrtsrc} to ${PWD}"
1316 if [[ -z ${skip} ]] ; then 1331 if [[ -z ${skip} ]] ; then
1317 local ver=$(grep -a '#.*Makeself' "${src}" | awk '{print $NF}') 1332 local ver=$(grep -m1 -a '#.*Makeself' "${src}" | awk '{print $NF}')
1318 local skip=0 1333 local skip=0
1319 exe=tail 1334 exe=tail
1320 case ${ver} in 1335 case ${ver} in
1321 1.5.*|1.6.0-nv) # tested 1.5.{3,4,5} ... guessing 1.5.x series is same 1336 1.5.*|1.6.0-nv) # tested 1.5.{3,4,5} ... guessing 1.5.x series is same
1322 skip=$(grep -a ^skip= "${src}" | cut -d= -f2) 1337 skip=$(grep -a ^skip= "${src}" | cut -d= -f2)
1324 2.0|2.0.1) 1339 2.0|2.0.1)
1325 skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-) 1340 skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-)
1326 ;; 1341 ;;
1327 2.1.1) 1342 2.1.1)
1328 skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-) 1343 skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-)
1329 let skip="skip + 1" 1344 (( skip++ ))
1330 ;; 1345 ;;
1331 2.1.2) 1346 2.1.2)
1332 skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1) 1347 skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1)
1333 let skip="skip + 1" 1348 (( skip++ ))
1334 ;; 1349 ;;
1335 2.1.3) 1350 2.1.3)
1336 skip=`grep -a ^offset= "${src}" | awk '{print $3}'` 1351 skip=`grep -a ^offset= "${src}" | awk '{print $3}'`
1337 let skip="skip + 1" 1352 (( skip++ ))
1338 ;; 1353 ;;
1339 2.1.4|2.1.5) 1354 2.1.4|2.1.5)
1340 skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1) 1355 skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1)
1341 skip=$(head -n ${skip} "${src}" | wc -c) 1356 skip=$(head -n ${skip} "${src}" | wc -c)
1342 exe="dd" 1357 exe="dd"
1351 esac 1366 esac
1352 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" 1367 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset"
1353 fi 1368 fi
1354 case ${exe} in 1369 case ${exe} in
1355 tail) exe="tail -n +${skip} '${src}'";; 1370 tail) exe="tail -n +${skip} '${src}'";;
1356 dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; 1371 dd) exe="dd ibs=${skip} skip=1 if='${src}'";;
1357 *) die "makeself cant handle exe '${exe}'" 1372 *) die "makeself cant handle exe '${exe}'"
1358 esac 1373 esac
1359 1374
1360 # lets grab the first few bytes of the file to figure out what kind of archive it is 1375 # lets grab the first few bytes of the file to figure out what kind of archive it is
1361 local tmpfile=$(emktemp) 1376 local tmpfile=$(emktemp)

Legend:
Removed from v.1.335  
changed lines
  Added in v.1.344

  ViewVC Help
Powered by ViewVC 1.1.20