summaryrefslogtreecommitdiff
path: root/www-client/palemoon/palemoon-28.16.0.ebuild
blob: 35c17c19f380c7200d94508460ba8053a557b2c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# Copyright 2020 LiGurOs Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
REQUIRED_BUILDSPACE='9G'
GCC_SUPPORTED_VERSIONS="6.5 7.5 8.4 9.3 10.2 11.0"

inherit git-r3 eutils flag-o-matic pax-utils desktop xdg-utils

KEYWORDS="~x86 amd64"
DESCRIPTION="Pale Moon Web Browser"
HOMEPAGE="https://www.palemoon.org/"

SLOT="0"
LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
IUSE="+official-branding +optimize cpu_flags_x86_sse cpu_flags_x86_sse2 +shared-js threads debug +jemalloc -valgrind dbus -necko-wifi gnome +gconf +gtk2 -gtk3 pulseaudio +devtools -system-sqlite -system-cairo -system-pixman -system-libevent -system-hunspell -system-vpx -system-compress -system-images -system-nss -system-ffi"

EGIT_REPO_URI="https://repo.palemoon.org/MoonchildProductions/Pale-Moon.git"
EGIT_COMMIT="${PV}_Release"
RESTRICT="network-sandbox"

DEPEND="
	>=dev-lang/perl-5.6
	dev-lang/nasm
	<sys-devel/gcc-10.0
	>=x11-libs/pango-1.22.0
	>=dev-libs/glib-2.22
	>=app-arch/brotli-1.0.9
	>=media-libs/woff2-1.0.2
"

RDEPEND="
	x11-libs/libXt
	media-libs/freetype
	>=media-libs/fontconfig-2.7.0
	optimize? ( sys-libs/glibc )
	valgrind? ( dev-util/valgrind )
	shared-js? ( virtual/libffi )
	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 )
	media-libs/alsa-lib
	pulseaudio? ( media-sound/pulseaudio )
	media-video/ffmpeg[x264]
	necko-wifi? ( net-wireless/wireless-tools )
	system-cairo? ( >=x11-libs/cairo-1.10 )
	system-compress?
	(
		>=sys-libs/zlib-1.2.3
		app-arch/bzip2
	)
	system-images?
	(
		media-libs/libjpeg-turbo
		media-libs/libpng:*[apng]
	)
	system-libevent? ( dev-libs/libevent )
	system-ffi? ( dev-libs/libffi )
	system-hunspell? ( app-text/hunspell )
	system-nss? ( >=dev-libs/nss-3.48.4 )
	system-pixman? ( >=x11-libs/pixman-0.19.2 )
	system-sqlite? ( >=dev-db/sqlite-3.33.0[secure-delete] )
	system-vpx? ( >=media-libs/libvpx-1.5.0 )"

# autoconf 2.13 is still needed as the configure scripts are not updated yet
# python 2.7 is also still needed as the mach build system can't handle python3
BDEPEND="
	${RDEPEND}
	>=sys-devel/autoconf-2.13:2.1
	dev-lang/python:2.7"

REQUIRED_USE="
	optimize? ( !debug )
	jemalloc? ( !valgrind )
	^^ ( gtk2 gtk3 )
	necko-wifi? ( dbus )
	official-branding? (
		!system-sqlite !system-cairo !system-pixman !system-libevent !system-vpx
		!system-compress !system-images !system-nss !system-ffi !system-hunspell
	)"

src_prepare() {
	eapply_user

	default
}

