# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=debian-devscripts
pkgver=2.23.7
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="https://ftp.debian.org/debian/pool/main/d/devscripts/devscripts_$pkgver.tar.xz"
builddir="$srcdir/devscripts/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="
d1cb527bc842f3f82413edb0f10dd90c3a7b362daeeca900cd998732989fe976abc04dd62760bfeda459bfc26eac0c038f59a8382759ae6c82b3cc745c20800f  devscripts_2.23.7.tar.xz
"
