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

Diff of /eclass/eutils.eclass

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

Revision 1.329 Revision 1.334
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.329 2010/01/28 22:00:12 betelgeuse Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.334 2010/02/26 03:15:26 abcd 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 [[ $(type -t eqawarn) == function ]] && \
58 eqawarn "QA Notice: ebeep is not defined in EAPI=3, please file a bug at http://bugs.gentoo.org"
59}
60
61epause() {
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"
64}
65
54fi 66fi
55 67
56# @FUNCTION: ecvs_clean 68# @FUNCTION: ecvs_clean
57# @USAGE: [list of dirs] 69# @USAGE: [list of dirs]
58# @DESCRIPTION: 70# @DESCRIPTION:
73 [[ -z $* ]] && set -- . 85 [[ -z $* ]] && set -- .
74 find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf 86 find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
75} 87}
76 88
77# @FUNCTION: eshopts_push 89# @FUNCTION: eshopts_push
78# @USAGE: [options to `set`] 90# @USAGE: [options to `set` or `shopt`]
79# @DESCRIPTION: 91# @DESCRIPTION:
80# Often times code will want to enable a shell option to change code behavior. 92# Often times code will want to enable a shell option to change code behavior.
81# Since changing shell options can easily break other pieces of code (which 93# Since changing shell options can easily break other pieces of code (which
82# assume the default state), eshopts_push is used to (1) push the current shell 94# assume the default state), eshopts_push is used to (1) push the current shell
83# options onto a stack and (2) pass the specified arguments to set. 95# options onto a stack and (2) pass the specified arguments to set.
96#
97# If the first argument is '-s' or '-u', we assume you want to call `shopt`
98# rather than `set` as there are some options only available via that.
84# 99#
85# A common example is to disable shell globbing so that special meaning/care 100# A common example is to disable shell globbing so that special meaning/care
86# may be used with variables/arguments to custom functions. That would be: 101# may be used with variables/arguments to custom functions. That would be:
87# @CODE 102# @CODE
88# eshopts_push -o noglob 103# eshopts_push -o noglob
96# @CODE 111# @CODE
97eshopts_push() { 112eshopts_push() {
98 # have to assume __ESHOPTS_SAVE__ isn't screwed with 113 # have to assume __ESHOPTS_SAVE__ isn't screwed with
99 # as a `declare -a` here will reset its value 114 # as a `declare -a` here will reset its value
100 local i=${#__ESHOPTS_SAVE__[@]} 115 local i=${#__ESHOPTS_SAVE__[@]}
116 if [[ $1 == -[su] ]] ; then
101 __ESHOPTS_SAVE__[$i]=$- 117 __ESHOPTS_SAVE__[$i]=$(shopt -p)
102 [[ $# -eq 0 ]] && return 0 118 [[ $# -eq 0 ]] && return 0
119 shopt "$@" || die "eshopts_push: bad options to shopt: $*"
120 else
121 __ESHOPTS_SAVE__[$i]=$-
122 [[ $# -eq 0 ]] && return 0
103 set "$@" || die "eshopts_push: bad options to set: $*" 123 set "$@" || die "eshopts_push: bad options to set: $*"
124 fi
104} 125}
105 126
106# @FUNCTION: eshopts_pop 127# @FUNCTION: eshopts_pop
107# @USAGE: 128# @USAGE:
108# @DESCRIPTION: 129# @DESCRIPTION:
112 [[ $# -ne 0 ]] && die "eshopts_pop takes no arguments" 133 [[ $# -ne 0 ]] && die "eshopts_pop takes no arguments"
113 local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 )) 134 local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 ))
114 [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair" 135 [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair"
115 local s=${__ESHOPTS_SAVE__[$i]} 136 local s=${__ESHOPTS_SAVE__[$i]}
116 unset __ESHOPTS_SAVE__[$i] 137 unset __ESHOPTS_SAVE__[$i]
138 if [[ ${s} == "shopt -"* ]] ; then
139 eval "${s}" || die "eshopts_pop: sanity: invalid shopt options: ${s}"
140 else
117 set +$- || die "eshopts_pop: sanity: invalid shell settings: $-" 141 set +$- || die "eshopts_pop: sanity: invalid shell settings: $-"
118 set -${s} || die "eshopts_pop: sanity: unable to restore saved shell settings: ${s}" 142 set -${s} || die "eshopts_pop: sanity: unable to restore saved shell settings: ${s}"
143 fi
119} 144}
120 145
121# @VARIABLE: EPATCH_SOURCE 146# @VARIABLE: EPATCH_SOURCE
122# @DESCRIPTION: 147# @DESCRIPTION:
123# Default directory to search for patches. 148# Default directory to search for patches.
934 irc) type=IRCClient;; 959 irc) type=IRCClient;;
935 mail) type=Email;; 960 mail) type=Email;;
936 news) type=News;; 961 news) type=News;;
937 nntp) type=News;; 962 nntp) type=News;;
938 p2p) type=FileTransfer;; 963 p2p) type=FileTransfer;;
964 voip) type=Telephony;;
939 *) type=;; 965 *) type=;;
940 esac 966 esac
941 type="Network;${type}" 967 type="Network;${type}"
942 ;; 968 ;;
943 969
952 math*) type=Math;; 978 math*) type=Math;;
953 physics) type=Physics;; 979 physics) type=Physics;;
954 visual*) type=DataVisualization;; 980 visual*) type=DataVisualization;;
955 *) type=;; 981 *) type=;;
956 esac 982 esac
957 type="Science;${type}" 983 type="Education;Science;${type}"
958 ;; 984 ;;
959 985
960 sys) 986 sys)
961 type="System" 987 type="System"
962 ;; 988 ;;
964 www) 990 www)
965 case ${catmin} in 991 case ${catmin} in
966 client) type=WebBrowser;; 992 client) type=WebBrowser;;
967 *) type=;; 993 *) type=;;
968 esac 994 esac
969 type="Network" 995 type="Network;${type}"
970 ;; 996 ;;
971 997
972 *) 998 *)
973 type= 999 type=
974 ;; 1000 ;;
979 else 1005 else
980 local desktop_name="${PN}-${SLOT}" 1006 local desktop_name="${PN}-${SLOT}"
981 fi 1007 fi
982 local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop" 1008 local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop"
983 #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop 1009 #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop
1010
1011 # Don't append another ";" when a valid category value is provided.
1012 type=${type%;}${type:+;}
1013
1014 eshopts_push -s extglob
1015 if [[ -n ${icon} && ${icon} != /* && ${icon} == *.@(xpm|png|svg) ]]; then
1016 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."
1018 icon=${icon%.@(xpm|png|svg)}
1019 fi
1020 eshopts_pop
984 1021
985 cat <<-EOF > "${desktop}" 1022 cat <<-EOF > "${desktop}"
986 [Desktop Entry] 1023 [Desktop Entry]
987 Name=${name} 1024 Name=${name}
988 Type=Application 1025 Type=Application
989 Comment=${DESCRIPTION} 1026 Comment=${DESCRIPTION}
990 Exec=${exec} 1027 Exec=${exec}
991 TryExec=${exec%% *} 1028 TryExec=${exec%% *}
992 Icon=${icon} 1029 Icon=${icon}
993 Categories=${type}; 1030 Categories=${type}
994 EOF 1031 EOF
995 1032
996 [[ ${path} ]] && echo "Path=${path}" >> "${desktop}" 1033 [[ ${path} ]] && echo "Path=${path}" >> "${desktop}"
997 1034
998 ( 1035 (

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

  ViewVC Help
Powered by ViewVC 1.1.20