# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=debian-devscripts
pkgver=2.25.13
pkgrel=0
pkgdesc="Debian developer scripts"
url="https://tracker.debian.org/pkg/devscripts"
arch="noarch"
license="GPL-2.0-or-later"
checkdepends="perl"
# checkbashisms is the common accepted name, but prefix for rest
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	checkbashisms
	$pkgname-hardening-check:harden
	"
source="$pkgname-$pkgver.tar.gz::https://salsa.debian.org/debian/devscripts/-/archive/v$pkgver/devscripts-v$pkgver.tar.gz"
builddir="$srcdir/devscripts-v$pkgver/scripts"

prepare() {
	default_prepare

	sed -i "s/###VERSION###/$pkgver/" checkbashisms.pl

	mv checkbashisms.pl checkbashisms
	mv hardening-check.pl hardening-check
}

check() {
	printf '#!/bin/sh\necho "hello world"\n' > ./testfile
	perl ./checkbashisms --version
	perl ./checkbashisms ./testfile
}

package() {
	depends="
		checkbashisms=$pkgver-r$pkgrel
		$pkgname-hardening-check=$pkgver-r$pkgrel
		"

	# only these useful for now
	install -Dm755 -t "$pkgdir"/usr/bin/ \
		checkbashisms \
		hardening-check

	install -Dm644 checkbashisms.1 \
		-t "$pkgdir"/usr/share/man/man1/
	install -Dm644 checkbashisms.bash_completion \
		"$pkgdir"/usr/share/bash-completion/completions/checkbashisms
}

checkbashisms() {
	pkgdesc="$pkgdesc (checkbashisms)"
	depends="perl"

	amove usr/bin/checkbashisms
}

harden() {
	pkgdesc="$pkgdesc (hardening-check)"
	depends="perl"

	amove usr/bin/hardening-check
}

sha512sums="
b8e103305a75bd9e416b5924109e31e2a9e8b2575adb54a856688e449cfdbae64ebcc4c34c88ab13c46754aa8fe79996ee75459721b972aae3bfad474883a6a8  debian-devscripts-2.25.13.tar.gz
"
