summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0f090c97a2947bf4c35d0a300a33977b4a8b5d44 (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
# Maintainer: tarball <bootctl@gmail.com>
# Contributor: brody <archfan@brodix.de>

pkgbase=netbird
pkgname=(
  $pkgbase
  $pkgbase-server
)
pkgver=0.81.1
pkgrel=1
url='https://netbird.io'
arch=(i686 pentium4 x86_64 arm armv7h armv6h aarch64 riscv64)
makedepends=('go')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/netbirdio/netbird/archive/refs/tags/v$pkgver.tar.gz"
        "netbird-server.service")
sha256sums=('c4b50687979ea231c8afa1c956bd045a6d1f7289c5fb6c1a729789b4f5675a10'
            '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"

  go build \
    -o build \
    -ldflags "-s -w -linkmode=external -X github.com/netbirdio/netbird/version.version=$pkgver -extldflags \"$LDFLAGS\"" \
    ./client ./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 ]]
}

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"

  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"

  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"
}