PKGBUILDs/community/npm/PKGBUILD

69 lines
2.3 KiB
Bash
Raw Normal View History

2020-02-19 01:22:30 +00:00
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
2021-03-03 02:01:20 +00:00
# - skip documentation build, breaks on 32-bit
# - comment make in build, comment man mv in package
2020-02-19 01:22:30 +00:00
pkgname=npm
2022-02-04 15:19:02 +00:00
pkgver=8.4.1
2020-12-22 01:25:07 +00:00
pkgrel=1
2020-02-19 01:22:30 +00:00
pkgdesc='A package manager for javascript'
arch=('any')
url='https://www.npmjs.com/'
license=('custom:Artistic')
2021-06-11 00:01:47 +00:00
depends=('nodejs' 'node-gyp' 'nodejs-nopt' 'semver')
2020-02-19 01:22:30 +00:00
# libgl: TODO
# libvips: for sharp (doc build) (disabled as current version of gatsby imports a broken sharp)
# libxi: for cwebp (doc build)
2021-03-03 02:01:20 +00:00
makedepends=('libgl' 'libxi' 'marked' 'marked-man' 'procps-ng' 'python')
2020-02-19 01:22:30 +00:00
options=('!emptydirs')
source=("$pkgname-$pkgver.tar.gz::https://github.com/npm/cli/archive/v$pkgver.tar.gz")
2022-02-04 15:19:02 +00:00
sha512sums=('39fcfe9ff2410f4dddd627ec7071143b5979800b452e05ef2ad866a246c90c47f6058e56cc12005a002f10894c4916a0f0adc79bf4c5f05bd6eb67ff556cbf4d')
2020-02-19 01:22:30 +00:00
prepare() {
cd cli-$pkgver
mkdir -p node_modules/.bin
ln -sf /usr/bin/marked{,-man} node_modules/.bin/
# Use local marked/marked-man
sed -i 's|node bin/npm-cli.js install marked|true |' Makefile
# Don't build twice
sed -i 's/install: all/install:/' Makefile
mkdir -p man/man1
}
build() {
cd cli-$pkgver
2021-03-03 02:01:20 +00:00
#NODE_PATH=/usr/lib/node_modules make
2020-02-19 01:22:30 +00:00
}
package() {
cd cli-$pkgver
2021-03-03 02:01:20 +00:00
node bin/npm-cli.js install -g -f --prefix="$pkgdir/usr" $(node bin/npm-cli.js pack | tail -1)
2020-02-19 01:22:30 +00:00
# Non-deterministic race in npm gives 777 permissions to random directories.
# See https://github.com/npm/npm/issues/9359 for details.
chmod -R u=rwX,go=rX "$pkgdir"
# npm installs package.json owned by build user
# https://bugs.archlinux.org/task/63396
chown -R root:root "$pkgdir"
# Experimental dedup
_npmdir="$pkgdir"/usr/lib/node_modules/$pkgname
rm -r "$_npmdir"/node_modules/{,.bin/}semver
rm -r "$_npmdir"/node_modules/{,.bin/}node-gyp
2021-06-11 00:01:47 +00:00
rm -r "$_npmdir"/node_modules/{,.bin/}nopt
2021-03-03 02:01:20 +00:00
sed -i 's|../../node_modules/node-gyp/bin/node-gyp.js|../../../node-gyp/bin/node-gyp.js|' \
2020-02-19 01:22:30 +00:00
"$_npmdir"/bin/node-gyp-bin/node-gyp
install -dm755 "$pkgdir"/usr/share/bash-completion/completions
node "$srcdir"/cli-$pkgver/bin/npm-cli.js completion > "$pkgdir"/usr/share/bash-completion/completions/npm
2021-03-03 02:01:20 +00:00
#mv "$pkgdir"/usr/lib/node_modules/npm/man "$pkgdir"/usr/share/
2020-02-19 01:22:30 +00:00
install -Dm644 "$srcdir"/cli-$pkgver/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}