summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c49ac273d4df0d05db79d5aa71960c6330f08e04 (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
96
# Maintainer: Gesh <gesh@gesh.uni.cx>
# Contributor: Ashwin Vishnu <9155111+ashwinvis@users.noreply.github.com>
# Contributor: Ashwin Vishnu <ashwinvis+gh@protonmail.com>
# Contributor: Doron Behar <doron.behar@gmail.com>

pkgname=pandoc-crossref-static-git
_pkgname="${pkgname%-static-git}"
pkgver=0.3.17.0.r15.g2dfb0d5
_pandoc_type=version
_pandoc_ver=3.1.13
_pandoc_commit=ab2b5e8bcd510542260c938d1c676bfc72bafe77
pkgrel=1
pkgdesc="Pandoc filter for cross-references (static build)"
url="https://github.com/lierdakil/pandoc-crossref"
license=("GPL-2.0-or-later")
arch=('x86_64')
conflicts=("pandoc-crossref")
provides=("$_pkgname=${pkgver%%.r*}")
replaces=('pandoc-crossref-bin' 'pandoc-crossref-static' 'pandoc-crossref-lite')
depends=("pandoc=$_pandoc_ver")
makedepends=('git' 'stack' 'pandoc' 'yq')
source=("$pkgname::git+$url.git")
sha256sums=('SKIP')

pkgver() {
    cd "$pkgname"
    git describe --match='*[0-9]' --tags --long \
        | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

_bumpVer() {
    yq -i --yaml-output --arg pkg "$1" --arg ver "$2" \
        "$(cat <<'EOF'
        (."extra-deps".[]
        | strings
        | select(match("^\($pkg)-[0-9.]+")))
        |= $pkg + "-" + $ver
EOF
)" stack.yaml
}

prepare() {
    cd "$pkgname"
    stack config set resolver lts-22.13 # ghc-9.6.4
    _bumpVer texmath 0.12.8.8
    _bumpVer typst 0.5.0.3
    _bumpVer typst-symbols 0.1.6

    # if pandoc updates break the golden tests, cf
    # https://github.com/lierdakil/pandoc-crossref/pull/403#issuecomment-1732434519
    # for how to bump
    verPat='\([0-9]\+\.\)\{1,3\}[0-9]\+'
    sedscript=''
    case "$_pandoc_type" in
    stock) return;;
    commit)
        sedscript+="/ pandoc-$verPat/{"
        sedscript+='s#pandoc.*#github: jgm/pandoc#;'
        sedscript+="a\  commit: $_pandoc_commit"$'\n'
        sedscript+='}'
        ;;
    version)
        sedscript+="s/ pandoc-$verPat/ pandoc-$_pandoc_ver/;"
        sedscript+="s/ pandoc-cli-$verPat/ pandoc-cli-$_pandoc_ver/;"
        ;;
    esac
    sed -i "$sedscript" stack.yaml
    _pandoc_bound=$(awk -F. '/[0-9]+\./{$NF++;print}' OFS=. <<<"${_pandoc_ver}")
    sed -i "/, pandoc /s#<.*#<$_pandoc_bound#" \
        pandoc-crossref.cabal package.yaml
}

check() {
    cd "$pkgname"

    stack test
}

build() {
    cd "$pkgname"

    stack setup
    stack build \
        --install-ghc \
        --ghc-options='-fdiagnostics-color=always' \
        --flag 'pandoc:embed_data_files' \
        --fast
    pandoc -s -t man docs/index.md -o pandoc-crossref.1
}

package() {
    cd "$pkgname"
    stack install --local-bin-path "$pkgdir/usr/bin"
    install -Dm644 pandoc-crossref.1 \
        "${pkgdir}"/usr/share/man/man1/pandoc-crossref.1
}