aboutsummaryrefslogtreecommitdiffstats
path: root/testing/consul/APKBUILD
blob: 4de97d48e5e9651c668f08703d5122cd923f21e0 (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
# Contributor: Olivier Mauras <olivier@mauras.ch>
# Maintainer:
pkgname=consul
pkgver=0.5.2
pkgrel=0
pkgdesc="A tool for service discovery, monitoring and configuration"
url="https://www.consul.io/"
arch="all"
license="MPL 2.0"
depends=""
depends_dev=""
makedepends="go godep perl bash mercurial $depends_dev"
install="$pkgname.pre-install $pkgname.pre-deinstall $pkgname.post-deinstall"
pkgusers="consul"
pkggroups="consul"
subpackages=""
options="!strip"
source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz
	consul.initd
	consul.confd
	acl.json.sample
	encrypt.json.sample
	server.json
	tls.json.sample"

_disturl="dev.alpinelinux.org:/archive/$pkgname/"
_gourl="github.com/hashicorp/consul"
_builddir="$srcdir"/src/github.com/hashicorp

snapshot() {
	abuild clean
	abuild deps
	abuild fetch
	export GOPATH="$srcdir"
	mkdir -p $_builddir
	cd $_builddir
	msg "Checking out v${pkgver} tag"
	git clone -q --branch v${pkgver} https://$_gourl || return 1
	cd $pkgname
	# use custom godeps file
	install -D "${_builddir}"/$pkgname/deps/v${pkgver//./-}.json \
		$_builddir/$pkgname/Godeps/Godeps.json || return 1
	go get -v -d || return 1
	godep restore
	cd "$srcdir"
	tar zcf $pkgname-$pkgver.tar.gz src || return 1
	rsync --progress -La $pkgname-$pkgver.tar.gz \
		$_disturl || return 1
	cd $startdir && abuild undeps
}

prepare() {
	cd "$srcdir"/${pkgname}-${pkgver}
	local i
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"/$pkgname || return 1
	export GOPATH="$srcdir"
	go build -v -o bin/consul \
		-ldflags "-X main.GitDescribe $pkgver" || return 1
}

package() {
	cd "$_builddir"
	# Consul init script
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname || return 1
	# Consul init conf
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname || return 1
	# Main binary
	install -m750 -o root -g consul \
		-D ${pkgname}/bin/${pkgname} \
		"$pkgdir"/usr/sbin/${pkgname} || return 1
	# Consul datadir
	install -m750 -o consul -g consul -d "$pkgdir"/var/${pkgname} || return 1
	# Consul configdir
	install -m750 -o root -g consul -d "$pkgdir"/etc/${pkgname} || return 1
	# Consul sample config files
	for cf in acl.json.sample encrypt.json.sample server.json tls.json.sample; do
		install -m640 -o root -g consul "$srcdir"/$cf "$pkgdir"/etc/${pkgname} || return 1
	done
}