# Contributor: Carlo Landmeter # Maintainer: Francesco Colista pkgname=lxd pkgver=3.16 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 " # 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"/deps/$p autoreconf -i done } build() { export GOPATH="$builddir/_dist" export CGO_CFLAGS="-I${GOPATH}/deps/sqlite/ -I${GOPATH}/deps/libco/ -I${GOPATH}/deps/raft/include/ -I${GOPATH}/deps/dqlite/include/" export CGO_LDFLAGS="$CGO_LDFLAGS -L${GOPATH}/deps/sqlite/.libs/ -L${GOPATH}/deps/libco/ -L${GOPATH}/deps/raft/.libs -L${GOPATH}/deps/dqlite/.libs/ -lintl" export LD_LIBRARY_PATH="$ldpath ${GOPATH}/deps/sqlite/.libs/:${GOPATH}/deps/libco/:${GOPATH}/deps/raft/.libs/:${GOPATH}/deps/dqlite/.libs/" cd "$GOPATH"/deps/raft PKG_CONFIG_PATH="${GOPATH}/deps/raft/" ./configure \ --prefix=/usr \ --libdir=/usr/lib/lxd make cd "$GOPATH"/deps/libco make cd "$GOPATH"/deps/sqlite ./configure \ --prefix=/usr \ --enable-replication \ --disable-amalgamation \ --disable-tcl \ --libdir=/usr/lib/lxd make cd "$GOPATH"/deps/dqlite PKG_CONFIG_PATH="${GOPATH}/deps/sqlite/:${GOPATH}/deps/libco/:${GOPATH}/deps/raft/" ./configure \ --prefix=/usr \ --libdir=/usr/lib/lxd make CFLAGS="-I${GOPATH}/deps/sqlite/ -I${GOPATH}/deps/libco/ -I${GOPATH}/deps/raft/include/" LDFLAGS="-L${GOPATH}/deps/sqlite/.libs/ -L${GOPATH}/deps/libco/ -L${GOPATH}/deps/raft/.libs/" cd "$builddir" go install -v -x -tags libsqlite3 $_project/lxd for bin in lxc fuidshift lxc-to-lxd lxd-benchmark lxd-p2c; do go install -v -x $_project/$bin done } package() { for r in sqlite dqlite; do cd "$GOPATH"/deps/$r make DESTDIR="$pkgdir" install done cp ${GOPATH}/deps/libco/libco.so* "$pkgdir"/usr/lib/lxd cp ${GOPATH}/deps/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 install -Dm755 ../scripts/empty-lxd.sh "$subpkgdir"/usr/bin/empty-lxd.sh } libs() { pkgdesc="LXD bundled libraries" 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 rm -r "$pkgdir"/etc } sha512sums="11c6c5c49ceb23c31979829937e1baad340b8920481ef5b89b2b6d0b6b05967ec1f446f8b0330c11008f6fecea077eed0858af7fe802c50b52148757584fdfb9 lxd-3.16.tar.gz bc32c71f2ce10f508433e1e4651c08c18e8a17e9419a7ce391c0f127fc7cf378c665178926b35eae8813e290d9c5eab3ceb605679fd32efdf2cf98a57cee4127 lxd.confd 94de0c0d5ab63463a929a4151359950b1117d0ada5ccf0944311cc70c6b6d4c437ccb4158734ab35db67bfb4abc437074c3f3515be4531f63adc74da21fefb5b lxd.initd 7453a02f003b2b3ccc2695649ca6b39157f1bd30070815e6addaacb280ea935d79bc5d265925aeec379a16f0235387d8333c3f25519c959b980fe15ad2d5728c lxd-dont-go-get.patch"