archrelease: copy trunk to community-any
[ArchLinux/community.git] / nerdctl / trunk / PKGBUILD
blob097b461a2397ec817899ace3f08b2704c811f4b6
1 # Maintainer: George Rawlinson <grawlinson@archlinux.org>
3 pkgname=nerdctl
4 pkgver=1.3.1
5 pkgrel=1
6 pkgdesc='Docker-compatible CLI for containerd'
7 arch=('x86_64')
8 url='https://github.com/containerd/nerdctl'
9 license=('Apache')
10 depends=('containerd')
11 makedepends=('git' 'go')
12 optdepends=(
13   'buildkit: to build OCI images'
14   'cni-plugins: to run OCI images'
15   'rootlesskit: for rootless mode'
16   'slirp4netns: for rootless mode'
18 options=('!lto')
19 _commit='b224b280ff3086516763c7335fc0e0997aca617a'
20 source=(
21   "$pkgname::git+$url.git#commit=$_commit"
22   'skip-failing-test.patch'
24 sha512sums=('SKIP'
25             'c168de6147edcebf31df4b2e22dc830cad62b81780d10105aada8e17347523747d413c4398bec3840f079a37177b6f9c3ca87c8f0119f4f651f7e4c6462eb8b3')
26 b2sums=('SKIP'
27         'c4dd2803d0fb6ef0067ee2ec3fb34f606618e157264e03f9b607629900b11a774f484c8cb320054f90911400bb436ca65f024bf5d63f39766e5b7f19fd8814e5')
29 pkgver() {
30   cd "$pkgname"
31   git describe --tags | sed 's/^v//'
34 prepare() {
35   cd "$pkgname"
37   # create directory for build output
38   mkdir build
40   # download dependencies
41   export GOPATH="${srcdir}"
42   go mod download
44   # skip failing unit test
45   patch -p1 -i ../skip-failing-test.patch
48 build() {
49   cd "$pkgname"
51   # set Go flags
52   export CGO_CPPFLAGS="${CPPFLAGS}"
53   export CGO_CFLAGS="${CFLAGS}"
54   export CGO_CXXFLAGS="${CXXFLAGS}"
55   export GOPATH="${srcdir}"
57   go build -v \
58     -buildmode=pie \
59     -mod=readonly \
60     -modcacherw \
61     -ldflags "-compressdwarf=false \
62     -linkmode external \
63     -extldflags ${LDFLAGS} \
64     -X github.com/containerd/nerdctl/pkg/version.Version=$pkgver \
65     -X github.com/containerd/nerdctl/pkg/version.Revision=$_commit" \
66     -o build \
67     ./cmd/...
69   # generate shell auto-completions
70   for completion in bash fish zsh; do
71     ./build/nerdctl completion "$completion" > "build/$completion-completions"
72   done
75 check() {
76   cd "$pkgname"
78   go test -v ./pkg/...
81 package() {
82   cd "$pkgname"
84   # binary & rootless scripts
85   install -vDm755 -t "$pkgdir/usr/bin" build/nerdctl extras/rootless/*.sh
87   # shell completions
88   install -vDm644 build/bash-completions "$pkgdir/usr/share/bash-completion/completions/$pkgname"
89   install -vDm644 build/fish-completions "$pkgdir/usr/share/fish/vendor_completions.d/$pkgname.fish"
90   install -vDm644 build/zsh-completions "$pkgdir/usr/share/zsh/site-functions/_$pkgname"