# Contributor: Steeve Chailloux <steeve.chailloux@orus.io>
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Mitch Tishmack <mitch.tishmack@gmail.com>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=cabal-stage0
pkgver=3.10.3.0
pkgrel=0
# GHC version used to bootstrap cabal via the ./bootstrap.py script.
_bootstrapver=9.8.2
pkgdesc="Cabal version used for bootstrapping"
url="https://haskell.org/cabal"
arch="aarch64 x86_64" # Limited by GHC
license="BSD-3-Clause"
depends="gmp zlib !cabal"
makedepends="ghc~=$_bootstrapver gmp-dev libffi-dev zlib-dev python3"
options="!check"
source="$pkgname-$pkgver.tar.gz::https://github.com/haskell/cabal/archive/refs/tags/cabal-install-v$pkgver.tar.gz
	$pkgname-$pkgver-$_bootstrapver.tar.gz::https://dev.alpinelinux.org/archive/cabal-stage0/cabal-$pkgver-with-ghc-$_bootstrapver.tar.gz"
builddir="$srcdir/cabal-cabal-install-v$pkgver"

# Provide cabal-bootstrap for community/cabal.
# See comment in community/cabal for details.
provides="cabal-bootstrap"
provider_priority=1 # lowest

build() {
	export PATH="$PATH:/usr/lib/llvm14/bin"

	./bootstrap/bootstrap.py --bootstrap-sources \
		"$srcdir/$pkgname-$pkgver-$_bootstrapver.tar.gz"
}

package() {
	install -m 755 -D _build/bin/cabal "$pkgdir/usr/bin/cabal"
	install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

sha512sums="
8e8138567674c55beaa95786c8c621d9a7891e8941681958dc95f08a1f4c03d5dad6c91dcef41f078f3e90a0e3c50ac128406916f9863b253080332e75d456e7  cabal-stage0-3.10.3.0.tar.gz
ba8b8285c4c9a08fc9b0b944f916c8cb2fec4e65f4f23b350e8a7709152de8f7bb16c1ea51e230bccb06b1cda887fca6427ff1fc0efb28c2975392d6f03214d8  cabal-stage0-3.10.3.0-9.8.2.tar.gz
"
