# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libblockdev
pkgver=3.1.1
pkgrel=2
pkgdesc="Library for manipulating block devices"
url="https://github.com/storaged-project/libblockdev"
arch="all"
license="LGPL-2.1-or-later"
makedepends="
	bash
	coreutils
	cryptsetup-dev
	e2fsprogs-dev
	eudev-dev
	glib-dev
	gobject-introspection-dev
	keyutils-dev
	kmod-dev
	libbytesize-dev
	libnvme-dev
	lvm2-dev
	ndctl-dev
	nss-dev
	parted-dev
	python3
	volume_key-dev
	yaml-dev
	"
subpackages="$pkgname-dev py3-$pkgname:_py3:noarch"
source="https://github.com/storaged-project/libblockdev/releases/download/$pkgver-1/libblockdev-$pkgver.tar.gz
	fix-glibc-glob-onlydir.patch
	"

build() {
	CFLAGS="$CFLAGS -flto=auto -Wno-error" \
		./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

_py3() {
	pkgdesc="$pkgdesc - python3-bindings"

	amove usr/lib/python*
}

sha512sums="
44628d9e68a467f8a5d5e65e12d5d6ffb4d9b953c846acd9f6da257eab5ccd79309651d6b20092fa700fb4340f1f718ceef11141203da676d088824aa9d03481  libblockdev-3.1.1.tar.gz
199b184b2955a49320f2d8dd71be31507f170a21652c8dbc5d2821b5a451d8252402c4a14f8c0cef6b95c8a9ae85a6f385d5b9720d2d683b3b41fe1a056fc438  fix-glibc-glob-onlydir.patch
"
