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

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

  ViewVC Help
Powered by ViewVC 1.1.20