# Template file for 'hfsprogs'
pkgname=hfsprogs
_distver=540.1
_patchver=3
version=${_distver}.linux${_patchver}
revision=2
wrksrc="diskdev_cmds-${version}"
hostmakedepends="clang"
makedepends="libressl-devel libuuid-devel"
short_desc="Apple's mkfs and fsck for HFS and HFS+ file systems"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="APSL-2.0"
homepage="http://www.opensource.apple.com/"
distfiles="http://cavan.codon.org.uk/~mjg59/diskdev_cmds/diskdev_cmds-${version}.tar.gz"
checksum=b01b203a97f9a3bf36a027c13ddfc59292730552e62722d690d33bd5c24f5497
nocross="clang can't link cross-compiled fsck_hfs"

pre_build() {
	sed -i 's/[F|f]sck_hfs/fsck.hfsplus/g' fsck_hfs.tproj/fsck_hfs.8
	sed -i 's/[N|n]ewfs_hfs/mkfs.hfsplus/g' newfs_hfs.tproj/newfs_hfs.8

	# Remove errant execute bits.
	find . -type f -name '*.[ch]' -exec chmod -c -x {} +
}

do_build() {
	make ${makejobs}
}

do_check() {
	./fsck_hfs.tproj/fsck_hfs 2>&1 | grep 'usage: fsck_hfs'
	./newfs_hfs.tproj/newfs_hfs 2>&1 | grep 'usage: newfs_hfs'
}

do_install() {
	vbin fsck_hfs.tproj/fsck_hfs fsck.hfs
	vbin newfs_hfs.tproj/newfs_hfs mkfs.hfsplus
	ln -s /usr/bin/fsck.hfs "${DESTDIR}"/usr/bin/fsck.hfsplus

	vman fsck_hfs.tproj/fsck_hfs.8
	vman newfs_hfs.tproj/newfs_hfs.8
	ln -s fsck.hfs.8 "${DESTDIR}"/usr/share/man/man8/fsck.hfs.8

	vlicense "${FILESDIR}"/APSL-2.0
}
