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