summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fc4121649069827296da98f2bd320e1954365388 (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
# Maintainer: Rafael Dominiquini <rafaeldominiquini at gmail dot com>

_npmname=wperf
pkgname=$_npmname
pkgver=1.0.11
pkgrel=2

pkgdesc="A simple HTTP load testing utility with detailed performance metrics."
arch=("x86_64")
url="https://github.com/jhuckaby/wperf"
license=("MIT")

depends=("glibc" "nodejs")
makedepends=("npm")
provides=("$_npmname")
conflicts=("$_npmname")
# options=(strip emptydirs zipman)

source=("https://registry.npmjs.org/${_npmname}/-/${_npmname}-${pkgver}.tgz"
		"https://raw.githubusercontent.com/jhuckaby/wperf/v${pkgver}/LICENSE.md")
noextract=("${_npmname}-${pkgver}.tgz")
b2sums=('8046df2f9fdb0c95cf6a78e8b2cb7722f7880312cefa451a49aa6edd882a8f0966fd07357057f516d5ec7b3e892539ec996eca9c0ad1e6dd7a65f896c1b811a0'
        'bf727eb2112307cf17d0289aabd22b2adc6181ad0c30339852284bbffe5df7c124f636b8e68c940a6e60a78896185c9bc344139cbeccb9db659153284dd56a79')

# Document: https://wiki.archlinux.org/title/Node.js_package_guidelines
package() {
	msg2 "Install using Using npm"
	npm install -s -g \
		--cache "${srcdir}/npm-cache" \
		--prefix "${pkgdir}/usr" \
		"${srcdir}/${_npmname}-${pkgver}.tgz"

	msg2 "Fix ownership of ALL FILES"
	find "${pkgdir}/usr" -type d -exec chmod 755 {} +
	chown -R root:root "${pkgdir}"

	msg2 "Remove references to ${pkgdir}"
	find "$pkgdir" -name package.json -print0 | xargs -r -0 sed -i '/_where/d'

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

	find "$pkgdir" -type f -name package.json | while read pkgjson; do
		local tmppackage="$(mktemp)"
		jq 'del(.man)' "$pkgjson" >"$tmppackage"
		mv "$tmppackage" "$pkgjson"
		chmod 644 "$pkgjson"
	done

	msg2 "Install README file"
	install -dm755 "${pkgdir}/usr/share/doc/${pkgname}/"
	ln -sf "/usr/lib/node_modules/${_npmname}/README.md" "${pkgdir}/usr/share/doc/${pkgname}/README.md"

	msg2 "Install LICENSE file"
	install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}/"
	ln -sf "/usr/lib/node_modules/${_npmname}/LICENSE.md" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}