summaryrefslogtreecommitdiff
path: root/testing/zot/APKBUILD
blob: 808819e8303d6f0f30814cb7257e395a9c9f5c01 (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
# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=zot
pkgver=2.0.1
_zui_commit=f4a6030d93c4111af699a3ea0c154bd212e5aa06
pkgrel=0
pkgdesc="Vendor-neutral OCI-native container image registry"
url="https://zotregistry.io/"
# 32-bit, s390x, riscv64: tests fail to build
arch="all !armv7 !armhf !x86 !s390x !riscv64"
license="Apache-2.0"
makedepends="go npm nodejs"
subpackages="
	$pkgname-doc
	$pkgname-openrc
	$pkgname-cli:_cli
	$pkgname-exporter:_exporter
	$pkgname-cli-bash-completion:_bashcomp:noarch
	$pkgname-cli-fish-completion:_fishcomp:noarch
	$pkgname-cli-zsh-completion:_zshcomp:noarch
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/project-zot/zot/archive/refs/tags/v$pkgver.tar.gz
	zui-$_zui_commit.tar.gz::https://github.com/project-zot/zui/archive/$_zui_commit.tar.gz
	zot.initd
	zot.confd
	"
options="net" # download Go modules

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

prepare() {
	default_prepare

	# XXX: remove this on the next update
	# (upstream probably hasn't updated go.mod file correctly)
	go mod tidy

	cd "$srcdir"/zui-$_zui_commit
	npm install --no-progress
}

build() {
	cd "$srcdir"/zui-$_zui_commit
	npm run build
	cp -r build "$builddir"/pkg/extensions/

	cd "$builddir"
	local _extensions="sync,search,scrub,metrics,lint,ui,mgmt,profile,userprefs,imagetrust"
	local _goldflags="
	-X zotregistry.io/zot/pkg/api/config.ReleaseTag=v$pkgver
	-X zotregistry.io/zot/pkg/api/config.Commit=AlpineLinux
	-X zotregistry.io/zot/pkg/api/config.BinaryType=${_extensions//,/-}
	-X zotregistry.io/zot/pkg/api/config.GoVersion=$(go env GOVERSION)
	"

	for binary in zot zb zli; do
		go build -v \
			-ldflags "$_goldflags" \
			-tags "$_extensions,containers_image_openpgp" \
			./cmd/$binary
	done
	go build -v -tags containers_image_openpgp ./cmd/zxp

	# Only generate shell completions for the CLI client
	for shell in bash fish zsh; do
		./zli completion $shell > zli.$shell
	done
}

check() {
	# Skip tests requiring static container image tarballs (pulled via skopeo) in ./test/data/
	# and oras binary in ./hack/tools/
	# shellcheck disable=2046
	go test -tags containers_image_openpgp \
		-skip TestHTTPClient \
		$(go list ./... | grep -v \
		-e 'pkg/test/image-utils$' \
		-e 'pkg/test/common$' \
		-e 'pkg/storage/local$')
}

package() {
	install -Dm755 zot -t "$pkgdir"/usr/bin/

	install -Dm644 examples/config-*.json -t "$pkgdir"/usr/share/doc/zot/examples/

	install -Dm755 "$srcdir"/zot.initd -t "$pkgdir"/etc/init.d/zot
	install -Dm644 "$srcdir"/zot.confd -t "$pkgdir"/etc/conf.d/zot
}

_cli() {
	pkgdesc="$pkgdesc - CLI tools"
	install -Dm755 "$builddir"/zli "$builddir"/zb -t "$subpkgdir"/usr/bin/
}

_exporter() {
	pkgdesc="$pkgdesc - metrics exporter"
	install -Dm755 "$builddir"/zxp -t "$subpkgdir"/usr/bin/
}

_bashcomp() {
	pkgdesc="Bash completions for $pkgname-cli"
	install_if="bash-completion $pkgname-cli=$pkgver-r$pkgrel"
	install -Dm644 "$builddir"/zli.bash \
		"$subpkgdir"/usr/share/bash-completion/completions/zli
}

_fishcomp() {
	pkgdesc="Fish completions for $pkgname-cli"
	install_if="fish $pkgname-cli=$pkgver-r$pkgrel"
	install -Dm644 "$builddir"/zli.fish \
		"$subpkgdir"/usr/share/fish/vendor_completions.d/zli.fish
}

_zshcomp() {
	pkgdesc="Zsh completions for $pkgname-cli"
	install_if="zsh $pkgname-cli=$pkgver-r$pkgrel"
	install -Dm644 "$builddir"/zli.zsh \
		"$subpkgdir"/usr/share/zsh/site-functions/_zli
}

sha512sums="
47fb6a87d6d9548c5add65ba9a3ba3b5bcd6e28a12989967c67ad491c0753521ba9b453d418cef32ecc4de6929868718a9cb4734c4dbadc1602bd9cd0ce9e81a  zot-2.0.1.tar.gz
8b0f168193c664bb9f22f3340c8fcf934cf20cb53f89e25be417efb5633deb01f2dcedbd4960b03a94490f89a44ac2e53def839e2aa9489eab6ca52759d02c18  zui-f4a6030d93c4111af699a3ea0c154bd212e5aa06.tar.gz
86dfa273e97110b703fbc368757520ef6169dead185ff54b5b8ba45e764949bc3a21a51d53a1605d7163faef8c83c066e688577f5315b8c0afb09f69a2bbe3bb  zot.initd
b128ecaf3e35cfdab8069da9a8267a9faed50b892ae07b6a4a22a4108236d6cdbc10cc4cf0105c728e9e6da6ac773f56d1dd84de1ba4463110058b6c2f190b30  zot.confd
"