summaryrefslogtreecommitdiff
path: root/repo/pandoc/pandoc.xibuild
blob: 12d24061a646f825005d499f45455d32f624cc90 (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
#!/bin/sh

NAME="pandoc"
DESC="universal markup converter"

MAKEDEPS=" ghc cabal zlib libffi"

PKG_VER=2.19.1
SOURCE="https://hackage.haskell.org/package/pandoc-$PKG_VER/pandoc-$PKG_VER.tar.gz"

ADDITIONAL="
cabal.config
"

cabal_update() {
	echo "Freezing pandoc dependencies"

	# Resolve deps and generate fresh cabal.config with version constraints.
	cabal update
	(
		cd "$BUILD_ROOT"
		cabal v1-freeze --shadow-installed-packages

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

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

prepare() {
	apply_patches

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

	ln -sf "$BUILD_ROOT/cabal.config" "$BUILD_ROOT/cabal.project.freeze"
}

build() {
	cabal update
	cabal install --only-dependencies
	cabal configure \
		--prefix='/usr' \
		--enable-tests \
		--enable-split-sections \
		--ghc-option="-split-sections" \
		--flags="+embed_data_files -trypandoc +static"
	cabal build --jobs=${JOBS:-1}
}

check() {
	cabal test --jobs=${JOBS:-1}
}

package() {
	_bindir="$PKG_DEST/usr/bin"
	mkdir -p "$_bindir"
	cabal install \
		--installdir="$_bindir" \
		--install-method=copy
	install -Dm644 man/pandoc.1 "$PKG_DEST"/usr/share/man/man1/pandoc.1
}