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

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

  ViewVC Help
Powered by ViewVC 1.1.20