diff --git a/eclass/palemoon-v1.eclass b/eclass/palemoon-v1.eclass new file mode 100644 index 0000000..924bd53 --- /dev/null +++ b/eclass/palemoon-v1.eclass @@ -0,0 +1,213 @@ +# Copyright 2019-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + + +# @ECLASS: palemoon-v1.eclass +# @MAINTAINER: src_prepare group +# @AUTHOR: src_prepare group +# @SUPPORTED_EAPIS: 6 7 +# @BLURB: Common configuration eclass for Palemoon +# @DESCRIPTION: This eclass is used in palemoon ebuilds + + +case ${EAPI} in + 0 | 1 | 2 | 3 | 4 | 5 ) + die "EAPI=${EAPI} not supported" + ;; +esac + + +inherit check-reqs desktop toolchain-funcs xdg-utils + +EXPORT_FUNCTIONS pkg_pretend pkg_postinst pkg_postrm pkg_setup + + +# @FUNCTION: palemoon-v1_pkg_pretend +# @DESCRIPTION: pkg_pretend for palemoon + +palemoon-v1_pkg_pretend() { + + # Ensure that we have enough disk space to compile: + CHECKREQS_DISK_BUILD="${REQUIRED_BUILDSPACE}" + check-reqs_pkg_setup + + # Ensure that we are on a supported compiler profile: + einfo "Checking compiler profile..." + if [[ ${PALEMOON_ENABLE_UNSUPPORTED_COMPILERS} == 1 ]]; then + unsupported_compiler_warning "$(tc-get-compiler-type)" + else + if ! [[ tc-is-gcc && "${GCC_SUPPORTED_VERSIONS}" =~ (^| )"$(gcc-version)"($| ) ]]; then + unsupported_compiler_error "$(tc-get-compiler-type)" + die + fi + fi +} + + +# @FUNCTION: palemoon-v1_pkg_postinst +# @DESCRIPTION: pkg_postinst for palemoon + +palemoon-v1_pkg_postinst() { + xdg_icon_cache_update + xdg_desktop_database_update +} + + +# @FUNCTION: palemoon-v1_pkg_postrm +# @DESCRIPTION: pkg_postrm for palemoon + +palemoon-v1_pkg_postrm() { + xdg_icon_cache_update + xdg_desktop_database_update +} + + +# @FUNCTION: palemoon-v1_pkg_setup +# @DESCRIPTION: pkg_setup for palemoon + +palemoon-v1_pkg_setup() { + + # Nested configure scripts in mozilla products generate unrecognized + # options false positives when toplevel configure passes downwards: + export QA_CONFIGURE_OPTIONS=".*" +} + + +# @FUNCTION: official-branding_warning +# @DESCRIPTION: Warn when enabling official branding + +official-branding_warning() { + elog "You are enabling the official branding. You may not redistribute this build" + elog "to any users on your network or the internet. Doing so puts yourself into" + elog "a legal problem with Moonchild Productions." + elog "You can disable the official branding by emerging ${PN} _without_" + elog "the official-branding USE flag." +} + + +# @FUNCTION: unsupported_compiler_warning +# @DESCRIPTION: Warn when unsupported compiler is detected + +unsupported_compiler_warning() { + ewarn "Building Pale Moon with a compiler other than a supported gcc version" + ewarn "may result in an unstable build." + ewarn "Be aware that building Pale Moon with an unsupported compiler" + ewarn "means that the official support channels may refuse to offer any" + ewarn "kind of help in case the build fails or the browser behaves incorrectly." + ewarn "Supported GCC versions: ${GCC_SUPPORTED_VERSIONS// /, }" + if [[ "${1}" == "gcc" ]]; then + ewarn "Selected GCC version: $(gcc-version)" + else + ewarn "Unsupported compiler selected: ${1}" + fi + ewarn "To disable this warning unset the PALEMOON_ENABLE_UNSUPPORTED_COMPILERS" + ewarn "environment variable." +} + + +# @FUNCTION: unsupported_compiler_error +# @DESCRIPTION: Error when unsupported compiler is detected + +unsupported_compiler_error() { + eerror "Building Pale Moon with a compiler other than a supported gcc version" + eerror "may result in an unstable build." + eerror "You can use gcc-config to change your compiler profile, just remember" + eerror "to change it back afterwards." + eerror "You need to have the appropriate versions of gcc installed for them" + eerror "to be shown in gcc-config." + eerror "Alternatively, you can set the PALEMOON_ENABLE_UNSUPPORTED_COMPILERS" + eerror "environment variable to 1 either by exporting it from the current shell" + eerror "or by adding it to your make.conf file." + eerror "Be aware though that building Pale Moon with an unsupported compiler" + eerror "means that the official support channels may refuse to offer any" + eerror "kind of help in case the build fails or the browser behaves incorrectly." + eerror "Supported GCC versions: ${GCC_SUPPORTED_VERSIONS// /, }" + if [[ "${1}" == "gcc" ]]; then + eerror "Selected GCC version: $(gcc-version)" + else + eerror "Unsupported compiler selected: ${1}" + fi +} + + +# @FUNCTION: mozconfig_init +# @DESCRIPTION: Initialize mozconfig + +mozconfig_init() { + echo "ac_add_options --enable-application=palemoon" > "${S}/.mozconfig" +} + + +# @FUNCTION: mozconfig_enable +# @DESCRIPTION: Enable a mozconfig option + +mozconfig_enable() { + for option in "${@}"; do + echo "ac_add_options --enable-${option}" >> "${S}/.mozconfig" + done +} + + +# @FUNCTION: mozconfig_disable +# @DESCRIPTION: Disable a mozconfig option + +mozconfig_disable() { + for option in "${@}"; do + echo "ac_add_options --disable-${option}" >> "${S}/.mozconfig" + done +} + + +# @FUNCTION: mozconfig_with +# @DESCRIPTION: Enable a mozconfig option + +mozconfig_with() { + for option in "${@}"; do + echo "ac_add_options --with-${option}" >> "${S}/.mozconfig" + done +} + + +# @FUNCTION: mozconfig_var +# @DESCRIPTION: Enable a mozconfig viariable + +mozconfig_var() { + echo "mk_add_options ${1}=${2}" >> "${S}/.mozconfig" +} + + +# @FUNCTION: set_pref +# @DESCRIPTION: Enable a (Java Script) preference + +set_pref() { + echo "pref(\"${1}\", ${2});" >> "${S}/${obj_dir}/dist/bin/browser/defaults/preferences/palemoon.js" +} + + +# @FUNCTION: install_branding_files +# @DESCRIPTION: Install icons and desktop file + +install_branding_files() { + cp -rL "${S}/${obj_dir}/dist/branding" "${extracted_dir}/" + + local size sizes icon_path icon name + icon="${PN}" + icon_path="${extracted_dir}/branding" + name="Pale Moon" + sizes="16 32 48" + + for size in ${sizes}; do + insinto "/usr/share/icons/hicolor/${size}x${size}/apps" + newins "${icon_path}/default${size}.png" "${icon}.png" + done + + # The 128x128 icon has a different name: + insinto "/usr/share/icons/hicolor/128x128/apps" + newins "${icon_path}/mozicon128.png" "${icon}.png" + + # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs: + newicon "${icon_path}/default48.png" "${icon}.png" + newmenu "${FILESDIR}/${PN}.desktop" "${PN}.desktop" + sed -i -e "s:@NAME@:${name}:" -e "s:@ICON@:${icon}:" \ + "${ED}/usr/share/applications/${PN}.desktop" || die +} diff --git a/www-client/palemoon/files/palemoon.desktop b/www-client/palemoon/files/palemoon.desktop new file mode 100644 index 0000000..89b6b35 --- /dev/null +++ b/www-client/palemoon/files/palemoon.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Categories=Network;WebBrowser; +Comment=Web Browser +Exec=palemoon %u +Icon=@ICON@ +MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall; +Name=@NAME@ +Terminal=false +Type=Application diff --git a/www-client/palemoon/metadata.xml b/www-client/palemoon/metadata.xml new file mode 100644 index 0000000..608f78e --- /dev/null +++ b/www-client/palemoon/metadata.xml @@ -0,0 +1,30 @@ + + + + + + Enable Mozilla Developer Tools + + + Use x11-libs/gtk+:2 + + + Use x11-libs/gtk+:3 + + + Replace memory allocator with jemalloc + + + Enable the necko wifi scanner + + + Enable official branding + + + Enable compiler optimization + + + Enable Valgrind integration hooks + + + diff --git a/www-client/palemoon/palemoon-28.9.1.ebuild b/www-client/palemoon/palemoon-28.9.1.ebuild new file mode 100644 index 0000000..d2b89ed --- /dev/null +++ b/www-client/palemoon/palemoon-28.9.1.ebuild @@ -0,0 +1,253 @@ +# Copyright 2019-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +GCC_SUPPORTED_VERSIONS="4.9 5.4 7.3 8.2 8.3 9.2" +PYTHON_COMPAT=( python2_7 ) +REQUIRED_BUILDSPACE='9G' + +inherit palemoon-v1 git-r3 flag-o-matic pax-utils python-any-r1 + +DESCRIPTION="Pale Moon Web Browser" +HOMEPAGE="https://www.palemoon.org/" + +if [[ "${PV}" == *9999* ]]; then + EGIT_REPO_URI="https://github.com/MoonchildProductions/Pale-Moon.git" + KEYWORDS="" +else + EGIT_REPO_URI="https://github.com/MoonchildProductions/Pale-Moon.git" + EGIT_COMMIT="${PV}_Release" + KEYWORDS="~amd64" +fi + +RESTRICT="mirror" +LICENSE="MPL-2.0 GPL-2 LGPL-2.1" +SLOT="0" +IUSE=" + cpu_flags_x86_sse + cpu_flags_x86_sse2 + dbus + +devtools + debug + gnome + -gtk2 + +gtk3 + +jemalloc + pulseaudio + -necko-wifi + official-branding + +optimize + threads + -valgrind +" +REQUIRED_USE=" + optimize? ( + !debug + ) + jemalloc? ( + !valgrind + ) + ^^ ( + gtk2 + gtk3 + ) + necko-wifi? ( + dbus + ) +" + +DEPEND=" + ${PYTHON_DEPS} + >=dev-lang/perl-5.6 + >=sys-devel/autoconf-2.13:2.1 + dev-lang/yasm +" +RDEPEND=" + app-arch/zip + media-libs/alsa-lib + media-libs/fontconfig + media-libs/freetype + virtual/ffmpeg[x264] + x11-libs/libXt + dbus? ( + >=sys-apps/dbus-0.60 + >=dev-libs/dbus-glib-0.60 + ) + gnome? ( + gnome-base/gconf + ) + gtk2? ( + >=x11-libs/gtk+-2.18.0:2 + ) + gtk3? ( + >=x11-libs/gtk+-3.4.0:3 + ) + necko-wifi? ( + net-wireless/wireless-tools + ) + pulseaudio? ( + media-sound/pulseaudio + ) + valgrind? ( + dev-util/valgrind + ) + optimize? ( + sys-libs/glibc + ) +" + +src_prepare() { + + # Ensure that our plugins dir is enabled by default: + sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \ + "${S}/platform/xpcom/io/nsAppFileLocationProvider.cpp" \ + || die "sed failed to replace plugin path for 32bit!" + sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \ + "${S}/platform/xpcom/io/nsAppFileLocationProvider.cpp" \ + || die "sed failed to replace plugin path for 64bit!" + + default +} + +src_configure() { + + # Does not build with -fno-common + filter-flags -fno-common + append-flags -fcommon + + # Basic configuration: + mozconfig_init + + mozconfig_disable updater install-strip accessibility + + if use official-branding; then + official-branding_warning + mozconfig_enable official-branding + fi + + if use optimize; then + O='-O2' + if use cpu_flags_x86_sse && use cpu_flags_x86_sse2; then + O="${O} -msse2 -mfpmath=sse" + fi + mozconfig_enable "optimize=\"${O}\"" + filter-flags '-O*' '-msse2' '-mfpmath=sse' + else + mozconfig_disable optimize + fi + + if use threads; then + mozconfig_with pthreads + fi + + if use debug; then + mozconfig_var MOZ_DEBUG_SYMBOLS 1 + mozconfig_enable "debug-symbols=\"-gdwarf-2\"" + fi + + if use jemalloc; then + mozconfig_enable jemalloc + fi + + if use valgrind; then + mozconfig_enable valgrind + fi + + if ! use dbus; then + mozconfig_disable dbus + fi + + if ! use gnome; then + mozconfig_disable gconf + fi + + if use gtk2; then + mozconfig_enable default-toolkit=\"cairo-gtk2\" + fi + + if use gtk3; then + mozconfig_enable default-toolkit=\"cairo-gtk3\" + fi + + if ! use necko-wifi; then + mozconfig_disable necko-wifi + fi + + if ! use pulseaudio; then + mozconfig_disable pulseaudio + fi + + if use devtools; then + mozconfig_enable devtools + fi + + # Enabling this causes xpcshell to hang during the packaging process, + # so disabling it until the cause can be tracked down. It most likely + # has something to do with the sandbox since the issue goes away when + # building with FEATURES="-sandbox -usersandbox". + mozconfig_disable precompiled-startupcache + + # Mainly to prevent system's NSS/NSPR from taking precedence over + # the built-in ones: + append-ldflags -Wl,-rpath="${EPREFIX}/usr/$(get_libdir)/palemoon" + + export MOZBUILD_STATE_PATH="${WORKDIR}/mach_state" + mozconfig_var PYTHON "$(which python2)" + mozconfig_var AUTOCONF "$(which autoconf-2.13)" + mozconfig_var MOZ_MAKE_FLAGS "\"${MAKEOPTS}\"" + + # Shorten obj dir to limit some errors linked to the path size hitting + # a kernel limit (127 chars): + mozconfig_var MOZ_OBJDIR "@TOPSRCDIR@/o" + + # Disable mach notifications, which also cause sandbox access violations: + export MOZ_NOSPAM=1 +} + +src_compile() { + + # Prevents portage from setting its own XARGS which messes with the + # Pale Moon build system checks: + # See: https://gitweb.gentoo.org/proj/portage.git/tree/bin/isolated-functions.sh + XARGS="$(which xargs)" + export XARGS + + python2 "${S}/platform/mach" build || die +} + +src_install() { + + # obj_dir changes depending on arch, compiler, etc: + local obj_dir="$(echo */config.log)" + obj_dir="${obj_dir%/*}" + + # Disable MPROTECT for startup cache creation: + pax-mark m "${obj_dir}"/dist/bin/xpcshell + + # Set the backspace behaviour to be consistent with the other platforms: + set_pref "browser.backspace_action" 0 + + # Gotta create the package, unpack it and manually install the files + # from there not to miss anything (e.g. the statusbar extension): + einfo "Creating the package..." + python2 "${S}/platform/mach" mozpackage || die + local extracted_dir="${T}/package" + mkdir -p "${extracted_dir}" + cd "${extracted_dir}" + einfo "Extracting the package..." + find "${S}/${obj_dir}/dist/" -name "*.bz2" -printf "${S}/${obj_dir}/dist/%P" | xargs tar xjpf || die + einfo "Installing the package..." + local dest_libdir="/usr/$(get_libdir)" + mkdir -p "${D}/${dest_libdir}" + cp -rL "${PN}" "${D}/${dest_libdir}" + dosym "${dest_libdir}/${PN}/${PN}" "/usr/bin/${PN}" + einfo "Done installing the package." + + # Until JIT-less builds are supported, + # also disable MPROTECT on the main executable: + pax-mark m "${D}/${dest_libdir}/${PN}/"{palemoon,palemoon-bin,plugin-container} + + # Install icons and .desktop for menu entry: + install_branding_files +} diff --git a/www-client/palemoon/palemoon-9999.ebuild b/www-client/palemoon/palemoon-9999.ebuild new file mode 100644 index 0000000..d2b89ed --- /dev/null +++ b/www-client/palemoon/palemoon-9999.ebuild @@ -0,0 +1,253 @@ +# Copyright 2019-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +GCC_SUPPORTED_VERSIONS="4.9 5.4 7.3 8.2 8.3 9.2" +PYTHON_COMPAT=( python2_7 ) +REQUIRED_BUILDSPACE='9G' + +inherit palemoon-v1 git-r3 flag-o-matic pax-utils python-any-r1 + +DESCRIPTION="Pale Moon Web Browser" +HOMEPAGE="https://www.palemoon.org/" + +if [[ "${PV}" == *9999* ]]; then + EGIT_REPO_URI="https://github.com/MoonchildProductions/Pale-Moon.git" + KEYWORDS="" +else + EGIT_REPO_URI="https://github.com/MoonchildProductions/Pale-Moon.git" + EGIT_COMMIT="${PV}_Release" + KEYWORDS="~amd64" +fi + +RESTRICT="mirror" +LICENSE="MPL-2.0 GPL-2 LGPL-2.1" +SLOT="0" +IUSE=" + cpu_flags_x86_sse + cpu_flags_x86_sse2 + dbus + +devtools + debug + gnome + -gtk2 + +gtk3 + +jemalloc + pulseaudio + -necko-wifi + official-branding + +optimize + threads + -valgrind +" +REQUIRED_USE=" + optimize? ( + !debug + ) + jemalloc? ( + !valgrind + ) + ^^ ( + gtk2 + gtk3 + ) + necko-wifi? ( + dbus + ) +" + +DEPEND=" + ${PYTHON_DEPS} + >=dev-lang/perl-5.6 + >=sys-devel/autoconf-2.13:2.1 + dev-lang/yasm +" +RDEPEND=" + app-arch/zip + media-libs/alsa-lib + media-libs/fontconfig + media-libs/freetype + virtual/ffmpeg[x264] + x11-libs/libXt + dbus? ( + >=sys-apps/dbus-0.60 + >=dev-libs/dbus-glib-0.60 + ) + gnome? ( + gnome-base/gconf + ) + gtk2? ( + >=x11-libs/gtk+-2.18.0:2 + ) + gtk3? ( + >=x11-libs/gtk+-3.4.0:3 + ) + necko-wifi? ( + net-wireless/wireless-tools + ) + pulseaudio? ( + media-sound/pulseaudio + ) + valgrind? ( + dev-util/valgrind + ) + optimize? ( + sys-libs/glibc + ) +" + +src_prepare() { + + # Ensure that our plugins dir is enabled by default: + sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \ + "${S}/platform/xpcom/io/nsAppFileLocationProvider.cpp" \ + || die "sed failed to replace plugin path for 32bit!" + sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \ + "${S}/platform/xpcom/io/nsAppFileLocationProvider.cpp" \ + || die "sed failed to replace plugin path for 64bit!" + + default +} + +src_configure() { + + # Does not build with -fno-common + filter-flags -fno-common + append-flags -fcommon + + # Basic configuration: + mozconfig_init + + mozconfig_disable updater install-strip accessibility + + if use official-branding; then + official-branding_warning + mozconfig_enable official-branding + fi + + if use optimize; then + O='-O2' + if use cpu_flags_x86_sse && use cpu_flags_x86_sse2; then + O="${O} -msse2 -mfpmath=sse" + fi + mozconfig_enable "optimize=\"${O}\"" + filter-flags '-O*' '-msse2' '-mfpmath=sse' + else + mozconfig_disable optimize + fi + + if use threads; then + mozconfig_with pthreads + fi + + if use debug; then + mozconfig_var MOZ_DEBUG_SYMBOLS 1 + mozconfig_enable "debug-symbols=\"-gdwarf-2\"" + fi + + if use jemalloc; then + mozconfig_enable jemalloc + fi + + if use valgrind; then + mozconfig_enable valgrind + fi + + if ! use dbus; then + mozconfig_disable dbus + fi + + if ! use gnome; then + mozconfig_disable gconf + fi + + if use gtk2; then + mozconfig_enable default-toolkit=\"cairo-gtk2\" + fi + + if use gtk3; then + mozconfig_enable default-toolkit=\"cairo-gtk3\" + fi + + if ! use necko-wifi; then + mozconfig_disable necko-wifi + fi + + if ! use pulseaudio; then + mozconfig_disable pulseaudio + fi + + if use devtools; then + mozconfig_enable devtools + fi + + # Enabling this causes xpcshell to hang during the packaging process, + # so disabling it until the cause can be tracked down. It most likely + # has something to do with the sandbox since the issue goes away when + # building with FEATURES="-sandbox -usersandbox". + mozconfig_disable precompiled-startupcache + + # Mainly to prevent system's NSS/NSPR from taking precedence over + # the built-in ones: + append-ldflags -Wl,-rpath="${EPREFIX}/usr/$(get_libdir)/palemoon" + + export MOZBUILD_STATE_PATH="${WORKDIR}/mach_state" + mozconfig_var PYTHON "$(which python2)" + mozconfig_var AUTOCONF "$(which autoconf-2.13)" + mozconfig_var MOZ_MAKE_FLAGS "\"${MAKEOPTS}\"" + + # Shorten obj dir to limit some errors linked to the path size hitting + # a kernel limit (127 chars): + mozconfig_var MOZ_OBJDIR "@TOPSRCDIR@/o" + + # Disable mach notifications, which also cause sandbox access violations: + export MOZ_NOSPAM=1 +} + +src_compile() { + + # Prevents portage from setting its own XARGS which messes with the + # Pale Moon build system checks: + # See: https://gitweb.gentoo.org/proj/portage.git/tree/bin/isolated-functions.sh + XARGS="$(which xargs)" + export XARGS + + python2 "${S}/platform/mach" build || die +} + +src_install() { + + # obj_dir changes depending on arch, compiler, etc: + local obj_dir="$(echo */config.log)" + obj_dir="${obj_dir%/*}" + + # Disable MPROTECT for startup cache creation: + pax-mark m "${obj_dir}"/dist/bin/xpcshell + + # Set the backspace behaviour to be consistent with the other platforms: + set_pref "browser.backspace_action" 0 + + # Gotta create the package, unpack it and manually install the files + # from there not to miss anything (e.g. the statusbar extension): + einfo "Creating the package..." + python2 "${S}/platform/mach" mozpackage || die + local extracted_dir="${T}/package" + mkdir -p "${extracted_dir}" + cd "${extracted_dir}" + einfo "Extracting the package..." + find "${S}/${obj_dir}/dist/" -name "*.bz2" -printf "${S}/${obj_dir}/dist/%P" | xargs tar xjpf || die + einfo "Installing the package..." + local dest_libdir="/usr/$(get_libdir)" + mkdir -p "${D}/${dest_libdir}" + cp -rL "${PN}" "${D}/${dest_libdir}" + dosym "${dest_libdir}/${PN}/${PN}" "/usr/bin/${PN}" + einfo "Done installing the package." + + # Until JIT-less builds are supported, + # also disable MPROTECT on the main executable: + pax-mark m "${D}/${dest_libdir}/${PN}/"{palemoon,palemoon-bin,plugin-container} + + # Install icons and .desktop for menu entry: + install_branding_files +}