# Template file for 'fakeroot'
pkgname=fakeroot
version=1.29
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="${DEBIAN_SITE}/main/f/fakeroot/${pkgname}_${version}.orig.tar.gz"
checksum=8fbbafb780c9173e3ace4a04afbc1d900f337f3216883939f5c7db3431be7c20

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
}
