summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3c57f3308e98f5176a6fbab641ada0b9be488424 (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
pkgname=wallstreet
_pkgname=wallstreet
pkgver=r41.8c966fa
pkgrel=1
pkgdesc="Stock quotes and charts for the terminal"
arch=('any')
url="https://github.com/madnight/wallstreet"
license=('MIT')
depends=('nodejs')
makedepends=('npm' 'git' 'jq')
source=("git+https://github.com/madnight/wallstreet.git")
sha256sums=('SKIP')

pkgver() {
  cd $_pkgname
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

package() {
  npm install -g --user root --prefix "$pkgdir/usr" git+file://$(realpath $_pkgname)
  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"
  chown -R root:root "$pkgdir"

  install -Dm 644 "$_pkgname/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}