summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0c07e57791b04d72b28231c818b149df7f389f3d (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
86
87
88
89
90
91
92
# Maintainer: Cedric Roijakkers <cedric [the at sign goes here] roijakkers [the dot sign goes here] be>.
# Inspired from the PKGBUILD for ferdi-git.

_electron='electron29'

pkgname="ferdium-electron"
pkgver=6.7.1
pkgrel=1
pkgdesc='A messaging browser that allows you to combine your favorite messaging services into one application (git build from latest release) - System-wide Electron edition'
arch=('x86_64' 'i686' 'armv7h' 'aarch64')
url="https://ferdium.org/"
license=('Apache')
depends=("$_electron")
makedepends=('git' 'python' 'jq' 'asar'
             'pnpm'
             'nodejs')
provides=('ferdium')
conflicts=('ferdium')
source=("$pkgname::git+https://github.com/ferdium/ferdium-app#tag=v$pkgver"
        'ferdium-recipes::git+https://github.com/ferdium/ferdium-recipes.git#branch=main'
        ferdium.desktop)
sha256sums=('SKIP'
            'SKIP'
            'd6e129220ed947cb5fa205211dabc6311a3d9c92434b6bc8deb2fae802c0b0d0')

prepare() {
  cd "$pkgname"

  git submodule init
  git config submodule.recipes.url "$srcdir/ferdium-recipes"
  git -c protocol.file.allow=always submodule update

  local node_ver=$(node -v | sed -e 's/^v//')
  local pnpm_ver=$(pnpm -v)
  local electron_ver=$(cat "/usr/lib/${_electron}/version")

  local jq_expr=".engines.node = \"$node_ver\" | .engines.pnpm = \"$pnpm_ver\" | .devDependencies.electron = \"$electron_ver\""

  jq "$jq_expr" package.json > package.tmp.json
  mv package.tmp.json package.json

  jq "$jq_expr" recipes/package.json > package.tmp.json
  mv package.tmp.json recipes/package.json

  # Specify path for autostart file
  sed -i -e "s#path: executablePath,#path: '/usr/bin/ferdium',#g" src/stores/AppStore.ts
  # Set noUnusedLocals to false to avoid compilation error in AppStore.ts
  sed -i -e 's#"noUnusedLocals": true#"noUnusedLocals": false#g' tsconfig.json
}

build() {
  cd "$pkgname"

  export CI=true

  pnpm install --no-frozen-lockfile
  pnpm run prepare-code || true

  cd "recipes"

  pnpm install --no-frozen-lockfile
  pnpm run package

  cd ..

  NODE_ENV=production pnpm run build \
    --linux --x64 --dir \
    -c.electronDist="/usr/lib/$_electron" \
    -c.electronVersion="$(cat "/usr/lib/$_electron/version" | sed -e 's/^v//')"
}

package() {
  cd "$pkgname"

  install -dm0755 "$pkgdir/usr/bin"
  cat > "$pkgdir/usr/bin/ferdium" <<EOF
#!/bin/sh
ELECTRON_IS_DEV=0 exec /usr/bin/$_electron /usr/lib/ferdium "\$@"
EOF
  chmod +x "$pkgdir/usr/bin/ferdium"

  install -dm0755 "$pkgdir/usr/lib/ferdium"
  asar e out/linux-unpacked/resources/app.asar "$pkgdir/usr/lib/ferdium"

  install -Dm0644 -t "$pkgdir/usr/share/applications/" "$srcdir/ferdium.desktop"
  for _size in 16 24 32 48 64 96 128 256 512 1024; do
    install -Dm644 "build-helpers/images/icons/${_size}x${_size}.png" \
      "$pkgdir/usr/share/icons/hicolor/${_size}x${_size}/apps/ferdium.png"
  done

  install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE.md
}