summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8239126941f442288c13192fb79845c9de97eb38 (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
# Maintainer: Zdeněk Biberle <zdenek at biberle dot net>
pkgname=snx-rs
pkgver=3.0.3
pkgrel=1
pkgdesc="Rust client for Checkpoint VPN tunnels"
arch=(x86_64)
url=https://github.com/ancwrd1/snx-rs
license=(AGPL-3.0-only)
depends=(gcc-libs glibc openssl glib2 gdk-pixbuf2 gtk3)
makedepends=(cargo imagemagick)
checkdepends=(iproute2)
source=(
  "$pkgname-$pkgver.tar.gz::https://github.com/ancwrd1/$pkgname/archive/refs/tags/v$pkgver.tar.gz"
  fix-executable-path.patch
  fix-desktop-file.patch
)
sha256sums=('92dd6f67c71ff373f733e1a0340a935c0d84b53746869cfcd7a0057c5a6c03a0'
            'c4438f1167b76cc278610faacdd6d821e21a9339dd12fd86bf5c27f6af66424d'
            'babd0692e40b03eab9e69696b7a9c8b5ebdca5f77e3de9209378a70af524820e')
_icon_sizes=(16 20 22 24 32 36 40 48 64 72 96 128 192 256)

prepare() {
  cd "$pkgname-$pkgver"
  patch --forward --strip=1 --input="$srcdir/fix-executable-path.patch"
  patch --forward --strip=1 --input="$srcdir/fix-desktop-file.patch"
  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname-$pkgver"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --frozen --release

  # Make sure that the source icon we're using has the expected size
  local source_icon=assets/icons/light/network-vpn.png
  test "$(magick identify -format "%wx%h" "$source_icon")" = 256x256
  # And now resize it to all the other sizes
  for size in "${_icon_sizes[@]}" ; do
    magick "$source_icon" -resize "${size}x$size" "assets/icons/$size.png"
  done
}

check() {
  cd "$pkgname-$pkgver"
  export RUSTUP_TOOLCHAIN=stable
  cargo test --frozen
}

package() {
  # At runtime, libappindicator-sys loads either libayatana-appindicator3.so
  # or libappindicator3.so to do its thing. These come from the
  # libayatana-appindicator and libappindicator-gtk3 packages.
  # Either one works, but as libappindicator-gtk3 seems to be on its way
  # out, I've chosen to depend on libayatana-appindicator.
  depends+=(libayatana-appindicator systemd iproute2)
  cd "$pkgname-$pkgver"
  install -Dm0755 -t "$pkgdir/usr/bin/" target/release/{snx-rs,snxctl,snx-rs-gui}
  install -Dm0644 -t "$pkgdir/usr/lib/systemd/system/" assets/snx-rs.service
  install -Dm0644 -t "$pkgdir/usr/share/applications/" assets/snx-rs-gui.desktop
  for size in "${_icon_sizes[@]}" ; do
    install -Dm0644 -T "assets/icons/$size.png" "$pkgdir/usr/share/icons/hicolor/${size}x$size/apps/snx-rs-gui.png"
  done
}