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

Contents of /eclass/chromium.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Fri Mar 23 19:53:51 2012 UTC (2 years ago) by floppym
Branch: MAIN
Changes since 1.2: +5 -1 lines
Set IUSE=custom-cflags in the eclass so we can reference it in the die hook.

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

  ViewVC Help
Powered by ViewVC 1.1.20