From 955c0c676e60d7bcc91514c80b425abe289ec6d6 Mon Sep 17 00:00:00 2001 From: Ronald Farrer Date: Thu, 12 Aug 2021 10:47:09 -0700 Subject: [PATCH] Added initial lxd ebuild. --- app-emulation/lxd/Manifest | 10 ++ app-emulation/lxd/files/lxd-4.0.0.confd | 23 +++ app-emulation/lxd/files/lxd-4.0.0.initd | 47 +++++ app-emulation/lxd/files/lxd-4.0.0.service | 20 +++ app-emulation/lxd/files/lxd-4.0.0.socket | 12 ++ .../lxd/files/lxd-4.0.0_apparmor.service | 21 +++ .../lxd/files/lxd-containers-4.0.0.service | 16 ++ app-emulation/lxd/lxd-4.17.ebuild | 164 ++++++++++++++++++ app-emulation/lxd/metadata.xml | 20 +++ 9 files changed, 333 insertions(+) create mode 100644 app-emulation/lxd/Manifest create mode 100644 app-emulation/lxd/files/lxd-4.0.0.confd create mode 100644 app-emulation/lxd/files/lxd-4.0.0.initd create mode 100644 app-emulation/lxd/files/lxd-4.0.0.service create mode 100644 app-emulation/lxd/files/lxd-4.0.0.socket create mode 100644 app-emulation/lxd/files/lxd-4.0.0_apparmor.service create mode 100644 app-emulation/lxd/files/lxd-containers-4.0.0.service create mode 100644 app-emulation/lxd/lxd-4.17.ebuild create mode 100644 app-emulation/lxd/metadata.xml diff --git a/app-emulation/lxd/Manifest b/app-emulation/lxd/Manifest new file mode 100644 index 0000000..4cc8c54 --- /dev/null +++ b/app-emulation/lxd/Manifest @@ -0,0 +1,10 @@ +AUX lxd-4.0.0.confd 582 BLAKE2B 88ce8ec99eb50174bffea7d3b8bddc67b50fe6677d54df115c9069311b5fb59a72170a15988f50714740074f7ec4f2cd32fb47b6d8c52cf69b8c6fa332162a06 SHA512 96d922ae81677eebace3f8d2dff7f67d58701c40c09e2435677f9289cca89fe260c0d9526059d3772c3405a5b8ec52466bf7d7a920dcdd7551f1b3f01f2fc9c4 +AUX lxd-4.0.0.initd 1221 BLAKE2B cdff6d900e09f85d9a4dc86b30f0d32b848689e209b79b48217e2f844a48fb358850cbc27db1aed7c1b957bbc19af2d76856fd65319a0a207cedfefbadf659cc SHA512 8b176036c1e5f2ffac4c94e781694fb637fa53666f10da1d5d2b3f1fc341f02003e5306dbd332edd9eeb6f7b08dffd9190c7f65361a40220f6f88d56e4c78a57 +AUX lxd-4.0.0.service 519 BLAKE2B 5314820c25e52449aad8db6584739cbe0f2654111e4b42c3eef0df995373487c789390dee99420dfd1aa5768ba66ba72999e8f2d8a3b0be6e621185f185b5b85 SHA512 c68c4106e189bd32538f5f2963c43afc30418dd9afeca56e5590f354725eb0126ee0aac02082cc42d69b851f392a4977a4f95cf2886044ad563c9a36facea222 +AUX lxd-4.0.0.socket 197 BLAKE2B 8c0d2dee71c14ee5f34b2bd0804adfa06ab3ae2a73bcf8d122184434c42b7f91f66fe610bddda93c458e0f171b505fe79a4f268d8243aabdf226f47e95027e71 SHA512 d70dc867b2e92b69928c83fc5feca4e387808adbc267b9fe4ecf0c8befdf3ca13366b229c6eefcb5667e51405fb0aa4e6bb8f59a0b5b5fb3895c46b4aaab0661 +AUX lxd-4.0.0_apparmor.service 567 BLAKE2B e5951c31f90b842f5b625060326d9611ed67fb50360b11791cbd1ab1953fdfe5eb726e22b7091bb8e45c294b772e6b00e9ca65833512eb5b570627fa3234812e SHA512 364764d007f4800138c712fce70fe28b096b6e35dc6d2e4f8aa9aff4b335ecec7dfc9600a1a16cd38e69a96534b7462daf5f6e946a2ee81bce17977b8d5911db +AUX lxd-containers-4.0.0.service 322 BLAKE2B a38cffd4b5809946abdac858564dcab2c2967c295d671df0d315d790df1849e25f0bc052e20cd0d9e4c23403289050b4538f5a52437ab8ae9ca3b40c6a9a1571 SHA512 a55f2c1a367c5c3c5eb6880e01893977de18c6e9463949236ee3247715fbf53641bbe1b69404362dd6cb6ba2a30ac6539fd362b21059e529dc4dac4ec5ca6718 +DIST lxd-4.17.tar.gz 15930575 BLAKE2B 8d4ec6a63daa348cebb50e9cc7568626dfba39fc2e409fe562ed9fe115478754df5a10803c0bde10112d6f70e0236f276cdc14c62f9a6f2b505c04e0bc270443 SHA512 c7570c6ba0b7c8f0025dcc185fa2a073b28b5d5589d49cb3340b8bd25d99d3bf0e5a9887e212e5ca88caf9c744052a038f7d2399f1386ebf6f0050a189c391b9 +DIST lxd-4.17.tar.gz.asc 833 BLAKE2B 19735b7bd90b504aba4a2b946b7171bead158bc4adaf566cd38c830e6c27850117c23da3ffc667dfe780c7ce621f0aaa58643fd461ca9139df4c19c9fe0a7b1a SHA512 e8888c05710e7e22e0ee8899d754865c3852a360c3ed84d4ce12b589f7afa5c9c049c11aea05d7a505c72f64c7f379b65b89bbe307118f520bfc4754a04aca15 +EBUILD lxd-4.17.ebuild 4213 BLAKE2B a2f99e67273d050702910790ae2b32f208de2ab25d48135bf428a09d8dfc9e461943aa03a27c4c8c9a06819a32d3fc72610f6892f1a6b4f6e3396d25ce3e41d3 SHA512 2246c8e2bbaafe40f76cdcfe5afa67560474630143e0abc8796456ddebb4d61f2e631d972416121032f5bddd78635aeb34167772a371a9ebe3d9cf24c020fe2c +MISC metadata.xml 614 BLAKE2B 9e3b2ece887f337fa3574d2b3466ae5448426ecd50c189af885bf5c2b9dc28e240569efb6c280b83b47e4c6b91fa0f45c7a237240ebda21169c1be76332b09cb SHA512 98acc201befa71acafd9ab8f67959e658269071c4903ef822dd10770903ca8fb34fa7a0b7f47e080783377a44a0098770dabd57262ec9c31f6ffc736f6ca4b55 diff --git a/app-emulation/lxd/files/lxd-4.0.0.confd b/app-emulation/lxd/files/lxd-4.0.0.confd new file mode 100644 index 0000000..68cf344 --- /dev/null +++ b/app-emulation/lxd/files/lxd-4.0.0.confd @@ -0,0 +1,23 @@ +# Group which owns the shared socket +LXD_OPTIONS+=" --group lxd" + +# Enable cpu profiling into the specified file +#LXD_OPTIONS+=" --cpuprofile /tmp/lxc_cpu_profile" + +# Enable memory profiling into the specified file +#LXD_OPTIONS+=" --memprofile /tmp/lxc_mem_profile" + +# Enable debug mode +#LXD_OPTIONS+=" --debug" + +# For debugging, print a complete stack trace every n seconds +#LXD_OPTIONS+=" --print-goroutines-every 5" + +# Enable verbose mode +#LXD_OPTIONS+=" -v" + +# Logfile to log to +#LXD_OPTIONS+=" --logfile /var/log/lxd/lxd.log" + +# Enable syslog logging +#LXD_OPTIONS+=" --syslog" diff --git a/app-emulation/lxd/files/lxd-4.0.0.initd b/app-emulation/lxd/files/lxd-4.0.0.initd new file mode 100644 index 0000000..e6ae971 --- /dev/null +++ b/app-emulation/lxd/files/lxd-4.0.0.initd @@ -0,0 +1,47 @@ +#!/sbin/openrc-run +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +DAEMON=/usr/sbin/lxd +PIDFILE=/run/lxd.pid + +depend() { + need net + need lxcfs +} + +start() { + ebegin "Starting lxd service" + + modprobe -f loop > /dev/null 2>&1 + + # fix permissions on /var/lib/lxd and make sure it exists + install -d /var/lib/lxd --group lxd --owner root --mode 0775 + start-stop-daemon --start \ + --pidfile ${PIDFILE} \ + --exec ${DAEMON} \ + --background \ + --make-pidfile \ + -- \ + ${LXD_OPTIONS} + eend ${?} +} + +stop() { + if [ "${RC_CMD}" = restart ]; then + ebegin "Stopping lxd service (but not containers)" + # start-stop-daemon sends SIGTERM with a timeout of 5s by default. + # SIGTERM indicates to LXD that it will be stopped temporarily. + # Instances will keep running. + start-stop-daemon --stop --quiet -p "${PIDFILE}" + eend ${?} + else + ebegin "Stopping lxd service and containers, waiting 40s" + # SIGPWR indicates to LXD that the host is going down. + # LXD will do a clean shutdown of all instances. + # After 30s all remaining instances will be killed. + # We wait up to 40s for LXD. + start-stop-daemon --stop --quiet -R SIGPWR/40 -p "${PIDFILE}" + eend ${?} + fi +} diff --git a/app-emulation/lxd/files/lxd-4.0.0.service b/app-emulation/lxd/files/lxd-4.0.0.service new file mode 100644 index 0000000..c2e9db8 --- /dev/null +++ b/app-emulation/lxd/files/lxd-4.0.0.service @@ -0,0 +1,20 @@ +[Unit] +Description=LXD - main daemon +After=network-online.target lxcfs.service lxd.socket +Requires=network-online.target lxcfs.service lxd.socket +Documentation=man:lxd(1) + +[Service] +EnvironmentFile=-/etc/environment +ExecStart=/usr/sbin/lxd --group lxd --logfile=/var/log/lxd/lxd.log +ExecStartPost=/usr/sbin/lxd waitready --timeout=600 +KillMode=process +TimeoutStartSec=600s +TimeoutStopSec=30s +Restart=on-failure +LimitNOFILE=1048576 +LimitNPROC=infinity +TasksMax=infinity + +[Install] +Also=lxd-containers.service lxd.socket diff --git a/app-emulation/lxd/files/lxd-4.0.0.socket b/app-emulation/lxd/files/lxd-4.0.0.socket new file mode 100644 index 0000000..3207c94 --- /dev/null +++ b/app-emulation/lxd/files/lxd-4.0.0.socket @@ -0,0 +1,12 @@ +[Unit] +Description=LXD - unix socket +Documentation=man:lxd(1) + +[Socket] +ListenStream=/var/lib/lxd/unix.socket +SocketGroup=lxd +SocketMode=0660 +Service=lxd.service + +[Install] +WantedBy=sockets.target diff --git a/app-emulation/lxd/files/lxd-4.0.0_apparmor.service b/app-emulation/lxd/files/lxd-4.0.0_apparmor.service new file mode 100644 index 0000000..5e688d9 --- /dev/null +++ b/app-emulation/lxd/files/lxd-4.0.0_apparmor.service @@ -0,0 +1,21 @@ +[Unit] +Description=LXD - main daemon +After=network-online.target lxcfs.service lxd.socket +Requires=network-online.target lxcfs.service lxd.socket +Documentation=man:lxd(1) + +[Service] +EnvironmentFile=-/etc/environment +ExecStartPre=/usr/libexec/lxc/lxc-apparmor-load +ExecStart=/usr/sbin/lxd --group lxd --logfile=/var/log/lxd/lxd.log +ExecStartPost=/usr/sbin/lxd waitready --timeout=600 +KillMode=process +TimeoutStartSec=600s +TimeoutStopSec=30s +Restart=on-failure +LimitNOFILE=1048576 +LimitNPROC=infinity +TasksMax=infinity + +[Install] +Also=lxd-containers.service lxd.socket diff --git a/app-emulation/lxd/files/lxd-containers-4.0.0.service b/app-emulation/lxd/files/lxd-containers-4.0.0.service new file mode 100644 index 0000000..894760c --- /dev/null +++ b/app-emulation/lxd/files/lxd-containers-4.0.0.service @@ -0,0 +1,16 @@ +[Unit] +Description=LXD - container startup/shutdown +Documentation=man:lxd(1) +After=lxd.socket lxd.service +Requires=lxd.socket + +[Service] +Type=oneshot +ExecStart=/usr/sbin/lxd activateifneeded +ExecStop=/usr/sbin/lxd shutdown +TimeoutStartSec=600s +TimeoutStopSec=600s +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/app-emulation/lxd/lxd-4.17.ebuild b/app-emulation/lxd/lxd-4.17.ebuild new file mode 100644 index 0000000..fae4246 --- /dev/null +++ b/app-emulation/lxd/lxd-4.17.ebuild @@ -0,0 +1,164 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit autotools bash-completion-r1 linux-info optfeature systemd verify-sig + +DESCRIPTION="Fast, dense and secure container management" +HOMEPAGE="https://linuxcontainers.org/lxd/introduction/ https://github.com/lxc/lxd" +SRC_URI="https://linuxcontainers.org/downloads/lxd/${P}.tar.gz + verify-sig? ( https://linuxcontainers.org/downloads/lxd/${P}.tar.gz.asc )" + +SLOT="0/$(ver_cut 1)" +LICENSE="Apache-2.0" +SLOT="1" +KEYWORDS="~amd64" +IUSE="apparmor ipv6 nls verify-sig" + +DEPEND="app-arch/xz-utils + >=app-emulation/lxc-3.0.0[apparmor?,seccomp(+)] + dev-libs/dqlite + dev-libs/lzo + dev-libs/raft[lz4] + >=dev-util/xdelta-3.0[lzma(+)] + net-dns/dnsmasq[dhcp,ipv6?]" +RDEPEND="${DEPEND} + acct-group/lxd + net-firewall/ebtables + net-firewall/iptables[ipv6?] + sys-apps/iproute2[ipv6?] + sys-fs/fuse:* + sys-fs/lxcfs + sys-fs/squashfs-tools[lzma] + virtual/acl" +BDEPEND="dev-lang/go + nls? ( sys-devel/gettext ) + verify-sig? ( app-crypt/openpgp-keys-linuxcontainers )" + +CONFIG_CHECK=" + ~CGROUPS + ~IPC_NS + ~NET_NS + ~PID_NS + + ~SECCOMP + ~USER_NS + ~UTS_NS +" + +ERROR_IPC_NS="CONFIG_IPC_NS is required." +ERROR_NET_NS="CONFIG_NET_NS is required." +ERROR_PID_NS="CONFIG_PID_NS is required." +ERROR_SECCOMP="CONFIG_SECCOMP is required." +ERROR_UTS_NS="CONFIG_UTS_NS is required." + +# Go magic. +QA_PREBUILT="/usr/bin/fuidshift + /usr/bin/lxc + /usr/bin/lxc-to-lxd + /usr/bin/lxd-agent + /usr/bin/lxd-benchmark + /usr/bin/lxd-p2c + /usr/sbin/lxd" + +EGO_PN="github.com/lxc/lxd" +GOPATH="${S}/_dist" # this seems to reset every now and then, though + +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/linuxcontainers.asc + +src_prepare() { + default + + export GOPATH="${S}/_dist" + + sed -i \ + -e "s:\./configure:./configure --prefix=/usr --libdir=${EPREFIX}/usr/lib/lxd:g" \ + -e "s:make:make ${MAKEOPTS}:g" \ + Makefile || die + + # Fix hardcoded ovmf file path, see bug 763180 + sed -i \ + -e "s:/usr/share/OVMF:/usr/share/edk2-ovmf:g" \ + -e "s:OVMF_VARS.ms.fd:OVMF_VARS.secboot.fd:g" \ + doc/environment.md \ + lxd/apparmor/instance_qemu.go \ + lxd/instance/drivers/driver_qemu.go || die "Failed to fix hardcoded ovmf paths." + + # Fix hardcoded virtfs-proxy-helper file path, see bug 798924 + sed -i \ + -e "s:/usr/lib/qemu/virtfs-proxy-helper:/usr/libexec/virtfs-proxy-helper:g" \ + lxd/device/disk.go || die "Failed to fix virtfs-proxy-helper path." +} + +src_configure() { :; } + +src_compile() { + export GOPATH="${S}/_dist" + export GO111MODULE=auto + export CGO_LDFLAGS_ALLOW="-Wl,-z,now" + + cd "${S}" || die + + for k in fuidshift lxd-benchmark lxc lxc-to-lxd; do + go install -v -x "${EGO_PN}/${k}" || die "failed compiling ${k}" + done + + go install -v -x -tags libsqlite3 ${EGO_PN}/lxd || die "Failed to build the daemon" + + # Needs to be built statically + CGO_ENABLED=0 go install -v -tags netgo "${EGO_PN}"/lxd-p2c + CGO_ENABLED=0 go install -v -tags agent,netgo "${EGO_PN}"/lxd-agent + + use nls && emake build-mo +} + +src_test() { + export GOPATH="${S}/_dist" + export GO111MODULE=off + go test -v ${EGO_PN}/lxd || die +} + +src_install() { + local bindir="_dist/bin" + export GOPATH="${S}/_dist" + + dosbin ${bindir}/lxd + + for l in fuidshift lxd-agent lxd-benchmark lxd-p2c lxc lxc-to-lxd; do + dobin ${bindir}/${l} + done + + cd "${S}" || die + + newbashcomp scripts/bash/lxd-client lxc + + newconfd "${FILESDIR}"/lxd-4.0.0.confd lxd + newinitd "${FILESDIR}"/lxd-4.0.0.initd lxd + + if use apparmor; then + systemd_newunit "${FILESDIR}"/lxd-4.0.0_apparmor.service lxd.service + else + systemd_newunit "${FILESDIR}"/lxd-4.0.0.service lxd.service + fi + + systemd_newunit "${FILESDIR}"/lxd-containers-4.0.0.service lxd-containers.service + systemd_newunit "${FILESDIR}"/lxd-4.0.0.socket lxd.socket + + dodoc AUTHORS doc/* + use nls && domo po/*.mo +} + +pkg_postinst() { + elog + elog "Consult https://wiki.gentoo.org/wiki/LXD for more information," + elog "including a Quick Start." + elog + elog "Please run 'lxc-checkconfig' to see all optional kernel features." + elog + optfeature "btrfs storage backend" sys-fs/btrfs-progs + optfeature "lvm2 storage backend" sys-fs/lvm2 + optfeature "zfs storage backend" sys-fs/zfs + elog + elog "Be sure to add your local user to the lxd group." +} diff --git a/app-emulation/lxd/metadata.xml b/app-emulation/lxd/metadata.xml new file mode 100644 index 0000000..0891ba1 --- /dev/null +++ b/app-emulation/lxd/metadata.xml @@ -0,0 +1,20 @@ + + + + + canutethegreat@gmail.com + Ronald Farrer + + + Enable AppArmor support + + + By combining the speed and density of containers with + the security of traditional virtual machines, LXD is + the next-generation of container hypervisor for Linux + from Canonical. + + + lxc/lxd + +