summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fce97ea8f7f3e668042fbc3d80d9db883cfbf261 (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
# Maintainer: Matthew McGinn <mamcgi@gmail.com>

pkgname=ci-node-modules
pkgdesc='Clean install node_modules using the appropriate installation command'
pkgver=1.1.0
pkgrel=1
arch=('any')
url='https://balena.io/'
_github_url="https://github.com/balena-io-modules/ci-node-modules"
license=('APACHE')
depends=('bash')
makedepends=('npm' 'jq')
source=("https://github.com/balena-io-modules/${pkgname}/archive/v${pkgver}.tar.gz")
noextract=("v${pkgver}.tar.gz")
options=(!strip)
sha256sums=('d8b2926c39a2c55349457e5f35ffec3eb19796fe346aeeb6eac0bebc41e8a374')

package() {
  npm install --global --production --user root --prefix "${pkgdir}/usr" "${srcdir}/v${pkgver}.tar.gz"

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

  find "${pkgdir}/usr" -type d -exec chmod 755 {} +
  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}"
}