# Maintainer: Luke T. Shumaker <lukeshu@parabola.nu>

pkgname=(parabolaweb-utils parabolaweb-dev)
pkgver=20251129
pkgdesc="Utilities for managing the ParabolaWeb website application"
url="https://git.parabola.nu/packages/parabolaweb-utils.git/"
license=('GPL-2.0-or-later')

# The commit to get dependency info for
# Bump pkgrel instead of pkgver if updating this is the only change
_parabolaweb_commit=6c7900ed6c4b05e21724ffc6dfafde51709c9cfc

pkgrel=1
epoch=1
arch=('i686' 'x86_64' 'armv7h')

makedepends=('git')
source=("git+https://git.parabola.nu/packages/$pkgname.git#tag=v${pkgver}"
        "requirements_prod-${_parabolaweb_commit}.txt::https://git.parabola.nu/server/parabolaweb.git/plain/requirements_prod.txt?id=${_parabolaweb_commit}"
        "requirements-${_parabolaweb_commit}.txt::https://git.parabola.nu/server/parabolaweb.git/plain/requirements.txt?id=${_parabolaweb_commit}")
sha256sums=('e6ba8aac0a5f4b49e665c2f1afc24b6fd4eaaf05f32929fd8e460e3de0df12d4'
            '9712873af06c24c0f3b6a3842ab282f001db98e20cbb4b2d84f0e2bf280f6161'
            '005be35cb88f6b624639afbc1c4b64f529b3fbb9d91119a01a1b05bca987ea29')

#makedepends+=(python-pip)
prepare() {
	cd "$srcdir/$pkgbase"
	ln -sf /bin/true build-aux/pip2pacman
}

build() {
	cd "$srcdir/$pkgbase"
	ln -srf ../requirements-${_parabolaweb_commit}.txt requirements.txt
	ln -srf ../requirements_prod-${_parabolaweb_commit}.txt requirements_prod.txt
	make
}

package_parabolaweb-utils() {
	cd "$srcdir/$pkgbase"
	depends=($(sed -r -e 's/\s*#.*//' depends.txt))
	backup=(
		'etc/conf.d/parabolaweb'
		'etc/nginx/snippets/parabolaweb.conf'
		'etc/sudoers.d/10-parabolaweb'
		'etc/uwsgi/parabolaweb.ini'
	)
	make install DESTDIR="$pkgdir"
}

package_parabolaweb-dev() {
	cd "$srcdir/$pkgbase"
	pkgdesc="Depends on packages needed to develop ParabolaWeb"
	depends=(parabolaweb-utils $(sed -r -e 's/\s*#.*//' depends_make.txt))
}
