summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b8b0c81354042d3bf9d5df884b9b14519c4e9612 (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
# Maintainer: Adam Smith <adam at adamsm dot com>

pkgname=instamancer
pkgver=3.3.0
pkgrel=1
pkgdesc="Scrape Instagram's API with Puppeteer."
arch=('x86_64')
url="https://github.com/scriptsmith/instamancer"
license=('MIT')
# Includes dependencies from google-chrome package
depends=('nodejs' 'alsa-lib' 'gtk3' 'libcups' 'libxss' 'libxtst' 'nss')
makedepends=('npm' 'jq')
install='instamancer.install'
source=(https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
noextract=($pkgname-$pkgver.tgz)
sha256sums=('ba696a6f19a014a6d1dbf80fe038ae3b943d1ccfa7cd1eb29ee74fb81d83e8d7')

# Taken from https://wiki.archlinux.org/index.php/Node.js_package_guidelines
package() {
  npm install \
    --ignore-scripts \
    --user root --global \
    --prefix "$pkgdir/usr" \
    "$srcdir"/$pkgname-$pkgver.tgz

  # Non-deterministic race in npm gives 777 permissions to random directories.
  # See https://github.com/npm/npm/issues/9359 for details.
  find "${pkgdir}"/usr -type d -exec chmod 755 {} +

  # Remove references to $pkgdir
  find "$pkgdir" -name package.json -print0 | xargs -r -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"

  # npm gives ownership of ALL FILES to build user
  # https://bugs.archlinux.org/task/63396
  chown -R root:root "$pkgdir"

  # Install license since the package doesn't include it
  install -Dm0644 "$pkgdir/usr/lib/node_modules/$pkgname/LICENSE" \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}