summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0c76846b3c74d994cb85307d817c2b81ca530ff9 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Maintainer: tarball <bootctl@gmail.com>
# Contributor: brody <archfan@brodix.de>

pkgbase=netbird
pkgname=(
  $pkgbase
  $pkgbase-server
  $pkgbase-ui
)
pkgver=0.71.2
pkgrel=1
url='https://netbird.io'
arch=(i686 pentium4 x86_64 arm armv7h armv6h aarch64 riscv64)
_ui_depends=(
  libglvnd
  libx11
  libxcursor
  libxi
  libxinerama
  libxrandr
  libxxf86vm
)
makedepends=('go' "${_ui_depends[@]}")
source=("$pkgbase-$pkgver.tar.gz::https://github.com/netbirdio/netbird/archive/refs/tags/v$pkgver.tar.gz"
        "netbird-server.service")
sha256sums=('5f7dd05277258b83fdea0c6f127fe1477ca3acdac885a79c3fd5ad0022e1d24d'
            '6e42973058b2db1a167ac110692d02c57b93d29ce6f68d8d5f8b91babcd856c9')

prepare() {
  cd "$srcdir/$pkgbase-$pkgver"
  mkdir -p build
  go mod download -x
}

build() {
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"

  cd "$srcdir/$pkgbase-$pkgver"

  # TODO: pass '-tags wayland' to glfw?
  go build \
    -o build \
    -ldflags "-s -w -linkmode=external -X github.com/netbirdio/netbird/version.version=$pkgver -extldflags \"$LDFLAGS\"" \
    ./client ./client/ui ./combined

  local shell
  for shell in bash fish zsh; do
    ./build/client completion $shell >build/client.$shell
  done
}

# upstream test suite requires root
check() {
  cd "$srcdir/$pkgbase-$pkgver/build"
  [[ "$(./client version)" == $pkgver ]]
}

_completions() {
  install -Dm644 "build/$1.bash" "$pkgdir/usr/share/bash-completion/completions/$2"
  install -Dm644 "build/$1.fish" "$pkgdir/usr/share/fish/vendor_completions.d/$2.fish"
  install -Dm644 "build/$1.zsh" "$pkgdir/usr/share/zsh/site-functions/_$2"
}

package_netbird() {
  license=('BSD-3-Clause')
  backup=(etc/default/$pkgname)
  depends=(glibc)
  optdepends=('resolvconf: Private DNS')
  pkgdesc='WireGuard-based overlay network: client'
  replaces=(wiretrustee)

  install -dm755 "$pkgdir/etc/$pkgbase"

  cd "$srcdir/$pkgname-$pkgver"
  install -Dm755 build/client "$pkgdir/usr/bin/$pkgname"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  _completions client "$pkgname"

  cd release_files/systemd/
  install -Dm644 env "$pkgdir/etc/default/$pkgname"
  install -Dm644 netbird@.service -t "$pkgdir/usr/lib/systemd/system/"
}

package_netbird-server() {
  license=('AGPL-3.0-only')
  backup=(etc/$pkgname/config.yaml)
  depends=(glibc ca-certificates)
  optdepends=('redis: IDP cache store')
  pkgdesc='WireGuard-based overlay network: single-binary server'
  replaces=($pkgbase-{management,signal,relay})

  install -Dm644 $pkgname.service -t "$pkgdir/usr/lib/systemd/system/"

  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm755 build/combined "$pkgdir/usr/bin/$pkgname"
  install -Dm640 combined/config.yaml.example "$pkgdir/etc/$pkgname/config.yaml"
}

package_netbird-ui() {
  license=('BSD-3-Clause')
  pkgdesc='GUI for the Netbird client'
  depends=(
    glibc
    netbird
    "${_ui_depends[@]}"
  )

  cd "$srcdir/$pkgbase-$pkgver"
  install -Dm755 build/ui "$pkgdir/usr/bin/$pkgname"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cd client/ui
  install -Dm644 assets/netbird.png "$pkgdir/usr/share/pixmaps/netbird.png"
  install -Dm644 build/netbird.desktop "$pkgdir/usr/share/applications/netbird.desktop"
}