# Template file for 'google-chrome'
pkgname=google-chrome
version=108.0.5359.124
revision=1
_channel=stable
archs="x86_64"
hostmakedepends="python3-html2text python3-setuptools"
depends="gtk+3"
short_desc="Attempt at creating a safer, faster, and more stable browser"
maintainer="Michael Aldridge <maldridge@voidlinux.org>"
license="custom:chrome"
homepage="https://www.google.com/chrome/"
distfiles="https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-${_channel}_${version}-1_amd64.deb"
checksum=ef5a7b3711b71f1eb4f4bfc4b724fa1250540a3b4f12444e79f3b7f4b70e8101
_license_checksum=8023b18fb5118ef65d586363e53909861bd1a9676e5eb83c20fd3ac6e33ea0be

skiprdeps="/opt/google/chrome/libqt5_shim.so"
repository=nonfree
restricted=yes
nostrip=yes

post_extract() {
	$XBPS_FETCH_CMD 'https://www.google.com/intl/en/chrome/terms/' -o google-chrome-eula.html
	html2text google-chrome-eula.html | sed -n '/^#/,/^SEE/p' > google-chrome-eula.md
	filesum="$(xbps-digest google-chrome-eula.md)"
	if [ "$filesum" != "$_license_checksum" ]; then
		msg_error "SHA256 mismatch for EULA:\n$filesum\n"
	fi
}

do_install() {
	vcopy etc /
	vcopy opt /
	vcopy usr /

	# Install the icons
	for size in 16 24 32 48 64 128 256; do
		# Create the google chrome xdg directory
		mkdir -p ${DESTDIR}/usr/share/icons/hicolor/${size}x${size}/apps

		# Copy the google chrome icon
		mv ${DESTDIR}/opt/google/chrome/product_logo_${size}.png \
		   ${DESTDIR}/usr/share/icons/hicolor/${size}x${size}/apps/google-chrome.png
	done

	# Remove unused icons
	rm ${DESTDIR}/opt/google/chrome/*.xpm

	# Remove the Debian/Ubuntu crontab
	rm -rf ${DESTDIR}/etc
	rm -rf ${DESTDIR}/opt/google/chrome/cron

	vlicense google-chrome-eula.md
}