src_configure() {
	# Basic configuration:
	echo "ac_add_options --enable-application=palemoon" > "${S}/.mozconfig"
	echo "ac_add_options --disable-updater" >> "${S}/.mozconfig"
	echo "ac_add_options --disable-install-strip" >> "${S}/.mozconfig"
	echo "ac_add_options --disable-accessibility" >> "${S}/.mozconfig"
	echo "ac_add_options --disable-eme" >> "${S}/.mozconfig"
	echo "ac_add_options --disable-webrtc" >> "${S}/.mozconfig"
	echo "ac_add_options --disable-gamepad" >> "${S}/.mozconfig"
	echo "ac_add_options --disable-tests" >> "${S}/.mozconfig"


	if use official-branding; then
		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."
		echo "ac_add_options --enable-official-branding" >> "${S}/.mozconfig"
	fi

	# System-* flags
	# Some options aren't in configure.in anymore (e.g. webp, spelling)
	if use system-compress; then
		echo "ac_add_options --with-system-zlib" >> "${S}/.mozconfig"
		echo "ac_add_options --with-system-bz2" >> "${S}/.mozconfig"
	fi

	if use system-libevent; then
		echo "ac_add_options --with-system-libevent" >> "${S}/.mozconfig"
	fi

	if use system-nss; then
		echo "ac_add_options --with-system-nss" >> "${S}/.mozconfig"
	fi

	if use system-images; then
		echo "ac_add_options --with-system-jpeg" >> "${S}/.mozconfig"
		echo "ac_add_options --with-system-png" >> "${S}/.mozconfig"
	fi

	if use system-vpx; then
		echo "ac_add_options --with-system-libvpx" >> "${S}/.mozconfig"
	fi

	if use system-sqlite; then
		echo "ac_add_options --with-system-sqlite" >> "${S}/.mozconfig"
	fi

	if use system-cairo; then
		echo "ac_add_options --with-system-cairo" >> "${S}/.mozconfig"
	fi

	if use system-pixman; then
		echo "ac_add_options --with-system-pixman" >> "${S}/.mozconfig"
	fi

	if use system-ffi; then
		echo "ac_add_options --with-system-ffi" >> "${S}/.mozconfig"
	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
		echo "ac_add_options --enable-optimize=\"${O}\"" >> "${S}/.mozconfig"
		filter-flags '-O*' '-msse2' '-mfpmath=sse'
	else
		echo "ac_add_options --disable-optimize" >> "${S}/.mozconfig"
	fi

	if use threads; then
		echo "ac_add_options --with-pthreads" >> "${S}/.mozconfig"
	fi

	if use debug; then
		echo "mk_add_options MOZ_DEBUG_SYMBOLS=1" >> "${S}/.mozconfig"
		echo "ac_add_options --enable-debug-symbols=\"-gdwarf-2\"" >> "${S}/.mozconfig"
	fi

	if ! use shared-js; then
		echo "ac_add_options --disable-shared-js" >> "${S}/.mozconfig"
	fi

	if use jemalloc; then
		echo "ac_add_options --enable-jemalloc" >> "${S}/.mozconfig"
	fi

	if use valgrind; then
		echo "ac_add_options --enable-valgrind" >> "${S}/.mozconfig"
	fi

	if ! use dbus; then
		echo "ac_add_options --disable-dbus" >> "${S}/.mozconfig"
	fi

	if ! use gnome; then
		echo "ac_add_options --disable-gconf" >> "${S}/.mozconfig"
	fi

	if use gtk2; then
		echo "ac_add_options --enable-default-toolkit=\"cairo-gtk2\"" >> "${S}/.mozconfig"
	fi

	if use gtk3; then
		echo "ac_add_options --enable-default-toolkit=\"cairo-gtk3\"" >> "${S}/.mozconfig"
	fi

	if ! use necko-wifi; then
		echo "ac_add_options --disable-necko-wifi" >> "${S}/.mozconfig"
	fi

	if ! use pulseaudio; then
		echo "ac_add_options --disable-pulseaudio" >> "${S}/.mozconfig"
	fi

	if use devtools; then
		echo "ac_add_options --enable-devtools" >> "${S}/.mozconfig"
	fi

	if ! use gconf; then
		echo "ac_add_options --disable-gconf" >> "${S}/.mozconfig"
	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".
	echo "ac_add_options --disable-precompiled-startupcache" >> "${S}/.mozconfig"

	# 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"
	echo "mk_add_options PYTHON=$(which python2)" >> "${S}/.mozconfig"
	echo "mk_add_options AUTOCONF=$(which autoconf-2.13)" >> "${S}/.mozconfig"
	echo "mk_add_options MOZ_MAKE_FLAGS=\"${MAKEOPTS}\"" >> "${S}/.mozconfig"

	# Shorten obj dir to limit some errors linked to the path size hitting
	# a kernel limit (127 chars):
	echo "mk_add_options MOZ_OBJDIR=\"@TOPSRCDIR@/o\"" >> "${S}/.mozconfig"

	# 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
	export XARGS="$(which xargs)"
	export SHELL="${SHELL:-${EPREFIX}/bin/bash}"
	${S}/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:
	echo "pref(\"browser.backspace_action\", 0);" >> "${S}/${obj_dir}/dist/bin/browser/defaults/preferences/palemoon.js"

	# 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..."
	${S}/mach package || die
	local extracted_dir="${T}/package"
	mkdir -p "${extracted_dir}"
	cd "${extracted_dir}"

	einfo "Extracting the package..."
	tar xJpf "${S}/${obj_dir}/dist/${P}.linux-${CTARGET_default%%-*}.tar.xz" || 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:
	cp -rL "${S}/${obj_dir}/dist/branding" "${extracted_dir}/"
	local size sizes icon_path icon name
	sizes="16 32 48"
	icon_path="${extracted_dir}/branding"
	icon="${PN}"
	name="Pale Moon"

	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}/icon/${PN}.desktop" "${PN}.desktop"
	sed -i -e "s:@NAME@:${name}:" -e "s:@ICON@:${icon}:" \
		"${ED}/usr/share/applications/${PN}.desktop" || die
}

pkg_postinst() {
	# Update mimedb for the new .desktop file
	xdg_desktop_database_update
	xdg_icon_cache_update
}

pkg_postrm() {
	xdg_icon_cache_update
}