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

Diff of /eclass/eutils.eclass

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

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

Legend:
Removed from v.1.332  
changed lines
  Added in v.1.348

  ViewVC Help
Powered by ViewVC 1.1.20