summaryrefslogtreecommitdiff
blob: aa72c6c076d38fc2d99c54b52a3e6d692ea3d16f (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
# Copyright 2020-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CHROMIUM_LANGS="am ar bg bn ca cs da de el en-GB es es-419 et fa fi fil fr gu he
	hi hr hu id it ja kn ko lt lv ml mr ms nb nl pl pt-BR pt-PT ro ru sk sl sr
	sv sw ta te th tr uk vi zh-CN zh-TW"

inherit chromium-2 desktop pax-utils readme.gentoo-r1 unpacker xdg-utils

DESCRIPTION="Open-source version of Google Chrome web browser"
HOMEPAGE="https://chromium.org/"

MY_P=${P}-1

SRC_URI="https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-common.tar.xz
	https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-l10n.tar.xz
	amd64? (
		https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-common-x86_64.tar.xz
		wayland? ( https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-wayland-x86_64.tar.xz )
		!wayland? ( https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-x11-x86_64.tar.xz )
	)
	arm64? (
		https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-common-aarch64.tar.xz
		wayland? ( https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-wayland-aarch64.tar.xz )
		!wayland? ( https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-x11-aarch64.tar.xz )
	)
	x86? (
		https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-common-i686.tar.xz
		wayland? ( https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-wayland-i686.tar.xz )
		!wayland? ( https://dev.gentoo.org/~sultan/distfiles/www-client/chromium-bin/${MY_P}-x11-i686.tar.xz )
	)"

LICENSE="BSD"
SLOT="0"
KEYWORDS="-* ~amd64 ~arm64 ~x86"
IUSE="cpu_flags_x86_sse2 suid +swiftshader wayland widevine"

RDEPEND="
	app-accessibility/at-spi2-atk:2
	app-accessibility/at-spi2-core:2
	dev-libs/atk
	dev-libs/expat
	dev-libs/glib:2
	dev-libs/libxml2[icu]
	dev-libs/libxslt
	dev-libs/nspr
	>=dev-libs/nss-3.26
	media-libs/alsa-lib
	media-libs/flac
	media-libs/fontconfig
	>=media-libs/freetype-2.11.0-r1
	media-libs/libjpeg-turbo
	media-libs/libwebp
	media-libs/mesa[gbm(+)]
	media-libs/openh264:0/6.1
	net-misc/curl[ssl]
	net-print/cups
	sys-apps/dbus
	sys-apps/pciutils
	>=sys-devel/gcc-9.3.0
	>=sys-libs/glibc-2.32
	sys-libs/zlib[minizip]
	virtual/ttf-fonts
	virtual/udev
	x11-libs/cairo
	x11-libs/libdrm
	x11-libs/gdk-pixbuf:2
	|| (
		x11-libs/gtk+:3[X,wayland?]
		gui-libs/gtk:4[X,wayland?]
	)
	x11-libs/libX11
	x11-libs/libXcomposite
	x11-libs/libXdamage
	x11-libs/libXext
	x11-libs/libXfixes
	x11-libs/libXrandr
	x11-libs/libXtst
	x11-libs/libxcb
	x11-libs/libxkbcommon
	x11-libs/libxshmfence
	x11-libs/pango
	x11-misc/xdg-utils
	amd64? (
		widevine? ( www-plugins/chrome-binary-plugins )
	)
	wayland? ( dev-libs/wayland )
"

S=${WORKDIR}
QA_PREBUILT="*"

DISABLE_AUTOFORMATTING="yes"
DOC_CONTENTS="
Some web pages may require additional fonts to display properly.
Try installing some of the following packages if some characters
are not displayed properly:
- media-fonts/arphicfonts
- media-fonts/droid
- media-fonts/ipamonafont
- media-fonts/noto
- media-fonts/ja-ipafonts
- media-fonts/takao-fonts
- media-fonts/wqy-microhei
- media-fonts/wqy-zenhei

To fix broken icons on the Downloads page, you should install an icon
theme that covers the appropriate MIME types, and configure this as your
GTK+ icon theme.

For native file dialogs in KDE, install kde-apps/kdialog.

To make password storage work with your desktop environment you may
have install one of the supported credentials management applications:
- app-crypt/libsecret (GNOME)
- kde-frameworks/kwallet (KDE)
If you have one of above packages installed, but don't want to use
them in Chromium, then add --password-store=basic to CHROMIUM_BIN_FLAGS
in /etc/chromium-bin/default.
"

pkg_pretend() {
	if use amd64 || use x86; then
		if ! use cpu_flags_x86_sse2; then
			eerror "This package requires a CPU supporting the SSE2 instruction set."
			die "SSE2 support missing"
		fi
	fi
}

pkg_setup() {
	chromium_suid_sandbox_check_kernel_config

	if ! use amd64 && use widevine; then
		ewarn "Widevine CDM plugin is not available for your architecture."
	fi
}

src_unpack() {
	:
}

src_install() {
	dodir /
	cd "${ED}" || die
	unpacker

	local CHROMIUM_BIN_HOME="opt/chromium-bin"

	if ! use suid; then
		rm "${CHROMIUM_BIN_HOME}/chrome-sandbox" || die
	fi

	# Remove SwiftShader OpenGL libraries
	if ! use swiftshader; then
		rm -r "${CHROMIUM_BIN_HOME}/swiftshader" || die
	fi

	# Clean unneeded languages
	pushd "${CHROMIUM_BIN_HOME}/locales" > /dev/null || die
	chromium_remove_language_paks
	popd > /dev/null || die

	# Install icons
	local size
	for size in 16 24 32 48 64 128 256 ; do
		newicon -s ${size} "${CHROMIUM_BIN_HOME}/icons/hicolor/${size}x${size}/apps/chromium-browser.png" ${PN}-browser.png
	done
	rm -r "${CHROMIUM_BIN_HOME}/icons"

	# Allow users to override command-line options, bug #357629.
	insinto /etc/chromium-bin
	newins "${FILESDIR}/chromium-bin.default" "default"

	# Install desktop entry
	domenu "${FILESDIR}/chromium-bin-browser-chromium.desktop"

	# Install GNOME default application entry (bug #303100).
	insinto /usr/share/gnome-control-center/default-apps
	newins "${FILESDIR}/chromium-bin-browser.xml" chromium-bin-browser.xml

	# Install manpage; bug #684550
	doman "${FILESDIR}/chromium-bin-browser.1"
	dosym chromium-bin-browser.1 /usr/share/man/man1/chromium-bin.1

	pax-mark m "${CHROMIUM_BIN_HOME}/chrome"

	# Symlink Widevine CDM
	if use widevine; then
		dosym "../../usr/$(get_libdir)/chromium-browser/WidevineCdm" "${CHROMIUM_BIN_HOME}/WidevineCdm"
	fi

	# Install launcher
	exeinto "${CHROMIUM_BIN_HOME}"
	doexe "${FILESDIR}/chromium-bin-launcher.sh"

	# It is important that we name the target "chromium-bin-browser",
	# xdg-utils expect it; bug #355517.
	dosym "../../${CHROMIUM_BIN_HOME}/chromium-bin-launcher.sh" /usr/bin/chromium-bin-browser
	# keep the old symlink around for consistency
	dosym "../../${CHROMIUM_BIN_HOME}/chromium-bin-launcher.sh" /usr/bin/chromium-bin

	dosym "../../${CHROMIUM_BIN_HOME}/chromedriver" /usr/bin/chromedriver-bin

	readme.gentoo_create_doc
}

pkg_postrm() {
	xdg_icon_cache_update
	xdg_desktop_database_update
}

pkg_postinst() {
	xdg_icon_cache_update
	xdg_desktop_database_update
	readme.gentoo_print_elog

	elog "For VA-API support you need to install x11-libs/libva with"
	elog "USE=X enabled."
	elog
	elog "VA-API is disabled by default at runtime. You have to enable it"
	elog "by adding --enable-features=VaapiVideoDecoder to CHROMIUM_BIN_FLAGS"
	elog "in /etc/chromium-bin/default."

	if use wayland; then
		elog
		elog "For screencast support you need to install media-video/pipewire."
		elog
		elog "Screencast is disabled by default at runtime. Either enable it"
		elog "by navigating to chrome://flags/#enable-webrtc-pipewire-capturer"
		elog "inside Chromium or add --enable-features=WebRTCPipeWireCapturer"
		elog "to CHROMIUM_BIN_FLAGS in /etc/chromium-bin/default."
	fi

	elog
	elog "chromium-bin profile defaults to \${HOME}/.config/chromium-bin."
	elog "Some extensions (e.g. KeepassXC) expect default chromium profile"
	elog "at \${HOME}/.config/chromium. You can overwrite this by adding"
	elog "--user-data-dir=\${HOME}/.config/chromium to CHROMIUM_BIN_FLAGS"
	elog "in /etc/chromium-bin/default."
}