# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=dmraid
pkgver=1.0.0_rc16
_distver=3
pkgrel=6
pkgdesc="Device mapper RAID interface"
url="https://people.redhat.com/~heinzm/sw/dmraid/"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="lvm2-dev"
options="!check" # No tests to run
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://people.redhat.com/~heinzm/sw/dmraid/src/dmraid-${pkgver/_/.}-$_distver.tar.bz2
	001-do_not_use_p_for_partition.patch
	002-support_virtio_devices.patch
	003-isw-probe-hpa.patch
	004-activate_multiple_raid_sets.patch
	005-fix_isw_sectors_calculation.patch
	006-musl-libc.patch
	007-fix-loff_t-musl.patch
	lfs64.patch
	"
builddir="$srcdir/dmraid/${pkgver/_/.}-$_distver/dmraid"

prepare() {
	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-led \
		--enable-intel_led \
		--enable-shared_lib
	# parallel compilation fails due to faulty job ordering. Tries to link with
	# its shared libs before it's even compiled
	make -j1
}

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

sha512sums="
7c45e5117adc52fc2094b1b2bad4f4c518a46317a2196611966d72085ba3587c4ac8d1080f9d934888c01788f2b2d3d621c6f0d3e2a023c0fb1f9f3fa7fc127e  dmraid-1.0.0.rc16-3.tar.bz2
df1e285f404da61f9d15c9be3fae905599fb5d03203d3cd0551421b89913361d36524f9d2ee899eac9088c35daad9e8d6280a621c6a5832eec1a9be21bd05b12  001-do_not_use_p_for_partition.patch
1486aa76066e959d800506030f37392560e4953eb23fbcb65899ce76ef8e646639d5bd7abed8d9328e9a7f8dcc005fac4312528a8afcc806d228828a5d9b3fb9  002-support_virtio_devices.patch
b679ef5ff2671a8c8aa1a12feb54cfdfa6a40cbb0aef23e49b1ea5a8f97563061f9b207eeaf06da9fbb33837d9d04a4972869adc87eb89eb459aeb1c1e7bc5ee  003-isw-probe-hpa.patch
ce120d7313f7f1b563e95fd9b81e4eb5353edf416a521d2955b0bd7a0c08ec4c0a5da4402aa1690f65d2b4464d1f5fc534ec7819b07ee8791046b25f0209a21b  004-activate_multiple_raid_sets.patch
702cb4cf0edf79dbde9185cada12462681b52bffd5f8c4eab1b594ef754c964fb6c7f711ce77e4074167d920755fe0466d284f94fb272d60ea2314f2a45ef366  005-fix_isw_sectors_calculation.patch
1335297528df24faa292e4d80a57e23e3f910b669a92370e57a97bd4df443092323a91489c2cc1f17e3b280a3a7f0386bb7fed3a157cdab7ab55686e9d5e1ae4  006-musl-libc.patch
3fe66677b7bb3a314cabcab32d35192ddd5ec70e50398a37916197eb2818debf919fe48337fe9befb3a7d7ab727cbeed976413db89585f66fed7375cf9b36ac8  007-fix-loff_t-musl.patch
c33d8876951233d86f9cc900f1df0edfa1cf2ea9d970c877ffa3072ec1af04c20cceb00a0b11bac97b9d2ea6244cc91470949ca4693d3fd6a2c83636ecccc2f0  lfs64.patch
"
