# Template file for 'fakeroot'
pkgname=fakeroot
version=1.37.1.1
revision=1
build_style=gnu-configure
configure_args="--disable-static"
hostmakedepends="automake libtool"
makedepends="acl-devel libcap-devel"
#checkdepends="sharutils"
short_desc="Gives a fake root environment"
maintainer="Piraty <mail@piraty.dev>"
license="GPL-3.0-or-later"
homepage="https://salsa.debian.org/clint/fakeroot"
distfiles="https://salsa.debian.org/clint/fakeroot/-/archive/upstream/${version}/fakeroot-upstream-${version}.tar.gz"
checksum=caeef85642445245e4e994ce3633d21718a0baf16d5398e280b3149cbfcfae35

lib32disabled=yes

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	CFLAGS="-D_STAT_VER=0"
fi

post_patch() {
	# always force absolute path for LD_PRELOAD
	vsed -i scripts/fakeroot.in -e 's/@LDPRELOADABS@/1/'

	# don't build translated manpages
	vsed -i doc/Makefile.am -e '/SUBDIRS/d'

	# disable failing tests
	#
	# depends on chown which doesn't work in chroot
	vsed -i test/Makefile.am \
		-e '/  t\.tar/d'
	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
		#mknod: Operation not permitted
		vsed -i test/Makefile.am \
			-e '/  t\.chmod_dev/d' \
			-e '/  t\.mknod/d'
		#ls doesn't report owner as root
		vsed -i test/Makefile.am \
			-e '/  t\.touchinstall/d'
		vsed -i configure.ac \
			-e 's/__${PRE}x${FUNC} _${PRE}x${FUNC} __${PRE}${FUNC}13 ${PRE}${FUNC}/${PRE}${FUNC}/'
	fi
}

pre_configure() {
	./bootstrap
}

pre_check() {
	export VERBOSE=x
}
