# Maintainer: Samuel Forestier <dev+archey@samuel.domains>

pkgname=archey4
pkgver=4.15.0.0
pkgrel=5
pkgdesc="A simple system information tool written in Python"
arch=('any')
url="https://github.com/HorlogeSkynet/${pkgname}"
license=('GPL-3.0-or-later')
groups=('utils')
depends=('python>=3.6' 'python-distro' 'python-netifaces')
makedepends=('python-setuptools')
optdepends=('bind-tools: WAN_IP would be detected faster'
	'lm_sensors: Temperature would be more accurate'
	'pciutils: GPU wouldn'"'"'t be detected without it'
	'procps-ng: Many entries wouldn'"'"'t work without it'
	'virt-what: Model would contain details about the hypervisor'
	'wmctrl: WindowManager would be more accurate')
provides=('archey')
conflicts=('archey-git' 'archey2' 'archey3-git' 'pyarchey')
install="${pkgname}.install"
backup=("etc/${pkgname}/config.json")
source=("${pkgname}_${pkgver}-${pkgrel}.tar.gz::${url}/archive/v${pkgver}.tar.gz")
md5sums=('db2d44bc114ccf53177c3d2b3be59837')
sha1sums=('9f5f29d1141939ba689dceceacb74c7f2b9d51f5')

build() {
	cd "${pkgname}-${pkgver}/"

	# Prepare the manual page.
	sed \
		-e "s/\${DATE}/$(date +'%B %Y')/1" \
		-e "s/\${VERSION}/${pkgver}/1" \
		archey.1 >dist/archey.1

	python3 setup.py build
}

package() {
	cd "${pkgname}-${pkgver}/"

	python3 setup.py -q install \
		--root="$pkgdir" \
		--optimize=1 \
		--skip-build

	# Configuration file.
	install -D -m0644 config.json -t "${pkgdir}/etc/${pkgname}/"

	# Manual page.
	install -D -m0644 dist/archey.1 -t "${pkgdir}/usr/share/man/man1/"

	# Meta-data files.
	install -D -m0644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
	install -D -m0644 README.md -t "${pkgdir}/usr/share/${pkgname}/"
	install -D -m0644 COPYRIGHT.md -t "${pkgdir}/usr/share/${pkgname}/"
}
