2021-08-12 11:12:38 -07:00
|
|
|
# Copyright 2020-2021 LiGurOs Authors
|
2021-08-12 10:47:09 -07:00
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
EAPI=7
|
|
|
|
|
|
|
|
DESCRIPTION="Fast, dense and secure container management"
|
2021-08-12 11:12:38 -07:00
|
|
|
HOMEPAGE="https://linuxcontainers.org/lxd/introduction/"
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
LICENSE="Apache-2.0 BSD BSD-2 LGPL-3 MIT MPL-2.0"
|
2021-08-12 10:47:09 -07:00
|
|
|
SLOT="1"
|
2021-08-12 11:12:38 -07:00
|
|
|
KEYWORDS="amd64 ~arm ~arm64 x86"
|
|
|
|
|
|
|
|
IUSE="+daemon +ipv6 +dnsmasq nls test +tools"
|
|
|
|
|
|
|
|
inherit autotools bash-completion-r1 linux-info systemd user
|
|
|
|
|
|
|
|
SRC_URI="https://linuxcontainers.org/downloads/${PN}/${P}.tar.gz"
|
|
|
|
|
|
|
|
DEPEND="
|
2021-08-12 10:47:09 -07:00
|
|
|
acct-group/lxd
|
2021-08-12 11:12:38 -07:00
|
|
|
>=dev-libs/raft-0.9.22
|
|
|
|
>=dev-db/sqlite-3.25
|
|
|
|
dev-lang/tcl
|
|
|
|
>=dev-lang/go-1.9.4
|
|
|
|
dev-libs/libuv
|
|
|
|
dev-libs/protobuf
|
2021-08-12 10:47:09 -07:00
|
|
|
nls? ( sys-devel/gettext )
|
2021-08-12 11:12:38 -07:00
|
|
|
test? (
|
|
|
|
app-misc/jq
|
|
|
|
net-misc/curl
|
|
|
|
sys-devel/gettext
|
|
|
|
)
|
|
|
|
"
|
|
|
|
|
|
|
|
RDEPEND="
|
|
|
|
daemon? (
|
|
|
|
dev-libs/raft
|
|
|
|
app-arch/xz-utils
|
|
|
|
>=app-emulation/lxc-4.0.0
|
|
|
|
dev-libs/libuv
|
|
|
|
dev-libs/lzo
|
|
|
|
dev-util/xdelta:3
|
|
|
|
dnsmasq? (
|
|
|
|
net-dns/dnsmasq[dhcp,ipv6?]
|
|
|
|
)
|
|
|
|
net-firewall/ebtables
|
|
|
|
net-firewall/iptables[ipv6?]
|
|
|
|
net-libs/libnfnetlink
|
|
|
|
net-libs/libnsl:0=
|
|
|
|
net-misc/rsync[xattr]
|
|
|
|
sys-apps/iproute2[ipv6?]
|
|
|
|
sys-fs/fuse
|
|
|
|
sys-fs/lxcfs
|
|
|
|
sys-fs/squashfs-tools[lzma]
|
|
|
|
virtual/acl
|
|
|
|
)
|
|
|
|
"
|
2021-08-12 10:47:09 -07:00
|
|
|
|
|
|
|
CONFIG_CHECK="
|
2021-08-12 11:12:38 -07:00
|
|
|
~BRIDGE
|
|
|
|
~DUMMY
|
|
|
|
~IP6_NF_NAT
|
|
|
|
~IP6_NF_TARGET_MASQUERADE
|
|
|
|
~IPV6
|
|
|
|
~IP_NF_NAT
|
|
|
|
~IP_NF_TARGET_MASQUERADE
|
|
|
|
~MACVLAN
|
|
|
|
~NETFILTER_XT_MATCH_COMMENT
|
|
|
|
~NET_IPGRE
|
|
|
|
~NET_IPGRE_DEMUX
|
|
|
|
~NET_IPIP
|
|
|
|
~NF_NAT_MASQUERADE_IPV4
|
|
|
|
~NF_NAT_MASQUERADE_IPV6
|
|
|
|
~VXLAN
|
2021-08-12 10:47:09 -07:00
|
|
|
"
|
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
ERROR_BRIDGE="BRIDGE: needed for network commands"
|
|
|
|
ERROR_DUMMY="DUMMY: needed for network commands"
|
|
|
|
ERROR_IP6_NF_NAT="IP6_NF_NAT: needed for network commands"
|
|
|
|
ERROR_IP6_NF_TARGET_MASQUERADE="IP6_NF_TARGET_MASQUERADE: needed for network commands"
|
|
|
|
ERROR_IPV6="IPV6: needed for network commands"
|
|
|
|
ERROR_IP_NF_NAT="IP_NF_NAT: needed for network commands"
|
|
|
|
ERROR_IP_NF_TARGET_MASQUERADE="IP_NF_TARGET_MASQUERADE: needed for network commands"
|
|
|
|
ERROR_MACVLAN="MACVLAN: needed for network commands"
|
|
|
|
ERROR_NETFILTER_XT_MATCH_COMMENT="NETFILTER_XT_MATCH_COMMENT: needed for network commands"
|
|
|
|
ERROR_NET_IPGRE="NET_IPGRE: needed for network commands"
|
|
|
|
ERROR_NET_IPGRE_DEMUX="NET_IPGRE_DEMUX: needed for network commands"
|
|
|
|
ERROR_NET_IPIP="NET_IPIP: needed for network commands"
|
|
|
|
ERROR_NF_NAT_MASQUERADE_IPV4="NF_NAT_MASQUERADE_IPV4: needed for network commands"
|
|
|
|
ERROR_NF_NAT_MASQUERADE_IPV6="NF_NAT_MASQUERADE_IPV6: needed for network commands"
|
|
|
|
ERROR_VXLAN="VXLAN: needed for network commands"
|
2021-08-12 10:47:09 -07:00
|
|
|
|
|
|
|
EGO_PN="github.com/lxc/lxd"
|
|
|
|
|
|
|
|
src_prepare() {
|
|
|
|
default
|
2021-08-12 11:12:38 -07:00
|
|
|
eapply_user
|
|
|
|
|
|
|
|
cd "${S}/_dist/deps/dqlite" || die "Can't cd to dqlite dir"
|
|
|
|
eautoreconf
|
|
|
|
}
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
src_configure() {
|
2021-08-12 10:47:09 -07:00
|
|
|
export GOPATH="${S}/_dist"
|
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
cd "${GOPATH}/deps/dqlite" || die "Can't cd to dqlite dir"
|
|
|
|
econf --libdir=${EPREFIX}/usr/lib/lxd
|
2021-08-12 10:47:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
src_compile() {
|
|
|
|
export GOPATH="${S}/_dist"
|
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
cd "${GOPATH}/deps/dqlite" || die "Can't cd to dqlite dir"
|
|
|
|
emake CFLAGS="-I${GOPATH}/deps/sqlite" LDFLAGS="-L${GOPATH}/deps/sqlite"
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
# We don't use the Makefile here because it builds targets with the
|
|
|
|
# assumption that `pwd` is in a deep gopath namespace, which we're not.
|
|
|
|
# It's simpler to manually call "go install" than patching the Makefile.
|
|
|
|
cd "${S}"
|
|
|
|
GO111MODULE=auto go install -v -x ${EGO_PN}/lxc || die "Failed to build the client"
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
if use daemon; then
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
# LXD depends on a patched, bundled sqlite with replication
|
|
|
|
# capabilities.
|
|
|
|
export CGO_CFLAGS="-I${GOPATH}/deps/dqlite/include/"
|
|
|
|
export CGO_LDFLAGS="-L${GOPATH}/deps/dqlite/.libs/ -Wl,-rpath,${EPREFIX}/usr/lib/lxd"
|
|
|
|
export LD_LIBRARY_PATH="${GOPATH}/deps/dqlite/.libs/"
|
|
|
|
|
|
|
|
GO111MODULE=auto go install -v -x ${EGO_PN}/lxd || die "Failed to build the daemon"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if use tools; then
|
|
|
|
GO111MODULE=auto go install -v -x ${EGO_PN}/fuidshift || die "Failed to build fuidshift"
|
|
|
|
GO111MODULE=auto go install -v -x ${EGO_PN}/lxc-to-lxd || die "Failed to build lxc-to-lxd"
|
|
|
|
GO111MODULE=auto go install -v -x ${EGO_PN}/lxd-agent || die "Failed to build lxd-agent"
|
|
|
|
GO111MODULE=auto go install -v -x ${EGO_PN}/lxd-benchmark || die "Failed to build lxd-benchmark"
|
|
|
|
GO111MODULE=auto go install -v -x ${EGO_PN}/lxd-p2c || die "Failed to build lxd-p2c"
|
|
|
|
fi
|
2021-08-12 10:47:09 -07:00
|
|
|
|
|
|
|
use nls && emake build-mo
|
2021-08-12 11:12:38 -07:00
|
|
|
|
|
|
|
mkdir _dist/man
|
|
|
|
./_dist/bin/lxc manpage _dist/man/
|
2021-08-12 10:47:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
src_test() {
|
2021-08-12 11:12:38 -07:00
|
|
|
if use daemon; then
|
|
|
|
export GOPATH="${S}/_dist"
|
|
|
|
# This is mostly a copy/paste from the Makefile's "check" rule, but
|
|
|
|
# patching the Makefile to work in a non "fully-qualified" go namespace
|
|
|
|
# was more complicated than this modest copy/paste.
|
|
|
|
# Also: sorry, for now a network connection is needed to run tests.
|
|
|
|
# Will properly bundle test dependencies later.
|
|
|
|
go get -v -x github.com/rogpeppe/godeps
|
|
|
|
go get -v -x github.com/remyoudompheng/go-misc/deadcode
|
|
|
|
go get -v -x github.com/golang/lint/golint
|
|
|
|
go test -v ${EGO_PN}/lxd
|
|
|
|
else
|
|
|
|
einfo "No tests to run for client-only builds"
|
|
|
|
fi
|
2021-08-12 10:47:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
src_install() {
|
|
|
|
local bindir="_dist/bin"
|
2021-08-12 11:12:38 -07:00
|
|
|
dobin ${bindir}/lxc
|
|
|
|
if use daemon; then
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
export GOPATH="${S}/_dist"
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
cd "${GOPATH}/deps/dqlite" || die "Can't cd to dqlite dir"
|
|
|
|
emake DESTDIR="${D}" install
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
# Must only install libs
|
|
|
|
rm -r "${D}/usr/include" || die "Can't remove include directory"
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
cd "${S}" || die "Can't cd to \${S}"
|
|
|
|
dosbin ${bindir}/lxd
|
|
|
|
fi
|
|
|
|
|
|
|
|
if use tools; then
|
|
|
|
dobin ${bindir}/fuidshift
|
|
|
|
dobin ${bindir}/lxc-to-lxd
|
|
|
|
dobin ${bindir}/lxd-agent
|
|
|
|
dobin ${bindir}/lxd-benchmark
|
|
|
|
dobin ${bindir}/lxd-p2c
|
|
|
|
fi
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
insinto /etc/sysctl.d
|
|
|
|
newins "${FILESDIR}/${PN}-sysctl.conf" 60-${PN}.conf
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
if use nls; then
|
|
|
|
domo po/*.mo
|
2021-08-12 10:47:09 -07:00
|
|
|
fi
|
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
if use daemon; then
|
|
|
|
newinitd "${FILESDIR}"/${PN}.initd lxd
|
|
|
|
newconfd "${FILESDIR}"/${PN}.confd lxd
|
2021-08-12 10:47:09 -07:00
|
|
|
|
2021-08-12 11:12:38 -07:00
|
|
|
systemd_newunit "${FILESDIR}"/${PN}.service ${PN}.service
|
|
|
|
fi
|
|
|
|
|
|
|
|
newbashcomp scripts/bash/lxd-client lxc
|
|
|
|
|
|
|
|
doman _dist/man/*
|
2021-08-12 10:47:09 -07:00
|
|
|
dodoc AUTHORS doc/*
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg_postinst() {
|
|
|
|
elog
|
|
|
|
elog "Consult https://wiki.gentoo.org/wiki/LXD for more information,"
|
|
|
|
elog "including a Quick Start."
|
2021-08-12 11:12:38 -07:00
|
|
|
|
|
|
|
# The messaging below only applies to daemon installs
|
|
|
|
use daemon || return 0
|
|
|
|
|
|
|
|
# Ubuntu also defines an lxd user but it appears unused (the daemon
|
|
|
|
# must run as root)
|
2021-08-12 10:47:09 -07:00
|
|
|
elog
|
2021-08-12 11:12:38 -07:00
|
|
|
elog "Though not strictly required, some features are enabled at run-time"
|
|
|
|
elog "when the relevant helper programs are detected:"
|
|
|
|
elog "- sys-apps/apparmor"
|
|
|
|
elog "- sys-fs/btrfs-progs"
|
|
|
|
elog "- sys-fs/lvm2"
|
|
|
|
elog "- sys-fs/zfs"
|
|
|
|
elog "- sys-process/criu"
|
2021-08-12 10:47:09 -07:00
|
|
|
elog
|
2021-08-12 11:12:38 -07:00
|
|
|
elog "Since these features can't be disabled at build-time they are"
|
|
|
|
elog "not USE-conditional."
|
2021-08-12 10:47:09 -07:00
|
|
|
elog
|
|
|
|
elog "Be sure to add your local user to the lxd group."
|
2021-08-12 11:12:38 -07:00
|
|
|
elog
|
|
|
|
elog "Networks with bridge.mode=fan are unsupported due to requiring"
|
|
|
|
elog "a patched kernel and iproute2."
|
2021-08-12 10:47:09 -07:00
|
|
|
}
|
2021-08-12 11:12:38 -07:00
|
|
|
|