summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e3fb7363f5635e53f8e0edf441f64b304ab08ac0 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Maintainer: 
# Contributor: Mark Wagie <mark dot wagie at proton dot me>
# Contributor: syntheit <daniel@matv.io>
pkgname=tagspaces
pkgver=6.0.2
pkgrel=2
_nodeversion=20
_electronversion=32
pkgdesc="An offline, open source, document manager with tagging support"
arch=('x86_64')
url="https://www.tagspaces.org"
license=('AGPL-3.0-or-later')
depends=("electron${_electronversion}" 'libnotify' 'libsecret' 'xdg-utils')
makedepends=('git' 'libxcrypt-compat' 'nvm')
source=("$pkgname-$pkgver.tar.gz::https://github.com/tagspaces/tagspaces/archive/refs/tags/v$pkgver.tar.gz"
        "$pkgname.desktop"
        "$pkgname.sh")
sha256sums=('3107087d5dbf70a957bd27a75ce7bf4550423bec6df6c3503c305155fef5a7d0'
            'a548e2b62a61a93d80482ebe43ef11e33e2c2bfef9db641fc583bd5539ac6948'
            '6a0d3ca0f31afdd7587b3dc0ed819f252c350eaeafb17472fe4b7031d4130118')

_ensure_local_nvm() {
  # let's be sure we are starting clean
  which nvm >/dev/null 2>&1 && nvm deactivate && nvm unload
  export NVM_DIR="$srcdir/.nvm"

  # The init script returns 3 if version specified
  # in ./.nvrc is not (yet) installed in $NVM_DIR
  # but nvm itself still gets loaded ok
  source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
}

prepare() {
  cd "$pkgname-$pkgver"
  export npm_config_cache="$srcdir/npm_cache"
  _ensure_local_nvm
  nvm install "${_nodeversion}"

  # Modify build target
  sed -i 's/"deb", "tar.gz", "appImage"/"deb"/g' resources/builder.json

  # Skip husky
  mkdir -p .git
  npm run skip:husky:pre-commit

  npm install
  npm run install-ext-node

  # A key is required in order for the main application to communicate with the web server
  cd release/app
  touch .env
  generated_key=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 128)
  echo "KEY=${generated_key}" > .env

  sed -i "s|@ELECTRONVERSION@|electron${_electronversion}|" "$srcdir/$pkgname.sh"
}

build() {
  cd "$pkgname-$pkgver"
  export npm_config_cache="$srcdir/npm_cache"
  electronDist="/usr/lib/electron${_electronversion}"
  electronVer="$(sed s/^v// /usr/lib/electron${_electronversion}/version)"
  export ELECTRON_SKIP_BINARY_DOWNLOAD=1
   _ensure_local_nvm
  npm run install-ext-node-linux
  npm exec -c "ts-node ./.erb/scripts/clean.js"
  npm run build
  npm exec -c "electron-builder --linux --config resources/builder.json \
    ${dist} -c.electronDist=${electronDist} -c.electronVersion=${electronVer}"
}

package() {
  install -Dm644 builds/linux-unpacked/resources/app.asar -t \
    "$pkgdir/usr/lib/$pkgname/"
  cp -r builds/linux-unpacked/resources/app.asar.unpacked -t \
    "$pkgdir/usr/lib/$pkgname/"
  install -Dm755 "$pkgname.sh" "$pkgdir/usr/bin/$pkgname"
  install -Dm644 "$pkgname.desktop" -t "$pkgdir/usr/share/applications/"

  cd "$pkgname-$pkgver"
  install -Dm644 assets/icons/256x256.png \
    "$pkgdir/usr/share/icons/hicolor/256x256/apps/$pkgname.png"
  install -Dm644 assets/icon.png \
    "$pkgdir/usr/share/icons/hicolor/512x512/apps/$pkgname.png"
}