summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b1e409c6feaee017a1b375ca5e127c454ff5f231 (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Maintainer: tarball <bootctl@gmail.com>
# Contributor: brody <archfan@brodix.de>

pkgbase=netbird
pkgname=(
  $pkgbase
  $pkgbase-management
  $pkgbase-signal
  $pkgbase-relay
)
pkgver=0.34.1
pkgrel=1
url='https://netbird.io'
arch=(i686 pentium4 x86_64 arm armv7h armv6h aarch64 riscv64)
license=(BSD-3-Clause)
makedepends=('go')

source=(
  "$pkgname-$pkgver.tar.gz::https://github.com/netbirdio/$pkgname/archive/refs/tags/v$pkgver.tar.gz"
  'netbird.env'
  'netbird@.service'
  'netbird-signal.env'
  'netbird-signal.service'
  'netbird-management.env'
  'netbird-management.service'
  'netbird-relay.env'
  'netbird-relay.service'
)
sha256sums=('5eb78e815c73b197f36141dbc071520171cd660a1f64a010c5ec5c4db4d006e4'
            '128e36e1f814a12886f3122a1809a404be17f81481275b6624e66937941f5269'
            '2fa681ef862bfa609d62596e730ff5fbfa706fedca801556cd18a97f349e039f'
            '80cd7b6a22087a83c1332c15693d8a18b780ef5ecf3fbc562af28d1a623eef3b'
            '2f5b3fee5a87099903d4fb65fc1a295b07669c90160b702c705471cb2a313842'
            '7d31d7847f5a25bca81def470f7fc5a277c3064e5a0ad71a3f19a29202537315'
            '834deff3977679cd70bab8fff7413e3f96085acd88175ff69e500478cb689229'
            'da07172b4a061387adda838f241982954e3eea62b9ba4aa677393b29d1630b28'
            '8ba9b40cd7db61a9339e2ccc3528e2b2951cc8f6afc252af329af12617334436')

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

build() {
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
  cd "$srcdir/$pkgbase-$pkgver"

  go build \
    -o build \
    -ldflags "-s -w -linkmode=external -X github.com/netbirdio/$pkgname/version.version=$pkgver -extldflags \"$LDFLAGS\"" \
    ./client ./signal ./management ./relay

  # relay does not support completions
  for bin in client signal management; do
    for shell in bash fish zsh; do
      ./build/$bin completion $shell >build/$bin.$shell
    done
  done
}

# upstream test suite requires root
check() {
  cd "$srcdir/$pkgbase-$pkgver/build"

  # relay does not support --version
  [[ "$(./client version)" == $pkgver ]]
  [[ "$(./management --version)" == "$pkgbase-mgmt version $pkgver" ]]
  [[ "$(./signal --version)" == "$pkgbase-signal version $pkgver" ]]
}

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

  install -Dm644 $pkgname.env "$pkgdir/etc/default/$pkgname"
  install -Dm644 $pkgname@.service "$pkgdir/usr/lib/systemd/system/$pkgname@.service"
  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"
  install -Dm644 build/client.bash "$pkgdir/usr/share/bash-completion/completions/$pkgname"
  install -Dm644 build/client.fish "$pkgdir/usr/share/fish/vendor_completions.d/$pkgname.fish"
  install -Dm644 build/client.zsh "$pkgdir/usr/share/zsh/site-functions/_$pkgname"
}

package_netbird-management() {
  backup=(etc/default/$pkgname)
  depends=(glibc ca-certificates)
  pkgdesc='WireGuard-based overlay network: management service'

  install -Dm644 $pkgname.env "$pkgdir/etc/default/$pkgname"
  install -Dm644 $pkgname.service "$pkgdir/usr/lib/systemd/system/$pkgname.service"
  install -dm755 "$pkgdir/etc/$pkgbase"

  cd "$srcdir/$pkgbase-$pkgver"

  install -Dm755 build/management "$pkgdir/usr/bin/$pkgbase-mgmt"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 build/management.bash "$pkgdir/usr/share/bash-completion/completions/$pkgbase-mgmt"
  install -Dm644 build/management.fish "$pkgdir/usr/share/fish/vendor_completions.d/$pkgbase-mgmt.fish"
  install -Dm644 build/management.zsh "$pkgdir/usr/share/zsh/site-functions/_$pkgbase-mgmt"
}

package_netbird-signal() {
  backup=(etc/default/$pkgname)
  depends=(glibc)
  pkgdesc='WireGuard-based overlay network: signal service'

  install -Dm644 $pkgname.env "$pkgdir/etc/default/$pkgname"
  install -Dm644 $pkgname.service "$pkgdir/usr/lib/systemd/system/$pkgname.service"

  cd "$srcdir/$pkgbase-$pkgver"

  install -Dm755 build/signal "$pkgdir/usr/bin/$pkgname"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 build/signal.bash "$pkgdir/usr/share/bash-completion/completions/$pkgname"
  install -Dm644 build/signal.fish "$pkgdir/usr/share/fish/vendor_completions.d/$pkgname.fish"
  install -Dm644 build/signal.zsh "$pkgdir/usr/share/zsh/site-functions/_$pkgname"
}

package_netbird-relay() {
  backup=(etc/default/$pkgname)
  depends=(glibc)
  pkgdesc='WireGuard-based overlay network: relay service'

  install -Dm644 $pkgname.env "$pkgdir/etc/default/$pkgname"
  install -Dm644 $pkgname.service "$pkgdir/usr/lib/systemd/system/$pkgname.service"

  cd "$srcdir/$pkgbase-$pkgver"

  install -Dm755 build/relay "$pkgdir/usr/bin/$pkgname"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}