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

Contents of /eclass/chromium.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Tue Jul 17 03:56:26 2012 UTC (2 years, 3 months ago) by floppym
Branch: MAIN
Changes since 1.5: +2 -2 lines
Remove -v option from rm command.

1 floppym 1.1 # Copyright 1999-2012 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 floppym 1.6 # $Header: /var/cvsroot/gentoo-x86/eclass/chromium.eclass,v 1.5 2012/05/30 06:15:24 phajdan.jr Exp $
4 floppym 1.1
5     # @ECLASS: chromium.eclass
6     # @MAINTAINER:
7     # Chromium Herd <chromium@gentoo.org>
8     # @AUTHOR:
9     # Mike Gilbert <floppym@gentoo.org>
10     # @BLURB: Shared functions for chromium and google-chrome
11    
12     inherit eutils fdo-mime gnome2-utils linux-info
13    
14     EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_postrm
15    
16 floppym 1.3 if [[ ${PN} == chromium ]]; then
17     IUSE+=" custom-cflags"
18     fi
19    
20 phajdan.jr 1.5 # @FUNCTION: chromium_suid_sandbox_check_kernel_config
21 floppym 1.1 # @USAGE:
22     # @DESCRIPTION:
23 phajdan.jr 1.5 # Ensures the system kernel supports features needed for SUID sandbox to work.
24     chromium_suid_sandbox_check_kernel_config() {
25 floppym 1.1 has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported"
26    
27     if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
28     # Warn if the kernel does not support features needed for sandboxing.
29     # Bug #363987.
30     ERROR_PID_NS="PID_NS is required for sandbox to work"
31     ERROR_NET_NS="NET_NS is required for sandbox to work"
32     CONFIG_CHECK="~PID_NS ~NET_NS"
33     check_extra_config
34     fi
35     }
36    
37 phajdan.jr 1.5 # @FUNCTION: chromium_check_kernel_config
38     # @USAGE:
39     # @DESCRIPTION:
40     # Ensures the system kernel is configured for full Chromium functionality.
41     chromium_check_kernel_config() {
42     eqawarn "chromium_check_kernel_config is deprecated."
43     eqawarn "Please use chromium_suid_sandbox_check_kernel_config if applicable."
44     chromium_suid_sandbox_check_kernel_config
45     }
46    
47 floppym 1.1 # @ECLASS-VARIABLE: CHROMIUM_LANGS
48     # @DEFAULT_UNSET
49     # @DESCRIPTION:
50     # List of language packs available for this package.
51    
52     _chromium_set_linguas_IUSE() {
53     [[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported"
54    
55     local lang
56     for lang in ${CHROMIUM_LANGS}; do
57     # Default to enabled since we bundle them anyway.
58     # USE-expansion will take care of disabling the langs the user has not
59     # selected via LINGUAS.
60     IUSE+=" +linguas_${lang}"
61     done
62     }
63    
64     if [[ ${CHROMIUM_LANGS} ]]; then
65     _chromium_set_linguas_IUSE
66     fi
67    
68     _chromium_crlang() {
69     local x
70     for x in "$@"; do
71     case $x in
72     es_LA) echo es-419 ;;
73     *) echo "${x/_/-}" ;;
74     esac
75     done
76     }
77    
78     _chromium_syslang() {
79     local x
80     for x in "$@"; do
81     case $x in
82     es-419) echo es_LA ;;
83     *) echo "${x/-/_}" ;;
84     esac
85     done
86     }
87    
88     _chromium_strip_pak() {
89     local x
90     for x in "$@"; do
91     echo "${x%.pak}"
92     done
93     }
94    
95     # @FUNCTION: chromium_remove_language_paks
96     # @USAGE:
97     # @DESCRIPTION:
98     # Removes pak files from the current directory for languages that the user has
99     # not selected via the LINGUAS variable.
100     # Also performs QA checks to ensure CHROMIUM_LANGS has been set correctly.
101     chromium_remove_language_paks() {
102     local crlangs=$(_chromium_crlang ${CHROMIUM_LANGS})
103     local present_crlangs=$(_chromium_strip_pak *.pak)
104     local present_langs=$(_chromium_syslang ${present_crlangs})
105     local lang
106    
107     # Look for missing pak files.
108     for lang in ${crlangs}; do
109     if ! has ${lang} ${present_crlangs}; then
110     eqawarn "LINGUAS warning: no .pak file for ${lang} (${lang}.pak not found)"
111     fi
112     done
113    
114     # Look for extra pak files.
115     # Remove pak files that the user does not want.
116     for lang in ${present_langs}; do
117     if [[ ${lang} == en_US ]]; then
118     continue
119     fi
120     if ! has ${lang} ${CHROMIUM_LANGS}; then
121     eqawarn "LINGUAS warning: no ${lang} in LANGS"
122     continue
123     fi
124     if ! use linguas_${lang}; then
125 floppym 1.6 rm "$(_chromium_crlang ${lang}).pak" || die
126 floppym 1.1 fi
127     done
128     }
129    
130     chromium_pkg_preinst() {
131     gnome2_icon_savelist
132     }
133    
134     chromium_pkg_postinst() {
135     fdo-mime_desktop_database_update
136     gnome2_icon_cache_update
137    
138     # For more info see bug #292201, bug #352263, bug #361859.
139 floppym 1.4 if ! has_version x11-themes/gnome-icon-theme &&
140     ! has_version x11-themes/oxygen-icons ; then
141     elog
142     elog "Depending on your desktop environment, you may need"
143     elog "to install additional packages to get icons on the Downloads page."
144     elog
145     elog "For KDE, the required package is kde-base/oxygen-icons."
146     elog
147     elog "For other desktop environments, try one of the following:"
148     elog " - x11-themes/gnome-icon-theme"
149     elog " - x11-themes/tango-icon-theme"
150     fi
151 floppym 1.1
152     # For more info see bug #359153.
153     elog
154     elog "Some web pages may require additional fonts to display properly."
155     elog "Try installing some of the following packages if some characters"
156     elog "are not displayed properly:"
157     elog " - media-fonts/arphicfonts"
158     elog " - media-fonts/bitstream-cyberbit"
159     elog " - media-fonts/droid"
160     elog " - media-fonts/ipamonafont"
161     elog " - media-fonts/ja-ipafonts"
162     elog " - media-fonts/takao-fonts"
163     elog " - media-fonts/wqy-microhei"
164     elog " - media-fonts/wqy-zenhei"
165     }
166    
167     chromium_pkg_postrm() {
168     gnome2_icon_cache_update
169     }
170    
171     chromium_pkg_die() {
172     if [[ "${EBUILD_PHASE}" != "compile" ]]; then
173     return
174     fi
175    
176     # Prevent user problems like bug #348235.
177     eshopts_push -s extglob
178     if is-flagq '-g?(gdb)?([1-9])'; then
179     ewarn
180     ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS)."
181 floppym 1.2 ewarn "This produces very large build files causes the linker to consume large"
182     ewarn "amounts of memory."
183     ewarn
184 floppym 1.1 ewarn "Please try removing -g{,gdb} before reporting a bug."
185     ewarn
186     fi
187     eshopts_pop
188    
189     # ccache often causes bogus compile failures, especially when the cache gets
190     # corrupted.
191     if has ccache ${FEATURES}; then
192     ewarn
193     ewarn "You have enabled ccache. Please try disabling ccache"
194     ewarn "before reporting a bug."
195     ewarn
196     fi
197    
198     # No ricer bugs.
199     if use_if_iuse custom-cflags; then
200     ewarn
201     ewarn "You have enabled the custom-cflags USE flag."
202     ewarn "Please disable it before reporting a bug."
203     ewarn
204     fi
205    
206     # If the system doesn't have enough memory, the compilation is known to
207     # fail. Print info about memory to recognize this condition.
208     einfo
209     einfo "$(grep MemTotal /proc/meminfo)"
210     einfo "$(grep SwapTotal /proc/meminfo)"
211     einfo
212     }
213    
214     # @VARIABLE: EGYP_CHROMIUM_COMMAND
215     # @DESCRIPTION:
216     # Path to the gyp_chromium script.
217     : ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
218    
219     # @VARIABLE: EGYP_CHROMIUM_DEPTH
220     # @DESCRIPTION:
221     # Depth for egyp_chromium.
222     : ${EGYP_CHROMIUM_DEPTH:=.}
223    
224     # @FUNCTION: egyp_chromium
225     # @USAGE: [gyp arguments]
226     # @DESCRIPTION:
227     # Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
228     # arguments. The full command line is echoed for logging.
229     egyp_chromium() {
230     set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
231     echo "$@"
232     "$@"
233     }
234    
235     # @FUNCTION: gyp_use
236     # @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
237     # @DESCRIPTION:
238     # If USE flag is set, echo -D[GYP flag]=[true suffix].
239     #
240     # If USE flag is not set, echo -D[GYP flag]=[false suffix].
241     #
242     # [GYP flag] defaults to use_[USE flag] with hyphens converted to underscores.
243     #
244     # [true suffix] defaults to 1. [false suffix] defaults to 0.
245     gyp_use() {
246     local gypflag="-D${2:-use_${1//-/_}}="
247     usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"
248     }
249    
250     # @FUNCTION: chromium_bundled_v8_version
251     # @USAGE: [path to version.cc]
252     # @DESCRIPTION:
253     # Outputs the version of v8 parsed from a (bundled) copy of the source code.
254     chromium_bundled_v8_version() {
255     local vf=${1:-v8/src/version.cc}
256     local major minor build patch
257     major=$(sed -ne 's/#define MAJOR_VERSION *\([0-9]*\)/\1/p' "${vf}")
258     minor=$(sed -ne 's/#define MINOR_VERSION *\([0-9]*\)/\1/p' "${vf}")
259     build=$(sed -ne 's/#define BUILD_NUMBER *\([0-9]*\)/\1/p' "${vf}")
260     patch=$(sed -ne 's/#define PATCH_LEVEL *\([0-9]*\)/\1/p' "${vf}")
261     echo "${major}.${minor}.${build}.${patch}"
262     }
263    
264     # @FUNCTION: chromium_installed_v8_version
265     # @USAGE:
266     # @DESCRIPTION:
267     # Outputs the version of dev-lang/v8 currently installed on the host system.
268     chromium_installed_v8_version() {
269     local cpf=$(best_version dev-lang/v8)
270     local pvr=${cpf#dev-lang/v8-}
271     echo "${pvr%-r*}"
272     }

  ViewVC Help
Powered by ViewVC 1.1.20