aboutsummaryrefslogtreecommitdiffstats
path: root/community/shellcheck/APKBUILD
blob: 8d978522af83d00510499090ec0bea1d8b894b42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Maintainer: Olliver Schinagl <oliver@schinagl.nl>
pkgname=shellcheck
pkgver=0.6.0
pkgrel=0
pkgdesc="a static analysis tool for shell scripts"
url="https://github.com/koalaman/shellcheck"
arch="x86_64" # Limited by GHC / Cabal
license="GPL-3.0"
makedepends="cabal ghc"
subpackages="$pkgname-doc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/koalaman/shellcheck/archive/v$pkgver.tar.gz
	cabal.config
"
_cabal_home="$srcdir/dist"

cabal_update() {
	msg "Freezing $pkgname dependencies"

	# Resolve deps and generate fresh cabal.config with version constraints.
	HOME="$_cabal_home" cabal update
	(
		cd "$builddir"
		unlink "cabal.config"
		HOME="$_cabal_home" cabal freeze --shadow-installed-packages

		# Add version tag at the first line.
		sed -i "1i--$pkgver" "cabal.config"

		mv "cabal.config" "$startdir/"
	)

	if ! abuild checksum; then
		die "Failed to update checksum, run 'abuild checksum' manually"
	fi
}

prepare() {
	default_prepare

	if [ "$(head -n 1 "$srcdir/cabal.config")" != "--$pkgver" ]; then
		die "Requirements file is outdated, run 'abuild cabal_update'"
	fi

	ln -sf "$srcdir/cabal.config" "$builddir/cabal.config"
}

build() {
	HOME="$_cabal_home" cabal update
	HOME="$_cabal_home" cabal install \
	                            --disable-documentation \
	                            --only-dependencies
	HOME="$_cabal_home" cabal configure \
	                            --prefix='/usr' \
	                            --bindir='$prefix/bin' \
	                            --docdir='$prefix/share/doc' \
	                            --datadir='$prefix/share' \
	                            --htmldir='$docdir/html' \
	                            --libdir='$prefix/lib' \
	                            --libsubdir="$pkgname" \
	                            --datasubdir="$pkgname" \
	                            --dynlibdir="$pkgname" \
	                            --sysconfdir='/etc' \
	                            --disable-library-profiling \
	                            --disable-profiling \
	                            --disable-shared \
	                            --enable-executable-stripping \
	                            --flags='GMP FFI standalone'
	HOME="$_cabal_home" cabal build
}

check() {
	_test_script="$(mktemp)"
	{
		echo "#!/bin/sh"
		echo
		echo "exit 0"
	} > "${_test_script}"
	trap 'rm "$_test_script"' EXIT
	"$builddir/dist/build/$pkgname/$pkgname" "$_test_script"
	trap - EXIT
	rm "${_test_script}"
}

package() {
	HOME="$_cabal_home" cabal copy --destdir="$pkgdir"

	rm -r "$pkgdir/usr/lib/$pkgname"

	mkdir -p "$pkgdir/usr/share/doc/$pkgname"
	mv "$pkgdir/usr/share/doc/LICENSE" "$pkgdir/usr/share/doc/$pkgname"
}

sha512sums="4e9575985fe914cb35444995212ac1afaa40b004dbbc86b5987bf8b65e20b14a0102c9c601dc061d604129a8e978021f22a11d682545cb7f07ec974495cfa387  shellcheck-0.6.0.tar.gz
087d7e5196c911dd1bd97f45cca7984e10b9e02aa160e25cc85576f97afe9f05eaaf38a3fe59f0f8bdbd80528bbc436dbb2c386b9194e317698b5bc0348ef3f1  cabal.config"