# Contributor: Mitch Tishmack <mitch.tishmack@gmail.com>
# Maintainer: Mitch Tishmack <mitch.tishmack@gmail.com>
pkgname=cabal
pkgver=1.24.0.2
pkgrel=1
pkgdesc="The Haskell Cabal"
url="http://haskell.org"
arch="armhf x86_64"
license="BSD-3-Clause"
depends="gmp zlib"
makedepends="ghc gmp-dev libffi-dev zlib-dev binutils-gold chrpath"
subpackages="$pkgname-doc"
source="
	cabal-0001-force-ld.gold.patch
	cabal-0002-busybox-od.patch
	cabal-0003-use-apkbuild-downloads.patch
	https://hackage.haskell.org/package/$pkgname-install-$pkgver/$pkgname-install-$pkgver.tar.gz
	https://hackage.haskell.org/package/mtl-2.2.1/mtl-2.2.1.tar.gz
	mtl.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/mtl-2.2.1/revision/1.cabal
	https://hackage.haskell.org/package/text-1.2.2.1/text-1.2.2.1.tar.gz
	text.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/text-1.2.2.1/revision/0.cabal
	https://hackage.haskell.org/package/parsec-3.1.9/parsec-3.1.9.tar.gz
	parsec.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/parsec-3.1.9/revision/0.cabal
	https://hackage.haskell.org/package/network-2.6.3.1/network-2.6.3.1.tar.gz
	network.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/network-2.6.3.1/revision/0.cabal
	https://hackage.haskell.org/package/network-uri-2.6.1.0/network-uri-2.6.1.0.tar.gz
	network-uri.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/network-uri-2.6.1.0/revision/0.cabal
	https://hackage.haskell.org/package/old-locale-1.0.0.7/old-locale-1.0.0.7.tar.gz
	old-locale.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/old-locale-1.0.0.7/revision/1.cabal
	https://hackage.haskell.org/package/old-time-1.1.0.3/old-time-1.1.0.3.tar.gz
	old-time.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/old-time-1.1.0.3/revision/1.cabal
	https://hackage.haskell.org/package/HTTP-4000.3.3/HTTP-4000.3.3.tar.gz
	HTTP.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/HTTP-4000.3.3/revision/0.cabal
	https://hackage.haskell.org/package/zlib-0.6.1.2/zlib-0.6.1.2.tar.gz
	zlib.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/zlib-0.6.1.2/revision/0.cabal
	https://hackage.haskell.org/package/random-1.1/random-1.1.tar.gz
	random.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/random-1.1/revision/1.cabal
	https://hackage.haskell.org/package/stm-2.4.4.1/stm-2.4.4.1.tar.gz
	stm.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/stm-2.4.4.1/revision/0.cabal
	https://hackage.haskell.org/package/async-2.1.0/async-2.1.0.tar.gz
	async.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/async-2.1.0/revision/0.cabal
	https://hackage.haskell.org/package/base16-bytestring-0.1.1.6/base16-bytestring-0.1.1.6.tar.gz
	base16-bytestring.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/base16-bytestring-0.1.1.6/revision/0.cabal
	https://hackage.haskell.org/package/base64-bytestring-1.0.0.1/base64-bytestring-1.0.0.1.tar.gz
	base64-bytestring.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/base64-bytestring-1.0.0.1/revision/0.cabal
	https://hackage.haskell.org/package/cryptohash-sha256-0.11.100.1/cryptohash-sha256-0.11.100.1.tar.gz
	cryptohash-sha256.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/cryptohash-sha256-0.11.100.1/revision/0.cabal
	https://hackage.haskell.org/package/ed25519-0.0.5.0/ed25519-0.0.5.0.tar.gz
	ed25519.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/ed25519-0.0.5.0/revision/2.cabal
	https://hackage.haskell.org/package/tar-0.5.0.3/tar-0.5.0.3.tar.gz
	tar.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/tar-0.5.0.3/revision/0.cabal
	https://hackage.haskell.org/package/hashable-1.2.4.0/hashable-1.2.4.0.tar.gz
	hashable.cabal-$pkgver-$pkgrel::https://hackage.haskell.org/package/hashable-1.2.4.0/revision/0.cabal
	https://hackage.haskell.org/package/hackage-security-0.5.2.2/hackage-security-0.5.2.2.tar.gz
	hackage-security.cabal-$pkgver-$pkgrel::http://hackage.haskell.org/package/hackage-security-0.5.2.2/revision/2.cabal
	"
