# util-linux-libs - libblkid, libmount and libuuid only
# Generated from manifest.tsv by gen-ports.py. Edit the manifest, not this file,
# unless the package needs something the template cannot express - in which case
# drop a `recipe.local` beside it and it will be preserved.
name=util-linux-libs
version=2.42.1
release=3
desc="libblkid, libmount and libuuid only"
url="https://github.com/util-linux/util-linux"
license="LGPL-2.1-or-later"
depend="glibc"
makedepend=""
source="https://kernel.org/pub/linux/utils/util-linux/v2.42/util-linux-2.42.1.tar.xz"
sha256="SKIP"

build() {
	cd "util-linux-2.42.1"
	# Not every configure script accepts the same options - sqlite rejects
	# --disable-nls outright, for instance - so only pass the ones this one
	# actually advertises. Guessing wrong fails the whole build.
	# --disable-all-programs, and then the three libraries back on by name.
	#
	# This package is called util-linux-libs and its description says
	# "libblkid, libmount and libuuid only", and it was doing a full
	# `make install`: the whole util-linux program set landed in it -
	# dmesg, kill, mount, su, agetty and, fatally, /bin/login.
	#
	# busybox provides /bin/login as an applet symlink and busybox links
	# nothing. util-linux's login links libpam, which ScrapLinux does not have
	# and does not build. So installing this package - which every base
	# install does, because libblkid and libmount are what mount and the
	# installer need - replaced a working login with one that could not
	# start, and the first boot of a finished install could not be logged
	# into:
	#
	#   scraplinux login: apiwo
	#   /bin/login: error while loading shared libraries: libpam.so.0
	#
	# The package now builds what its own name says it builds.
	_opts="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib"
	_opts="$_opts --disable-all-programs"
	_opts="$_opts --enable-libblkid --enable-libmount --enable-libuuid"
	_opts="$_opts --enable-libfdisk --enable-libsmartcols"
	_help=$(./configure --help 2>/dev/null)
	case "$_help" in *--disable-static*)  _opts="$_opts --disable-static" ;; esac
	case "$_help" in *--disable-nls*)     _opts="$_opts --disable-nls" ;; esac
	# shellcheck disable=SC2086
	./configure $_opts
	make -j"$JOBS"
}

package() {
	cd "util-linux-2.42.1"
	make DESTDIR="$pkgdir" install
	# Belt and braces. --disable-all-programs is what stops them being
	# built; this is what proves none reached the package, because a
	# single stray /bin/login here is an install nobody can log into.
	rm -rf "$pkgdir/bin" "$pkgdir/sbin" "$pkgdir/usr/bin" "$pkgdir/usr/sbin"
	true
}
