# Maintainer: Kimiblock Moe

pkgname=komikku-portable
pkgver=50.11.0
pkgrel=1
epoch=1
pkgdesc="Manga reader sandboxed by portable (prevents dGPU wakeups)"
arch=('x86_64')
url="https://github.com/Kraftland/portable"
license=('GPL-3.0-or-later')
groups=()
provides=(komikku)
options=(!debug !strip)
conflicts=("komikku")

optdepends=()

makedepends+=(komikku coreutils)

checkdepends=()

source=(
	portable-config
	komikku.sh
	komikku.desktop
)


md5sums=('7bc9e48038298ec3f0db1b70bae9d167'
         '5d5aef3f6dd4f268371cc20fe875ebc2'
         'c15e280ebf501ffe01c48754edd4cdc0')

function prepare() {
	pacman -Ql komikku >file.list
}

function package() {
	depends=("portable")
	depends+=(dconf  gdk-pixbuf2  glib2  graphene  gtk4  hicolor-icon-theme  libadwaita  libnotify  libsoup3  pango  python  python-beautifulsoup4  python-brotli
                  python-colorthief  python-cryptography  python-dateparser  python-emoji  python-gobject  python-keyring  python-lxml  python-magic  python-natsort
                  python-piexif  python-pillow  python-pypdf  python-pytz  python-rarfile  python-regex  python-requests  python-tzlocal  python-unidecode
                  python-urllib3  webkitgtk-6.0 python-pyjwt)
	while IFS= read -r line; do
		file="$(echo "$line" | awk '{print $2}')"
		if [[ -d ${file} ]]; then
			echo "Omitting Directory"
		else
			if [[ -L "${file}" ]]; then
				mkdir -p "$(dirname "${pkgdir}/${file}")"
				ln -vsf "$(readlink -f "${file}")" "${pkgdir}/${file}"
			else
				install -vDm755 "${file}" "${pkgdir}/${file}"
			fi
		fi
	done < file.list
	rm -f "${pkgdir}/usr/share/applications"/*
	rm -f "${pkgdir}/usr/bin"/*
	install -vDm755 /usr/bin/komikku -t "${pkgdir}/usr/lib/portable/overlay-usr"
	install -Dm644 portable-config \
		"${pkgdir}/usr/lib/portable/info/info.febvre.Komikku/config"
	install -Dm755 "komikku.sh" \
		"${pkgdir}/usr/bin/komikku"
	install -Dm644 "komikku.desktop" "${pkgdir}/usr/share/applications/info.febvre.Komikku.desktop"
}
