# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=fakeroot
pkgver=1.36
pkgrel=0
provider_priority=100
pkgdesc="Gives a fake root environment, useful for building packages as a non-privileged user"
arch="all"
license="GPL-3.0-or-later"
url="https://packages.debian.org/fakeroot"
checkdepends="bash coreutils"
makedepends_build="libtool autoconf automake po4a"
makedepends_host="libcap-dev acl-dev linux-headers"
makedepends="$makedepends_build $makedepends_host"
subpackages="$pkgname-dbg $pkgname-doc"
source="https://deb.debian.org/debian/pool/main/f/fakeroot/fakeroot_$pkgver.orig.tar.gz
	fakeroot-no64.patch
	fakeroot-stdint.patch
	xstatjunk.patch
	fix-shell-in-fakeroot.patch
	fix-format.patch
	t-xattr.patch
	"

prepare() {
	default_prepare

	CONFIG_SHELL=/bin/sh ./bootstrap
}

build() {
	# musl does not have _STAT_VER, it's really not used for
	# anything, so define it as zero (just like uclibc does)
	export CFLAGS="-D_STAT_VER=0 $CFLAGS"

	CONFIG_SHELL=/bin/sh ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-static

	make
	cd doc
	po4a -k 0 --rm-backups --variable "srcdir=../doc/" po4a/po4a.cfg
}

check() {
	make check || {
		cat test/test-suite.log
		return 1
	}
}

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

sha512sums="
8c98b14fd4ab65649be54d9f6acf231f23bc0c1d04340bee0d3d26825f038623ab1a8ce211207d78a67e2c338fe115065068408dc42efd72579e206c11a0d3e9  fakeroot_1.36.orig.tar.gz
7eb500a64093e4f888adf6d0d5dacf62c3240f6940ebd894469753fd88804b9a2e7ce3bcbb73b6cd0693f92c507d86d70a332320af9f9ffed4de790b4f9c9e84  fakeroot-no64.patch
dee95b7d65e8e5a961d335af6b1f37bb92416fb7eb68b180582e982bb725ad3a5cc9f2526a4a19eec40ea449325f2d21491401ab2f222028926b4bc2279c1430  fakeroot-stdint.patch
a13c8fd7d8a4c69e1044b2ec54af1df0df997c39a561f394b001bce4e83a1334315ae093d7aa73e47d4f32b0358532d51793d701a174b45d52172260a56c9d10  xstatjunk.patch
47593b3d86a66bab832c50a1d967cdc70e42bbd9ef4436f18140067ccefdd6418516e5157102c67e604f3623ed1b9f4fe1423fc5dad4dfe5356fc250c12818a7  fix-shell-in-fakeroot.patch
3d5858080659e4430eb15353b5adb9cf668e56ea56789832a2498b507f9a6ca13161eb66e806d8ab0edfec36d5c93cc4374ffd2812ee400bbf093b99be723fae  fix-format.patch
03edaee13bc7b9fa96b25e8539fd637d046631d7b37404a28adff72bfe0188df0def344b1696dcfaec87b1224b6ad1909263c3879a9ec7d62b833bb488ff29ac  t-xattr.patch
"
