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

Diff of /eclass/eutils.eclass

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

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

Legend:
Removed from v.1.330  
changed lines
  Added in v.1.349

  ViewVC Help
Powered by ViewVC 1.1.20