summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c9b1ad1a5e6ccfa6a466b259615f34c65e00b481 (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
# Maintainer: Caleb Maclennan <caleb@alerque.com>

_npmname=apg-js
pkgname=nodejs-"$_npmname"
pkgver=4.4.0
pkgrel=1
pkgdesc='an ABNF parser generator creating recursive-descent parsers from a superset of ABNF'
arch=(any)
url="https://github.com/ldthomas/$_npmname"
license=(BSD-2-Clause)
depends=(nodejs)
makedepends=(jq
             moreutils
             npm)
source=("https://registry.npmjs.org/$_npmname/-/$_npmname-$pkgver.tgz")
sha256sums=('79c9ad44a5b82d359ac68b69c3b4be46a269a7a953a98fd1b2dd757fcbfb3beb')
noextract=("${source[@]##*/}")

package() {
	npm install -g --user root --cache "$srcdir/npm-cache" --prefix "$pkgdir/usr" "${source[@]##*/}"
	find "$pkgdir/usr" -type d -exec chmod 755 {} +
	find "$pkgdir" -type f -name package.json \
		-execdir bash -c "jq '. |= with_entries(select(.key | test(\"_.+\") | not))' {} | sponge {}" \;
	chown -R root:root "$pkgdir"
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" "$pkgdir/usr/lib/node_modules/$_npmname/LICENSE.md"
	mkdir -p "$pkgdir/usr/bin"
	for bin in apg apg-conv; do
		ln -sf "../lib/node_modules/$_npmname/bin/$bin.sh" "$pkgdir/usr/bin/$bin-js"
	done
}