summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 664a104d0760cdc1d045e8be258e9813a735ad87 (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: Tony Lambiris <tony@libpcap.net>

pkgname=clair-git
pkgver=v3.0.0.pre1.r35.g9897d151
pkgrel=1
pkgdesc="Vulnerability Static Analysis for Containers"
arch=(x86_64)
url='https://github.com/coreos/clair'
license=(Apache)
makedepends=('git' 'go')
source=("${pkgname}::git+${url}")
sha256sums=('SKIP')

pkgver() {
	cd "${srcdir}/${pkgname}"

	git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
	cd "${srcdir}/${pkgname}"

	install -m755 -d "${srcdir}/go/src/github.com/coreos/"
	ln -sf "${srcdir}/${pkgname}" "${srcdir}/go/src/github.com/coreos/clair"

	cd "${srcdir}/go/src/github.com/coreos/clair"

	export GOPATH="${srcdir}/go" PATH="${srcdir}/go/bin:${PATH}"
	go get -v ./...
}

build() {
	cd "${srcdir}/go/src/github.com/coreos/clair"

	mkdir -p build

	export GOPATH="${srcdir}/go" PATH="${srcdir}/go/bin:${PATH}"
	go build \
		-ldflags "-s -w -X github.com/coreos/clair/pkg/version.Version=${pkgver}" \
		-gcflags="all=-trimpath=${GOPATH}/src" \
		-asmflags="all=-trimpath=${GOPATH}/src" \
		-o build/clair -v ./cmd/clair
}

package() {
	cd "${srcdir}/go/src/github.com/coreos/clair"

	install -Dm755 "build/clair" "${pkgdir}/usr/bin/clair"
	install -Dm755 "config.yaml.sample" "${pkgdir}/etc/clair/config.yaml"
	install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}