builddir="$srcdir/$pkgname-install-$pkgver"

prepare() {
	cd "$srcdir"
	default_prepare

	# Copy .cabal files to their proper package.cabal names
	for c in $(find "$srcdir" -name "*.cabal-$pkgver-$pkgrel" -print); do
		msg "cp $c $(echo $c | sed -e 's/[.]cabal[-].*/\.cabal/g')"
		cp $c $(echo $c | sed -e 's/[.]cabal[-].*/\.cabal/g')
	done
}

build() {
	cd "$builddir"
	env HOME="$builddir" NO_DOCUMENTATION=1 EXTRA_CONFIGURE_OPTS="" ./bootstrap.sh
}

package() {
	cd "$builddir"

	install -m 755 -D dist/build/cabal/cabal "$pkgdir/usr/bin/cabal"
	chrpath -d "$pkgdir/usr/bin/cabal"

	install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

sha512sums="735a1aa9084d7eb7297076587cf2896af2951d4a2ecc20c5a6758a91c3751f5c212b65668befc25cfbc273633041543bda3da0fe9cee59795eeb3f40b3fb4922  cabal-0001-force-ld.gold.patch
103f404ed135e14118ee41c1ce960597912998792af520ab3314cda3db4d4285cbd4c44b2fcc8cea7beee07d2cb0bfd6b2d3e8978e3bdb9897ec2f56e814f7b0  cabal-0002-busybox-od.patch
2931021267f601427a3ad2a1a6589f9ab2dce75de3f9fa06e53c8a93748d45fb87c1f76e23ab080f2100c29dd89d4c542f8f78f149ba116ffd4ebb47730c9726  cabal-0003-use-apkbuild-downloads.patch
bd055a52ff0ac697e6f21a588d53dd811d50ee9410659a242c00a5665b360ef10c024df4872b9070c33aa49f779c8817b883b40087d3f4e0be4096a54b2ad5f0  cabal-install-1.24.0.2.tar.gz
5c31626b15551ee1757ad701b8e5552202bb6fe1dbd002039e3b78c6d01108a5c50f565c4993d165a00eb564d9d72fb8d2aae891b6242f0ca8cb11f7b95c5c6b  mtl-2.2.1.tar.gz
f3e4665db8aba4aa85c5fc504d7e3aec4474aa497cbf081d8c73bf0bf46b54a00de60acc2b42c821cc4d3f4f5c12c65f7fa421181827c75b09def7d9fb7bf843  mtl.cabal-1.24.0.2-1
f0615f7614127d86dbfb3fba5dd1753af3d0774c46e11ee4a99d4510f73b59cf1bd8c73ca0387dba4fbcea3936aaaf0e92561cf6aab1a98d08fcad481d3795e4  text-1.2.2.1.tar.gz
a90e248e697f853f813db9e6278a394c991a41ceb40e92a9713f453abf3463cd5d38dcd6214c7cf1e2bfc2291972766f788226d520e5283f75871975e1cee193  text.cabal-1.24.0.2-1
bc5209813ad0742c68c275f0ecd3e284b6249d2651f75daf16ad9a776003591217eb7d47fdaad88530af90455fe7d3e014c3c1d7d0893482721d4997b23a2d16  parsec-3.1.9.tar.gz
59f5265437bac81f555065e3434bca5a0ccb88512c1c4339b8b7b3da26fcb12fff7a8f99e4202ada02d4d0f0fd3eed99457679ccb6b815e682577841fcebe0be  parsec.cabal-1.24.0.2-1
3c23ef0a1bf5383cc2479a517875037f9de38c79c1293734cc723111ab880a5842e091ee91a612090d0a2e422d53028d17cf5b0800af0d1d6c983d564197b9a6  network-2.6.3.1.tar.gz
a0c5deb6fa450d3f368cb6578ed7c1139509e8279bac18d25b0094544eaccf2f429c6e65ea454efc20576d316057c3b02a3e5622ed58bb9014297fa09183fde1  network.cabal-1.24.0.2-1
c1b6e516cd19875aab0da325dcb8f5c6b98d43c3952bda4f96bd9c798882357c724b2facbef09e2e98d29b696a9e5518a2de9463fb0af4c5df0734fe2654cc24  network-uri-2.6.1.0.tar.gz
03e07ba42e7e0699b77e78fe4c3fc76dc1f8840d8478ecb804c9d33e48323fce3f9bccad70e9ef12dda855a503d86209b9039854a0a1e577525b43b43098dd49  network-uri.cabal-1.24.0.2-1
34d018cb040de9adce3ddb8cffabe2a0610f6cd0ff5340ee721b7076671bd5cc3e830f58d16e73240df4b068510f7a24fd1995efc38f002b52d228abc4581d6a  old-locale-1.0.0.7.tar.gz
5efe4be2b309bf30e7ff6796e84a9dabc0106f64046cd1aa6ace67abf39cfd47dcf3e9a6c3b4f44f47b1f5fce7a1b928524052d5e16afbd77c8200f8f02ab090  old-locale.cabal-1.24.0.2-1
a701c62266f9f3c6dc60eba970b6c25a61bf82b6b8bb6b0073e0e44908598926fe7813a7ae1b1f9da98e4861a8f0565d0bd025cb97307b71c08cb9b0b2e321bb  old-time-1.1.0.3.tar.gz
9d287b87bad23ab46c1692b81c14996e04742b77d1949c2aecfd60a9399db3dcd84603c3e122635beb19d56b31ef3e93d9cf501e0f9133e88222f4c614e0734a  old-time.cabal-1.24.0.2-1
4e43efef355f4194ff7a29542babc9dd873f73b1a94092c83a882d79533704ba47be9320bd715425c56515d1709d729adc9ed1e5c273d39e9879f03304eeb7e7  HTTP-4000.3.3.tar.gz
87f02cc9fc5eec9114c269c8448f7450c8e926fd1e64a227a7b9d03c40714afb075e061fb26f3395d0ccee90321a919796c4ed2ebd8c03bb99f5193fea485e60  HTTP.cabal-1.24.0.2-1
0034eb1297eaf20ab64e5cbfc835cee1985d34bc248325bf57f7bf5cdf2918ab72f339fe5b8b3f5f16dee862f190e0c71612960b9021cf2ca70c951788b73fc1  zlib-0.6.1.2.tar.gz
8df23c6989663d1abd8aa5854bafeb8496188f1dcacbecab21343c122fae518941bf05a7d80e6ca4c5333a4e71dc6739f0dad96a8c1866353875d663a5e460b3  zlib.cabal-1.24.0.2-1
7f128b1c88adfe7ee6405578d3c999bb77e9e3c21e16f82a5197c0ad1d6731851e99e08d8169c6a8b1068ad8a1614c1c0ef8c04c1958337a6e325f1de0c718a3  random-1.1.tar.gz
cccc9fe05ec22db1e9e1399c9807e49f1312211fb9739a2ae3a455cc2fd00c1d9a74e64380541d83bb9b34fb02f00d80c67f2c1368ff7d1d631b7152b981d175  random.cabal-1.24.0.2-1
12a8edb7489995245fb21d9f0782cad87e992f56343d4492eef788370ebc2dcb934193d8602b85b5f3935c4bdb4c9426717b6149437cd7b0bb5311bda4b237eb  stm-2.4.4.1.tar.gz
3ee1168e333402123d35561a7f81467bc23d2cfc4d31180eb610e76d3d4017fea8401ebf6c9b0c602247c3f6929f4205ef823d5d4af6553828ed1ba23b6056db  stm.cabal-1.24.0.2-1
7c68218c7d63e6db31e626dbe7bacb44b0c24ba5a224afc70c09ed1f7b9d8ff8e1f932a97e34657b48db2d1ab4ed76d69c0ea6101cfc9afb8e8d40d617f37648  async-2.1.0.tar.gz
dba826ec9fdbf546e2bbd686d93fefe23c2f5a764ac80d0d932575e23d2ba44b5d932822e7d41e2520b59e0972c26b1476b5fb02397d842692de70007468547a  async.cabal-1.24.0.2-1
699bc1f7819a1c0cea0154626f8799301bc9360bc997a5e9313a605ec33ea04d77219b100693021fd43e01d8d979374db07e6e3fabef5301c411f335e30a8cba  base16-bytestring-0.1.1.6.tar.gz
7245e3101ef496313bab5e27f72a8fd8fde3942e838092b8a54b3a7cf918b3c818a88f73c96271c059fd97255fd513074b6c121132d9c3e6157da490be9150fa  base16-bytestring.cabal-1.24.0.2-1
6936b34955b89a275f5bd71c74bbad2be6ff9e2023ac652bdbc9c5b10dd624e3862fc348849858fdb5c7b8aacc36ab4cda8bc6ea797c129b6b28d7e2e2e610e7  base64-bytestring-1.0.0.1.tar.gz
f535e3bb7142c57b6f2e22e1f53f9e70f231568a7e3f2e574d49454604fa81be5c108cbff876d6027302b8b46a6524548f4cb290dc93d3e9fe324b1ab1746c9d  base64-bytestring.cabal-1.24.0.2-1
df6a8c7a4796f3b94faf0c1073b552eccf7dfbe6ab1489fef391e6342f34b3cb29991d1313aa5da11a90cb37bcd43c23eea12073ad4c7190926005de952c39e2  cryptohash-sha256-0.11.100.1.tar.gz
af2caec148a302861aa93decbf91a987bb3e10e60d97a2643da0ec08b1bcbd88f265b6196af75e9a5e92a80894249e9694e8a51ec0273ce6d5f482c5526f5398  cryptohash-sha256.cabal-1.24.0.2-1
cd2bb28de905c6d659f80f15e82970a9634c959432c73b6fd3b10ebca42a1ce734429e7ac861d0ab328904d99651a6d2fcaaf4d74ab75a3c0be68607e8f54ce9  ed25519-0.0.5.0.tar.gz
9e10bb302e48899dd80256a6ec76debc70a6c0789d2cd8694f413a2880fd3f14e3a3d40d5506ae0fa75c663f5dfa3a8eff612dae2249b4641a29fbfa62219035  ed25519.cabal-1.24.0.2-1
f90899e3a5fe097645e29b143cbf25ccf131f8b794bfea655e5b562369e4d7d492df78e53710d3ca4776233f07ace9335242eafbd3b4ba8d0e1d4664fd24a27d  tar-0.5.0.3.tar.gz
ba0dfcfa2211fd7ae41ef25492a5d1cee25f0e5a55779f9e6c2387a47e663402a5d59f46af4b22cc3148eb027183f9f060b9aa06189d1ce926ebad9fd4daa780  tar.cabal-1.24.0.2-1
992027ce617e347414e328e05afe69b8621fb1af21fef58836761d2002a1f9f7f97c981ff3c4fe8699a1da124771df575717ed4e3fd0bbe5c62d81be1322dbf6  hashable-1.2.4.0.tar.gz
7cd8b8a8998ef3d3bd6093c1b872fe0ba8a438abb7189d22df5bae291b5a3987a36cc647c43545ba7d2275512d31e9b77e9823da2431cf7402bfe3d26da77fc6  hashable.cabal-1.24.0.2-1
5adab3c46d7aada8668128ad8c9389ca65489eec776f8571b8ee5834d74b961f19b558cb6642cbb1891ee381b2d4f2019dddf29bad13607fe23bef49a3d6f535  hackage-security-0.5.2.2.tar.gz
844853ea8ebadad034f0ac7f59f2e800b87ee4b3625220a07b12212d8f83db320e8767cacb8e9d23afe41265e4eade63d20d78329cb009703d0f7de6b4278c21  hackage-security.cabal-1.24.0.2-1"
