APP=util-linux
VERSION=2.33
BUILD=2sml
HOMEPAGE="https://github.com/karelzak/util-linux"
DOWNLOAD="https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.33/util-linux-2.33.tar.xz"
DESC="a huge collection of essential utilities"
REQUIRES="readline zlib xz kmod eudev"

build() {
  mkandenterbuilddir
  rm -rf $APP-$VERSION

  tar xf $SRCDIR/$APP-$VERSION.tar.?z*
  cd $APP-$VERSION
  fixbuilddirpermissions

  # Thank you sabotage linux
  patch -p1 < $SRCDIR/cal.patch

  CFLAGS="$CFLAGS -include sys/sysmacros.h" \
  LDFLAGS="-lcurses -lterminfo" \
  ./configure \
    --prefix="" --sbindir=/bin --libdir=/lib \
    --includedir=/include \
    --disable-silent-rules \
    --disable-nls --disable-fsck\
    --enable-libmount-support-mtab \
    --disable-fdformat --disable-hwclock --disable-switch-root \
    --disable-kill --disable-login --disable-sulogin --disable-su\
    --disable-more --disable-pg --disable-agetty \
    --without-systemd --disable-wdctl --enable-libuuid \
    --enable-libblkid --enable-libmount --disable-uuidd \
    --enable-static-programs="mount,umount" \
    --without-python

  sed -i 's,/sbin,/bin,' config.status
  ./config.status

  make
  make install DESTDIR=$PKG

  # libuuid.la is required by gegl
  cp .libs/libuuid.la $PKG/lib/

  # Replace dynamically-linked mount with statically-linked mount
  (
  cd $PKG/bin
  mv mount.static mount
  mv umount.static umount
  )

  cp COPYING $PKGDOCS/

  # rev is provided by busybox which is statically-linked
  rm $PKG/bin/rev

  mkfinalpkg
}

SHA512SUMS="
41c95705c06e8794140091c41e62a3eb7c6a62c86bb2415dad53a19ed26f9ff849fb400cb87d5650ff6ff7b89d170d3139b04931f8c4b5c7257b724b61fa7da4  util-linux-2.33.tar.lz
ab3ab93642f6feaaba4d1125d5f213d7aa322cfa3396553b418a738a7f9bcdffd20d6c5ba272a6e72a52ec10349d21400791a47a9c5c1c879c311435b8db79fa  cal.patch
"
