# Template file for 'apk-tools'
pkgname=apk-tools
version=3.0.8
revision=1
short_desc="Package manager for apk packages"
maintainer="finwo <finwo@pm.me>"
license="GPL-2.0-only"
homepage="https://gitlab.alpinelinux.org/alpine/apk-tools"
distfiles="https://gitlab.alpinelinux.org/alpine/apk-tools/-/archive/v3.0.8/apk-tools-v3.0.8.tar.gz"
checksum=e81c64a6e7c3806d45d4622c253e757aee970be84048554fa0eed79310e9453e
depends="zlib openssl"
makedepends="zlib openssl"
hostmakedepends="muon"

# Notes:
# - Same version the host manager was built from (v3.0.8); target and host
#   stay on one version until there is a reason to diverge.
# - muon (build/host/bin, on PATH via the driver) configures, ninja builds;
#   out-of-tree in ${WORK}/build, DESTDIR install.
# - url_backend=libfetch (in-tree, no extra package) over wget; crypto
#   openssl (zlib + openssl come from the sysroot via PKG_CONFIG_PATH).
# - Disabled: docs (needs host scdoc), help/lua/python (needs lua/python),
#   tests (CI runs upstream's suite, not the target build), zstd (no zstd
#   package; our artifacts are gzip). No on-device man pages or embedded
#   help DB yet - revisit when the operator story needs them.

do_configure() {
  mkdir -p "${WORK}/build"
  cd "${WRKSRC}"
  muon setup \
    -Dprefix=/usr \
    -Ddocs=disabled \
    -Dhelp=disabled \
    -Dlua=disabled \
    -Dpython=disabled \
    -Dtests=disabled \
    -Dzstd=disabled \
    -Durl_backend=libfetch \
    -Dcrypto_backend=openssl \
    "${WORK}/build"
}

do_build() {
  ninja -C "${WORK}/build"
}

do_install() {
  DESTDIR="${DESTDIR}" ninja -C "${WORK}/build" install
}
