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

Diff of /eclass/eutils.eclass

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20