summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a125e37274603b631119816c0736ac059b6c7283 (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
# Maintainer: Davide Depau <davide@depau.eu>

_pkgname=cni-plugins-nftables
pkgname="${_pkgname}-git"
pkgver=1.0.12.r0.g5a16b82
pkgrel=1
pkgdesc='CNI plugins compatible with nftables'
arch=('x86_64' 'i686' 'pentium4' 'armv7h' 'aarch64')
url="https://github.com/greenpau/cni-plugins"
license=('apache')
makedepends=('go' 'git')
source=("${_pkgname}::git+https://github.com/greenpau/cni-plugins.git")
conflicts=("${_pkgname}")
optdepends=(
    "cni-plugins: Other network plugins maintained by the CNI team"
)
provides=("${_pkgname}")
sha256sums=('SKIP')

pkgver() {
  cd "$_pkgname"
  git describe --long --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare(){
  cd "$_pkgname"
  mkdir -p build/
}

build() {
  cd "$_pkgname"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
  go build -o build ./cmd/cni-nftables-portmap
  go build -o build ./cmd/cni-nftables-firewall
}

package() {
  cd "$_pkgname"
  install -dm755 "$pkgdir/usr/lib/cni"
  install -dm755 "$pkgdir/opt/cni/bin"
  install -Dm755 build/cni-nftables-portmap  "$pkgdir"/usr/lib/cni/cni-nftables-portmap
  install -Dm755 build/cni-nftables-firewall "$pkgdir"/usr/lib/cni/cni-nftables-firewall
  install -Dm755 build/cni-nftables-portmap  "$pkgdir"/opt/cni/bin/cni-nftables-portmap
  install -Dm755 build/cni-nftables-firewall "$pkgdir"/opt/cni/bin/cni-nftables-firewall
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
  install -Dm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
}