summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: aac64e5d8d31be811eb8b87896398c2a96d3003a (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
# Maintainer: Bao Trinh <qubidt@gmail.com>
# Contributor: George Rawlinson <grawlinson@archlinux.org>

_pkgname=nomad-driver-podman
pkgname=${_pkgname}-git
pkgver=0.5.2.r0.ge06c271
pkgrel=1
pkgdesc="A nomad taskdriver for podman containers"
arch=('x86_64')
url="https://github.com/hashicorp/nomad-driver-podman"
license=('MPL2')
depends=('nomad' 'podman')
makedepends=('go' 'git')
options=('!lto')
provides=("${_pkgname}")
conflicts=("${_pkgname}")
source=("${_pkgname}::git+${url}")
sha256sums=('SKIP')

pkgver() {
  cd "${_pkgname}"

  git describe --long --tags "$(git tag -l | sort -k1Vr,1 | head -n1)" | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd "${_pkgname}"

  # create directory for build output
  mkdir -p build

  # download dependencies
  export GOPATH="${srcdir}"
  go mod download
}

build() {
  cd "${_pkgname}"

  # set Go flags
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export GOPATH="${srcdir}"

  go build -v \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-compressdwarf=false \
    -linkmode external \
    -extldflags \"${LDFLAGS}\"" \
    -o build \
    .
}

package() {
  cd "${_pkgname}"

  # binary
  install -vDm755 -t "$pkgdir/usr/lib/nomad/plugins" "build/${_pkgname}"

  # documentation
  rm "examples/plugins/.gitkeep"
  rmdir "examples/plugins"
  install -vDm644 -t "$pkgdir/usr/share/doc/${_pkgname}" README.md
  cp -vr examples "$pkgdir/usr/share/doc/${_pkgname}"
}