# Contributor: Michael Zuo <muh.muhten@gmail.com>
# Contributor: Sora Morimoto <sora@morimoto.io>
# Contributor: Anil Madhavapeddy <anil@recoil.org>
# Contributor: omni <omni+alpine@hack.org>
# Maintainer: Kate <kit.ty.kate@disroot.org>
pkgname=opam
pkgver=2.3.0
pkgrel=0
pkgdesc="OCaml Package Manager"
url="https://opam.ocaml.org"
arch="all"
license="LGPL-2.1-only WITH OCaml-LGPL-linking-exception"
depends="curl patch unzip coreutils bubblewrap"
options="!check" # The tests use bubblewrap which cannot be run inside docker
makedepends="dune tar ocaml-compiler-libs"
checkdepends="rsync bash diffutils"
source="https://github.com/ocaml/opam/releases/download/$pkgver/opam-full-$pkgver.tar.gz"
subpackages="$pkgname-doc"
builddir="$srcdir/opam-full-$pkgver"

case "$CARCH" in
	riscv64|loongarch64)
		makedepends="${makedepends//ocaml/ocaml5}"
		;;
esac

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--with-mccs \
		--with-vendored-deps \
		--with-dune=/usr/bin/dune

	make -j1 all
}

check() {
	make tests
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}

sha512sums="
bda0d65bd567994460f058ac6f20a7139ec817de0708b065bae2554b423747349ed31c134f35e02beed2910f8b5e5078aafb39ce3f0f02df48f447e817f5fec2  opam-full-2.3.0.tar.gz
"
