# Template file for 'xbps-beta'
pkgname=xbps-beta
version=0.51.90
revision=1
build_style=configure
short_desc="The XBPS package system utilities"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="https://github.com/voidlinux/xbps"
license="2-clause-BSD"
distfiles="https://github.com/voidlinux/xbps/archive/$version.tar.gz"
checksum=5e768a708843afc8cd2218465868235acfd978428188e0e156a46bc07f3f3f0c
wrksrc=xbps-${version}
provides="xbps-${version}_${revision}"
replaces="xbps>=0"

CFLAGS="-Wno-error"

hostmakedepends="pkg-config"
makedepends="zlib-devel libressl-devel libarchive-devel"
depends="ca-certificates xbps-triggers libxbps-beta>=$version"

# xbps needs symbols from glibc-2.22
case "$XBPS_TARGET_MACHINE" in
	*-musl) : ;;
	*) depends+=" glibc>=2.22" ;;
esac

do_configure() {
	HAVE_VASPRINTF=1 ./configure --prefix=/usr --sysconfdir=/etc --enable-debug \
		--bindir=/usr/bin
}
post_install() {
	case "$XBPS_TARGET_MACHINE" in
	aarch64*) # XXX different repo location
		echo "repository=https://repo.voidlinux.eu/current/aarch64" > \
			${DESTDIR}/usr/share/xbps.d/00-repository-main.conf
		;;
	*-musl) # XXX different repo location
		echo "repository=https://repo.voidlinux.eu/current/musl" > \
			${DESTDIR}/usr/share/xbps.d/00-repository-main.conf
		;;
	*)
		echo "repository=https://repo.voidlinux.eu/current" > \
			${DESTDIR}/usr/share/xbps.d/00-repository-main.conf
		;;
	esac
	vmkdir etc/xbps.d
	touch ${DESTDIR}/etc/xbps.d/.empty
}

libxbps-beta_package() {
	short_desc+=" - runtime library"
	provides="libxbps-${version}_${revision}"
	replaces="libxbps>=0"
	pkg_install() {
		vmove "usr/lib/*.so.*"
	}
}
libxbps-beta-devel_package() {
	short_desc+=" - runtime library (development files)"
	depends="zlib-devel libarchive-devel libxbps-beta>=${version}"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
		vmove usr/lib/pkgconfig
	}
}
