# Template file for 'palemoon'
pkgname=palemoon
version=31.1.0
revision=1
_release=1.1
archs="i686 x86_64"
hostmakedepends="curl python3-html2text tar xz"
depends="libvpx alsa-lib dbus-glib libXt gtk+"
short_desc="Open-source web browser based on Firefox focusing on efficiency"
maintainer="tuxliban <tenshalito@gmail.com>"
license="LGPL-2.1-or-later MPL-2.0-or-later GPL-3.0-or-later"
homepage="https://www.palemoon.org"

if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
	_debarch=amd64
	checksum=d6351d67dce090ee17c8dbce84b3524c095afec2373fd33c8a2e795d94215155
else
	_debarch=i386
	checksum=63857a7b7626f5238652795066191c9091e5b10673c51d08941b03ec26dcdbc
fi

distfiles="https://download.opensuse.org/repositories/home:/stevenpusser/Debian_11/${_debarch}/${pkgname}_${version}-${_release}.gtk2_${_debarch}.deb"
_licenseURL="https://www.palemoon.org/redist.shtml"

do_extract() {
	ar x ${XBPS_SRCDISTDIR}/${pkgname}-${version}/${pkgname}_${version}-${_release}.gtk2_${_debarch}.deb
	tar xf data.tar.xz
}

do_install() {
	vinstall usr/share/applications/${pkgname}.desktop 0644 \
		usr/share/applications

	# Crear directorio en path falso ($DESTDIR) para el paquete
	vmkdir opt
	vmkdir usr/bin
	
	# Mover archivos de forma recursiva
	vcopy usr/lib/palemoon opt
	ln -s /opt/palemoon/palemoon "${DESTDIR}/usr/bin/palemoon"

	for res in 16 32 48 128; do
		vinstall usr/share/icons/hicolor/${res}x${res}/apps/${pkgname}.png 0644 \
			usr/share/icons/hicolor/${res}x${res}/apps ${pkgname}.png
	done
}

post_install() {
	curl ${_licenseURL} | html2text | sed '1,57d' > EULA.md
	vlicense EULA.md
}
