summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d50d05fdc2c9947b7004bee11b13e602e7bbafa2 (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
61
62
63
64
65
66
# Maintainer: INhBQfUQO2eFzulN <281587887a at protonmail dot ch>
# If you want TOR functionality, remove '--no-optional' from the 35th line

_pkgname=bibliogram
pkgname=bibliogram-git
pkgver=r388.a807acc
pkgrel=1
pkgdesc="An alternative front-end for Instagram"
arch=('any')
url="https://sr.ht/~cadence/bibliogram/"
license=('AGPL')
depends=('nodejs')
makedepends=('git' 'npm' 'jq')
optdepends=('graphicsmagick: Required for resizing images for thumbnailing')
provides=("$_pkgname")
conflicts=("$_pkgname")
source=("$pkgname::git+https://git.sr.ht/~cadence/$_pkgname#branch=master"
  "bibliogram.service"
  "bibliogram.sh")
sha256sums=('SKIP'
  '29edbea6200df766d01e49a56a1aee710a5a58a8108e11b78b8ea4bb961d9123'
  '6f3841030ba3e2be042ba54f7c8e65fb1282eac392b4501e461a0e3d10a6248f')

pkgver() {
  cd "$pkgname"
  (
    set -o pipefail
    git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
      printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
  )
}

build() {
  cd "${srcdir}/${pkgname}"
  npm install --no-optional
}

package() {
  install -D -m644 bibliogram.service -t "$pkgdir/usr/lib/systemd/system"

  # Use a wrapper script as an entry point
  install -D -m755 bibliogram.sh "$pkgdir/usr/bin/bibliogram"
  cd "${srcdir}/${pkgname}"
  install -d "${pkgdir}/opt/${_pkgname}"
  cp -a * "${pkgdir}/opt/${_pkgname}"

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

  # Remove references to $pkgdir/$srcdir
  find "$pkgdir" -type f -name package.json -print0 | xargs -0 sed -i "/_where/d"

  local tmppackage="$(mktemp)"
  local pkgjson="$pkgdir/opt/$_pkgname/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
}