summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fa5f7b113ba9c4f505e906e4a87ce5ede305aa4e (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
# Maintainer: Cristóbal Tapia <crtapia at gmail dot com>
pkgname=bibtex-tidy
pkgver=1.14.0
pkgrel=2
pkgdesc="BibTeX Tidy - Cleaner and Formatter for BibTeX files "
arch=('any')
url="https://github.com/FlamingTempura/bibtex-tidy"
license=('MIT')
depends=('nodejs')
makedepends=('npm' 'jq' 'txt2man')
source=("https://registry.npmjs.org/bibtex-tidy/-/$pkgname-$pkgver.tgz")
noextract=("$pkgname-$pkgver.tgz")
sha256sums=('0a2c1bb73911a7cee36a30ce1fc86feffe39b2d39acd4c94d02aac6f84a00285')

package() {
    npm install -g --prefix "$pkgdir/usr" "$srcdir/$pkgname-$pkgver.tgz"
    find "$pkgdir/usr" -type d -exec chmod 755 {} +

    # Remove references to $pkgdir
    find "$pkgdir" -type f -name package.json -print0 | xargs -0 sed -i "/_where/d"

    # Remove references to $srcdir
    local tmppackage="$(mktemp)"
    local pkgjson="$pkgdir/usr/lib/node_modules/$pkgname/package.json"
    jq '.|=with_entries(select(.key|test("_.+")|not))' "$pkgjson" >"$tmppackage"
    mv "$tmppackage" "$pkgjson"
    chmod 644 "$pkgjson"

    # Create manpage
    mfile="$pkgdir/usr/lib/node_modules/bibtex-tidy/bibtex-tidy.0"
    sed 's/^  Options:/OPTIONS/g' $mfile >"$pkgname.0"
    txt2man -d "" -s 1 -t "$pkgname" "$pkgname.0" >"$pkgname.1"

    gzip -f "$pkgname.1"
    mkdir -p "$pkgdir/usr/share/man/man1/"
    install -g 0 -o 0 -m 0644 "$pkgname.1.gz" "$pkgdir/usr/share/man/man1/"
    chown -R root:root "${pkgdir}"

}

# vim:set ts=2 sw=2 et:`