# Forked from Alpine for providing a version with systemd
maintainer="Robert Eckelmann <longnoserob@postmarketos.org>"
pkgname=open-iscsi
_pkgver=2.1.10
pkgver=9999$_pkgver
pkgrel=4
pkgdesc="High performance, transport independent, multi-platform iSCSI initiator"
url="https://www.open-iscsi.com"
arch="all"
license="GPL-2.0-only"
makedepends="cmake kmod-dev libmount linux-headers openssl-dev>3
	open-isns-dev util-linux-dev meson bash perl systemd-dev"
depends="systemd-libs"
options="!check"
subpackages="$pkgname-dev $pkgname-libs $pkgname-doc $pkgname-systemd $pkgname-udev"
install="$pkgname.post-install"
source="$pkgname-$_pkgver.tar.gz::https://github.com/open-iscsi/open-iscsi/archive/$_pkgver.tar.gz
	iscsid.conf
	musl-fixes.patch
	add-missing-headers.patch
	dont-use-lib64.patch
	remove-werror.patch
	0001-make-shell-scripts-POSIX-compatible.patch
	"
builddir="$srcdir/open-iscsi-$_pkgver"

build() {
	# musl doesn't have glob_onlydir but by spec it's also not guaranteed to return only dirs anyway
	CFLAGS="$CFLAGS -DGLOB_ONLYDIR=0" \
	abuild-meson \
		-Db_lto=true \
		-Drulesdir="/usr/lib/udev/rules.d" \
		. output
	meson compile -C output
}

check() {
	meson test --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	install -Dm644 "$srcdir"/iscsid.conf "$pkgdir"/etc/iscsi/iscsid.conf
	rm "$pkgdir"/etc/iscsi/initiatorname.iscsi
}

sha512sums="
18b92d3e9a85d8de66734d95e9ca74a8acc5167a98830134c18ad5e226b29a00d358f952edfab67b643c454ec63c0a382c7ab7e7e76970f7574b46cea0d5c82d  open-iscsi-2.1.10.tar.gz
4cc7c1923047616d908806aab96d468cb7b99ff9f8a9e02a039866b66db4ae856bd9f414854712d8a57c21614674f4468736bce26a4199c2ff054a165bca26e0  iscsid.conf
1b89ffd6de0dc7bb63fc2702a97e49df4369158c66ee609acfc041b1677c07fbd964b7a709f1f324fa51a9842d4d3e11611d9783e18d526372d468163c0ac8db  musl-fixes.patch
104b559eb368459a7151657fbca63927b6b1032bda272e903a1633c8b9d3ed199f2c5cca0e6741bcd5fa6e860d1ff2d111caf58d60d9f0a736ad767e8ae0427b  add-missing-headers.patch
86a9c4be4abd34821f156f9df586c530dc2b0efc96e961cb15fd22846856cc1e76aae85806e8d0eb9f3d3e3acd7f73fe8d2a1de8944903b503e256e6a99bb2dd  dont-use-lib64.patch
d99ef789d1aab1e7ba81e3f2b334a9518f1174cd53b4600bfd7e866973cdfa87664b2161c994ae7c35526a7d9165e0e2b3036f7dacc139b90fa3d0a90b6f6599  remove-werror.patch
e0cdca47e4dd4ca6684ab7ccae49a06253a7bc3de722a8239f692ee84431d8a63d4411f8584976d13f2907911551bf0d5871a315bd4d9f72e61b9654b34cb29b  0001-make-shell-scripts-POSIX-compatible.patch
"
