summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e2835c9139e49bb2ed3ffce27c9bba704cbf6b91 (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
# Maintainer: Kainoa Kanter <kainoa@t1c.dev>
# Based on `fastly` by Luis Martinez <luis.martinez@disroot.org>
# Contributor: oss@fastly.com

_pkgname=fastly
pkgname="$_pkgname-git"
pkgver=r1071.gfc70ca57
pkgrel=1
pkgdesc='CLI for the Fastly platform'
url='https://github.com/fastly/cli'
arch=('aarch64' 'i686' 'x86_64')
license=('Apache')
depends=('glibc')
makedepends=('git' 'go' 'rust')
provides=('fastly')
conflicts=('fastly-bin' 'fastly')
source=("$_pkgname::git+$url")
sha256sums=('SKIP')

pkgver() {
    cd "${srcdir}/${_pkgname}" || exit
    printf "r%s.g%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
	cd "$_pkgname"
	go mod download
	sed -i '/CGO_ENABLED=/s/0/1/g' Makefile
}

build() {
	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"
	cd "$_pkgname"
	make build \
		VERSION="$pkgver" \
		CLI_ENV="production" \
		GORELEASER_ARGS="--rm-dist --single-target" \
		GO_ARGS="${GOFLAGS}"
	./fastly --completion-script-bash > fastly.bash
	./fastly --completion-script-zsh > _fastly
}

check() {
	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"
	cd "$_pkgname"
	go test ./...
}

package() {
	cd "$_pkgname"
	install -Dv fastly -t "$pkgdir/usr/bin/"
	install -Dvm644 fastly.bash "$pkgdir/usr/share/bash-completion/completions/$_pkgname"
	install -Dvm644 _fastly -t "$pkgdir/usr/share/zsh/site-functions/"
}