aboutsummaryrefslogtreecommitdiffstats
path: root/testing/lxd/APKBUILD
blob: 62585bdd0042f8b990b4fab5a667947397e4157d (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=lxd
pkgver=3.15
pkgrel=0
pkgdesc="a container hypervisor and a new user experience for LXC"
url="https://linuxcontainers.org/lxd/"
arch="all !aarch64"
license="Apache-2.0"
depends="
	acl
	xz
	netcat-openbsd
	cgmanager
	squashfs-tools
	rsync
	shadow-uidmap
	lxc
	ip6tables
	dnsmasq
	ca-certificates
	tar
	"
makedepends="
	lxc-dev
	gettext-dev
	acl-dev
	tcl-dev
	libuv-dev
	libcap-dev
	linux-headers

	rsync
	go
	intltool

	libtool
	autoconf
	automake
	patchelf
	"
subpackages="
	$pkgname-scripts:scripts
	$pkgname-bash-completion:bashcomp:noarch
	$pkgname-openrc
	$pkgname-libs
	"
install="$pkgname.pre-install"
options="!check"
source="https://linuxcontainers.org/downloads/$pkgname/$pkgname-$pkgver.tar.gz
	$pkgname.confd
	$pkgname.initd
	lxd-dont-go-get.patch
	error-h-not-avail.patch
	"
# avoid conflict with system libsqlite3.so.0 by adding a soname prefix.
# this makes lxd-libs provide so:lxd:libsqlite3.so.0 and lxd depend on
# so:lxd:libsqlite3.so.0.
ldpath="/usr/lib/lxd"
sonameprefix="$pkgname:"

_project="github.com/lxc/lxd"

prepare() {
	export GOPATH="$builddir/dist"
	default_prepare
	update_config_guess
	for p in raft sqlite dqlite; do
		cd "$GOPATH"/$p
		autoreconf -i
	done
}

build() {
	export GOPATH="$builddir/dist"
	export CGO_CFLAGS="-I${GOPATH}/sqlite/ -I${GOPATH}/libco/ -I${GOPATH}/raft/include/ -I${GOPATH}/dqlite/include/"
	export CGO_LDFLAGS="$CGO_LDFLAGS -L${GOPATH}/sqlite/.libs/ -L${GOPATH}/libco/ -L${GOPATH}/raft/.libs -L${GOPATH}/dqlite/.libs/ -lintl"
	export LD_LIBRARY_PATH="$ldpath ${GOPATH}/sqlite/.libs/:${GOPATH}/libco/:${GOPATH}/raft/.libs/:${GOPATH}/dqlite/.libs/"

	cd "$GOPATH"/raft
    PKG_CONFIG_PATH="${GOPATH}/raft/" ./configure \
        --prefix=/usr \
        --libdir=/usr/lib/lxd
	make

	cd "$GOPATH"/libco
	make
	
	cd "$GOPATH"/sqlite
	./configure \
		--prefix=/usr \
		--enable-replication \
		--disable-amalgamation \
		--disable-tcl \
		--libdir=/usr/lib/lxd
	make

	cd "$GOPATH"/dqlite
	PKG_CONFIG_PATH="${GOPATH}/sqlite/:${GOPATH}/libco/:${GOPATH}/raft/" ./configure \
		--prefix=/usr \
		--libdir=/usr/lib/lxd

	make CFLAGS="-I${GOPATH}/sqlite/ -I${GOPATH}/libco/ -I${GOPATH}/raft/include/" LDFLAGS="-L${GOPATH}/sqlite/.libs/ -L${GOPATH}/libco/ -L${GOPATH}/raft/.libs/"

	cd "$builddir"
	go install -v -x $_project/lxc
	go install -v -x -tags libsqlite3 $_project/lxd
	for tool in fuidshift lxc-to-lxd lxd-benchmark lxd-p2c; do
		go install -v -x $_project/$tool
	done
}

package() {
	for r in sqlite dqlite; do
		cd "$GOPATH"/$r
		make DESTDIR="$pkgdir" install
	done

	cp ${GOPATH}/libco/libco.so* "$pkgdir"/usr/lib/lxd
	cp ${GOPATH}/raft/.libs/libraft.so* "$pkgdir"/usr/lib/lxd

	rm $pkgdir/usr/bin/sqlite3
	rm -r $pkgdir/usr/include

	cd ${GOPATH}
	install -Dm755 bin/$pkgname "$pkgdir"/usr/sbin/$pkgname
	install -Dm755 bin/lxc "$pkgdir"/usr/bin/lxc
	
	patchelf --set-rpath "/usr/lib/lxd" "${pkgdir}/usr/sbin/lxd"
	
	install -Dm755 "$srcdir"/lxd.initd \
		"$pkgdir"/etc/init.d/lxd
	install -Dm644 "$srcdir"/lxd.confd \
		"$pkgdir"/etc/conf.d/lxd
}

bashcomp() {
	depends="bash"
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	cd "$builddir"
	mkdir -p "$subpkgdir"/usr/share/bash-completion/completions
	cp scripts/bash/lxd-client "$subpkgdir"/usr/share/bash-completion/completions/lxd-client
}

scripts() {
	pkgdesc="LXD scripts"
	depends="$pkgname py3-lxc"

	export GOPATH="$builddir/dist"
	cd $GOPATH

	for tool in fuidshift lxc-to-lxd lxd-benchmark lxd-p2c; do
		install -Dm755 bin/$tool "$subpkgdir"/usr/bin/$tool
	done
}

libs() {
	pkgdesc="LXD bundled libraries"
	depends=
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
	patchelf --set-rpath "/usr/lib/lxd" "${subpkgdir}/usr/lib/lxd/libdqlite.so"
	patchelf --set-rpath "/usr/lib/lxd" "${subpkgdir}/usr/lib/lxd/libsqlite3.so"
	rm -rf "$subpkgdir"/usr/lib/lxd/pkgconfig \
		"$subpkgdir"/usr/lib/lxd/*.a
}

sha512sums="de7ad00c8827d13513eb7d01469441bce6b64554939b6cc8c2a106d457b1b959ff21dbc81d28b13551c121f74b2d4c3a5024926fa28f82d2e3f1de670f23250f  lxd-3.15.tar.gz
bc32c71f2ce10f508433e1e4651c08c18e8a17e9419a7ce391c0f127fc7cf378c665178926b35eae8813e290d9c5eab3ceb605679fd32efdf2cf98a57cee4127  lxd.confd
94de0c0d5ab63463a929a4151359950b1117d0ada5ccf0944311cc70c6b6d4c437ccb4158734ab35db67bfb4abc437074c3f3515be4531f63adc74da21fefb5b  lxd.initd
a77a74950110c94727956457843cd3f64c0db901fb05b95ab0edaa966f7fe76a993d86c8a51d14724a11846a69261199594f683dfefa1db633f4ca35c7f23607  lxd-dont-go-get.patch
64d0cb8c3555bcf4fec106d86262ec5075b813df12b5ae59808b4d7776abf73380eddfef1504c975fe44aaed8b637cb8a9323b914e564306e97494d213986db3  error-h-not-avail.patch"