PKGNAME=util-linux-runtime
PKGSEC=utils
PKGDES="Utilities and management tools for Linux (runtime libraries)"
PKGDEP="cryptsetup"
PKGDEP__RETRO="glibc"
# We need the full dependency to build binaries.
BUILDDEP="asciidoctor coreutils file libcap-ng libeconf libutempter python-3 slang \
          systemd zlib"
# setcap and setpriv requires libcap-ng.
BUILDDEP__RETRO="coreutils file libcap-ng"

# Note: AUTOTOOLS_AFTER still used, but used in custom script.
ABTYPE=self
AUTOTOOLS_AFTER=(
    '--localstatedir=/run'
    '--disable-werror'
    '--disable-asan'
    '--disable-ubsan'
    '--disable-fuzzing-engine'
    '--enable-symvers'
    '--enable-largefile'
    '--enable-assert'
    '--enable-nls'
    '--disable-rpath'
    '--enable-asciidoc'
# FIXME: --disable-poman, this feature requires po4a but references a non-
# existent po4a.cfg in the build routine.
    '--disable-poman'
    '--enable-tls'
    '--enable-widechar'
    '--enable-libuuid'
    '--enable-libuuid-force-uuidd'
    '--enable-libblkid'
    '--enable-libmount'
    '--enable-libsmartcols'
    '--enable-libfdisk'
    '--enable-fdisks'
    '--enable-mount'
    '--enable-losetup'
    '--enable-zramctl'
    '--enable-fsck'
    '--enable-partx'
    '--enable-uuidd'
    '--enable-uuidgen'
    '--enable-blkid'
    '--enable-wipefs'
    '--enable-mountpoint'
    '--enable-fallocate'
    '--enable-unshare'
    '--enable-nsenter'
    '--enable-setpriv'
    '--enable-hardlink'
    '--enable-eject'
    '--enable-agetty'
    '--enable-plymouth_support'
    '--enable-cramfs'
    '--enable-bfs'
    '--enable-minix'
    '--enable-fdformat'
# Note: --disable-hwclock-cmos, the Linux Kernel provides the necessary
# interface for access to the hardware clock.
    '--enable-hwclock'
    '--disable-hwclock-cmos'
    '--enable-hwclock-gplv3'
    '--enable-mkfs'
    '--enable-fstrim'
    '--enable-swapon'
    '--enable-lscpu'
    '--enable-lsfd'
    '--enable-lslogins'
    '--enable-wdctl'
    '--enable-cal'
    '--enable-logger'
    '--enable-whereis'
    '--enable-switch_root'
    '--enable-pivot_root'
    '--enable-lsmem'
    '--enable-chmem'
    '--enable-ipcmk'
    '--enable-ipcrm'
    '--enable-ipcs'
    '--enable-irqtop'
    '--enable-lsirq'
    '--enable-lsns'
    '--enable-rfkill'
    '--enable-scriptutils'
    '--enable-tunelp'
    '--enable-kill'
    '--enable-last'
    '--enable-utmpdump'
# Note: line was a demo provided by Mesa, which displays a triangle. `line' is
# not enabled in other distros.
    '--disable-line'
    '--enable-mesg'
# FIXME: raw(8) is no longer available as of Linux API headers 5.14.
#
# Ref: https://src.fedoraproject.org/rpms/util-linux/blob/rawhide/f/util-linux.spec#_965
#
# Ref: Commit in torvalds/linux.git ...
#      https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=603e4922f1c81fc2ed3a87b4f91a8d3aafc7e093
#
# Disable raw for all architectures, because linux/raw.h was deprecated since commit:
# 603e4922f1c81fc2ed3a87b4f91a8d3aafc7e093.
    '--disable-raw'
    '--enable-rename'
    '--disable-vipw'
    '--disable-newgrp'
# Note: chfn, chsh, login, nologin, su and vipw are provided by shadow.
    '--disable-chfn-chsh-password'
    '--disable-chfn-chsh'
    '--disable-chsh-only-listed'
    '--disable-login'
    '--disable-login-chown-vcs'
    '--disable-login-stat-mail'
    '--disable-nologin'
    '--enable-sulogin'
    '--disable-su'
    '--enable-runuser'
    '--enable-ul'
    '--enable-more'
    '--enable-pg'
    '--enable-setterm'
    '--enable-schedutils'
    '--enable-wall'
    '--enable-write'
    '--enable-bash-completion'
    '--enable-pylibmount'
    '--enable-pg-bell'
    '--enable-fs-paths-default=/usr/bin'
    '--enable-use-tty-group'
    '--disable-sulogin-emergency-mount'
    '--enable-usrdir-path'
    '--enable-makeinstall-chown'
    '--enable-makeinstall-setuid'
    '--enable-colors-default'
    '--with-util'
    '--without-selinux'
    '--without-audit'
    '--with-udev'
# Note:
# because the variable `CURSES_LIB_NAME` may be covered,
# so only one lib in ncursesw, ncurses and slang can be enabled
# ncursesw is more featured so ncurses and slang are disabled
# https://github.com/util-linux/util-linux/blob/v2.42/configure.ac#L1211
    '--with-ncursesw'
    '--without-ncurses'
    '--without-slang'
    '--with-tinfo'
    '--with-readline'
    '--with-utempter'
    '--with-cap-ng'
    '--with-libz'
    '--with-libmagic'
# Note: --without-user, libuser is needed for remote chsh, but we don't ship
# chsh from this package.
    '--without-user'
    '--with-btrfs'
    '--with-systemd'
    '--without-smack'
    '--without-econf'
    '--with-python=3'
    '--with-cryptsetup'
)

AUTOTOOLS_AFTER__RETRO=(
    "${AUTOTOOLS_AFTER[@]}"
    '--without-python'
    '--disable-asciidoc'
    '--disable-pylibmount'
# Note: No need for the following on Afterglow.
    '--disable-zramctl'
    '--disable-plymouth_support'
    '--disable-cramfs'
    '--disable-bfs'
    '--disable-minix'
    '--without-cryptsetup'
)

PKGREP="util-linux<=2.39.3-2"
PKGBREAK="util-linux<=2.39.3-2"

# Needed by Afterglow, whereas FAIL_ARCH defaults to mainline-only.
FAIL_ARCH="!(mainline|retro)"
