emacs
[idgentoo.git] / eclass / palemoon-5.eclass
blob62547c0f205e461f7d557782bf16bb9ef6a00110
1 inherit check-reqs gnome2-utils toolchain-funcs xdg-utils
3 EXPORT_FUNCTIONS pkg_pretend pkg_preinst pkg_postinst pkg_postrm pkg_setup
6 ###
7 # Package
8 ###
10 palemoon-5_pkg_pretend() {
11         # Ensure that we have enough disk space to compile:
12         CHECKREQS_DISK_BUILD=${REQUIRED_BUILDSPACE}
13         check-reqs_pkg_setup
15         # Ensure that we are on a supported compiler profile:
16         einfo "Checking compiler profile..."
17         if [[ $PALEMOON_ENABLE_UNSUPPORTED_COMPILERS == 1 ]]; then
18                 unsupported_compiler_warning $(tc-get-compiler-type)
19         else
20                 if ! [[ tc-is-gcc && "$GCC_SUPPORTED_VERSIONS" =~ (^| )"$(gcc-version)"($| ) ]]; then
21                         unsupported_compiler_error $(tc-get-compiler-type)
22                         die
23                 fi
24         fi
27 palemoon-5_pkg_preinst() {
28         gnome2_icon_savelist
31 palemoon-5_pkg_postinst() {
32         # Update mimedb for the new .desktop file:
33         xdg_desktop_database_update
34         gnome2_icon_cache_update
37 palemoon-5_pkg_postrm() {
38         gnome2_icon_cache_update
41 palemoon-5_pkg_setup() {
42         # Nested configure scripts in mozilla products generate unrecognized
43         # options false positives when toplevel configure passes downwards:
44         export QA_CONFIGURE_OPTIONS=".*"
48 ###
49 # Messages
50 ###
52 official-branding_warning() {
53         elog "You are enabling the official branding. You may not redistribute this build"
54         elog "to any users on your network or the internet. Doing so puts yourself into"
55         elog "a legal problem with Moonchild Productions."
56         elog "You can disable the official branding by emerging ${PN} _without_"
57         elog "the official-branding USE flag."
60 unsupported_compiler_warning() {
61         ewarn "Building Pale Moon with a compiler other than a supported gcc version"
62         ewarn "may result in an unstable build."
63         ewarn "Be aware that building Pale Moon with an unsupported compiler"
64         ewarn "means that the official support channels may refuse to offer any"
65         ewarn "kind of help in case the build fails or the browser behaves incorrectly."
66         ewarn "Supported GCC versions: ${GCC_SUPPORTED_VERSIONS// /, }"
67         if [[ "$1" == "gcc" ]]; then
68                 ewarn "Selected GCC version: $(gcc-version)"
69         else
70                 ewarn "Unsupported compiler selected: $1"
71         fi
72         ewarn "To disable this warning unset the PALEMOON_ENABLE_UNSUPPORTED_COMPILERS"
73         ewarn "environment variable."
76 unsupported_compiler_error() {
77         eerror "Building Pale Moon with a compiler other than a supported gcc version"
78         eerror "may result in an unstable build."
79         eerror "You can use gcc-config to change your compiler profile, just remember"
80         eerror "to change it back afterwards."
81         eerror "You need to have the appropriate versions of gcc installed for them"
82         eerror "to be shown in gcc-config."
83         eerror "Alternatively, you can set the PALEMOON_ENABLE_UNSUPPORTED_COMPILERS"
84         eerror "environment variable to 1 either by exporting it from the current shell"
85         eerror "or by adding it to your make.conf file."
86         eerror "Be aware though that building Pale Moon with an unsupported compiler"
87         eerror "means that the official support channels may refuse to offer any"
88         eerror "kind of help in case the build fails or the browser behaves incorrectly."
89         eerror "Supported GCC versions: ${GCC_SUPPORTED_VERSIONS// /, }"
90         if [[ "$1" == "gcc" ]]; then
91                 eerror "Selected GCC version: $(gcc-version)"
92         else
93                 eerror "Unsupported compiler selected: $1"
94         fi
98 ###
99 # Configuration
102 mozconfig_init() {
103         echo "ac_add_options --enable-application=palemoon" > "${S}/.mozconfig"
106 mozconfig_enable() {
107         for option in "$@"; do
108                 echo "ac_add_options --enable-${option}" >> "${S}/.mozconfig"
109         done
112 mozconfig_disable() {
113         for option in "$@"; do
114                 echo "ac_add_options --disable-${option}" >> "${S}/.mozconfig"
115         done
118 mozconfig_with() {
119         for option in "$@"; do
120                 echo "ac_add_options --with-${option}" >> "${S}/.mozconfig"
121         done
124 mozconfig_var() {
125         echo "mk_add_options $1=$2" >> "${S}/.mozconfig"
128 set_pref() {
129         echo "pref(\"$1\", $2);" >> "${S}/${obj_dir}/dist/bin/browser/defaults/preferences/palemoon.js"
134 # Branding
137 install_branding_files() {
138         cp -rL "${S}/${obj_dir}/dist/branding" "${extracted_dir}/"
139         local size sizes icon_path icon name
140         sizes="16 32 48"
141         icon_path="${extracted_dir}/branding"
142         icon="${PN}"
143         name="Pale Moon"
144         for size in ${sizes}; do
145                 insinto "/usr/share/icons/hicolor/${size}x${size}/apps"
146                 newins "${icon_path}/default${size}.png" "${icon}.png"
147         done
148         # The 128x128 icon has a different name:
149         insinto "/usr/share/icons/hicolor/128x128/apps"
150         newins "${icon_path}/mozicon128.png" "${icon}.png"
151         # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs:
152         newicon "${icon_path}/default48.png" "${icon}.png"
153         newmenu "${FILESDIR}/icon/${PN}.desktop" "${PN}.desktop"
154         sed -i -e "s:@NAME@:${name}:" -e "s:@ICON@:${icon}:" \
155                 "${ED}/usr/share/applications/${PN}.desktop" || die