# Template file for 'xz'
pkgname=xz
version=5.8.4
revision=1
short_desc="General-purpose data compression library and tools"
maintainer="finwo <finwo@pm.me>"
license="0BSD"
homepage="https://tukaani.org/xz/"
# NOTE: TOFU pin from the GitHub release asset. Deliberately modern
# (5.8.x): anything at/below 5.6.1 is unacceptable (2024 backdoor).
distfiles="https://github.com/tukaani-project/xz/releases/download/v5.8.4/xz-5.8.4.tar.gz"
checksum=0014c7886930454fe8bd4228665b51af55eeae560ea135c9c4cd33f55b2591d9
# glibc + busybox first: the post-install runs /sbin/ldconfig under
# /bin/sh (ordering, not just runtime truth - see libmnl).
depends="glibc busybox"

# Notes:
# - Shared-only per packages/README.md. Sysroot seed (second install +
#   .pc prefix rewrite) so grub's configure links under the sysroot.
# - Every UNOS library package carries the ldconfig post-install.

do_configure() {
  cd "${WRKSRC}"
  ./configure --prefix=/usr --disable-static
}

do_build() {
  cd "${WRKSRC}"
  make -j"$(nproc)"
}

do_install() {
  cd "${WRKSRC}"
  make install DESTDIR="${DESTDIR}"
  make install DESTDIR="${SYSROOT}"
  # .la files are build-time libtool metadata, never shipped
  rm -f "${DESTDIR}"/usr/lib/*.la "${SYSROOT}"/usr/lib/*.la
  [ -f "${SYSROOT}/usr/lib/pkgconfig/liblzma.pc" ] || die "xz: no sysroot .pc"
}
