summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fed26e3f2e2259bd4608f2f455f841d68d307444 (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
# Maintainer: ml <>
pkgname=google-chat-linux
_pkgver='5.14.15-1'
pkgver=${_pkgver/-/+}
pkgrel=1
pkgdesc='Unofficial electron-based desktop client for Google Chat, electron not included'
arch=('any')
url='https://github.com/squalou/google-chat-linux'
license=('custom:UNKNOWN')
depends=('electron' 'xdg-desktop-portal-impl')
makedepends=('jq' 'npm' 'nodejs-lts-fermium')
source=("$url/archive/$_pkgver/$pkgname-$_pkgver.tar.gz"
  google-chat-linux.sh
  google-chat-linux.desktop
  sandbox.patch)
sha256sums=('89d5ec2cac2afb9003f47bbbdb722f56c2671104912998e392d51fd36ddbc2cb'
            '5a458e5d7193784383ceda44faf8852410296f310acb5495d53c16bd0ea50059'
            'c7fdfa74422ce7900563fd1a0f5d76c4d4cd6d153ca3b28ab5a8912a33cba9c7'
            '3f6513ded0c0da0d1b3ccd3fa08537cdd36a7f0281b66ec1021006565732b9c3')


_patch_package_json() {
  mv package.json package.json.orig
  jq --arg version "$(</usr/lib/electron/version)" -f /dev/stdin package.json.orig <<'EOF' >package.json
del(.devDependencies.electron) |
.build *= {
  "electronDist": "/usr/lib/electron",
  "electronVersion": $version,
  "files": [
    "assets",
    "src"
  ]
}
EOF
}

_npm() { npm --no-audit --no-fund --no-update-notifier --cache="$srcdir/npm-cache" "$@"; }
prepare() {
  cd "$pkgname-$_pkgver"
  patch -Np1 < ../sandbox.patch
  _patch_package_json
  _npm install
}

build() {
  cd "$pkgname-$_pkgver"
  export NODE_ENV=production
  _npm run-script pack
}

package() {
  install -Dm755 "$pkgname".sh "$pkgdir"/usr/bin/"$pkgname"
  install -Dm644 "$pkgname".desktop -t "$pkgdir/usr/share/applications"

  cd "$pkgname-$_pkgver"
  install -Dm644 dist/linux-unpacked/resources/app.asar "$pkgdir"/usr/lib/"$pkgname".asar

  for i in build/icons/*.png; do
    : "${i##*/}"
    install -Dm644 "$i" "$pkgdir/usr/share/icons/hicolor/${_%.png}x${_%.png}/apps/$pkgname.png"
  done
  install -Dm644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
}