Gentoo Archives: gentoo-commits

From: Joonas Niilola <juippis@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-containers/lxd/files/, app-containers/lxd/
Date: Wed, 02 Feb 2022 08:53:18
Message-Id: 1643791986.5bd04ef5dc1514fe99e65550f7e72bcf7ab993eb.juippis@gentoo
1 commit: 5bd04ef5dc1514fe99e65550f7e72bcf7ab993eb
2 Author: Joonas Niilola <juippis <AT> gentoo <DOT> org>
3 AuthorDate: Wed Feb 2 08:45:41 2022 +0000
4 Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org>
5 CommitDate: Wed Feb 2 08:53:06 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5bd04ef5
7
8 app-containers/lxd: add 4.0.9
9
10 - inherit go-module.eclass; upstream uses go.mod now,
11 - new documentation offered by upstream, e.g. a handy cheatsheet,
12 - openrc init file and systemd service file now manages the log
13 directory (#817287),
14 - virtfs-proxy-helper bin path isn't hardcoded anymore (#798924),
15 - -Werror patch turned into sed for easier maintainability.
16
17 Bug: https://bugs.gentoo.org/798924
18 Closes: https://bugs.gentoo.org/817287
19 Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>
20
21 app-containers/lxd/Manifest | 2 +
22 app-containers/lxd/files/lxd-4.0.9.initd | 49 ++++++++
23 app-containers/lxd/files/lxd-4.0.9.service | 25 +++++
24 app-containers/lxd/lxd-4.0.9.ebuild | 174 +++++++++++++++++++++++++++++
25 4 files changed, 250 insertions(+)
26
27 diff --git a/app-containers/lxd/Manifest b/app-containers/lxd/Manifest
28 index 5aa9fa7a435c..97017785ab20 100644
29 --- a/app-containers/lxd/Manifest
30 +++ b/app-containers/lxd/Manifest
31 @@ -1,2 +1,4 @@
32 DIST lxd-4.0.8.tar.gz 8898153 BLAKE2B c02bea1019079f59fff5fbb2c3d3ebf13e01751fd1c18b9aa44a9306a8f631cb0c0a55f77eb17945e44c040dfdad5c790bb2c2e3ab165356e3900c3d6cccec0e SHA512 9bf5ee91438bc14e916410254979838a110d21d8329c0eaa0a5eecfd378039a3ac10291197d2f680dc12484866f21ef724618e88e6c02038e6d2484d33571dd6
33 DIST lxd-4.0.8.tar.gz.asc 833 BLAKE2B 2073b113f34b2ab052e6e4f406016ac04631ec63269b79dd1e85ca5191aa73ed1f47f0e87f5155b6e5c6659138a182c4c403a66e20925cdb347f49e542e8139b SHA512 9b5f00f9d4a601e718ca91f623dd31e864963b7b8a9e9be6af8da2288b775c4fc8c60b0d6fcefa2a347d733d1e002a3714ac3dbfadf9a1188f9747e9682fe8b9
34 +DIST lxd-4.0.9.tar.gz 9117078 BLAKE2B aa6689c1e958258484fba5c060765dd71d5406cb4375d3132cdc38633277e6c95322e8e3aed5e9dd251140c6868ec42470e797639dde4af42848e138f3b45ee2 SHA512 657949311753895f3941deaabae2d03092fc67490d2de78db48b296fdd3e9df4c5844467dd6913814426ca423a6ee1da9705bb1a2652ea99fe1356eb7da97ebb
35 +DIST lxd-4.0.9.tar.gz.asc 833 BLAKE2B 7cd0d3ab518d947ca3ea6dc804c6a59b592e4e568152c078fdd3c102420bcd94d2f0b2c335b8b4ecdb19dc3c9a10f665a1510903f395247da956717beaa172a3 SHA512 79a4111571ab43e79cf669e416ed50f3ccae0fbceb86d73757d23c778035e827f47643bc87ff6a2fc64b095345a3d53cbd0c4eb245c75364e907d7449f3a0886
36
37 diff --git a/app-containers/lxd/files/lxd-4.0.9.initd b/app-containers/lxd/files/lxd-4.0.9.initd
38 new file mode 100644
39 index 000000000000..7b3d464ea367
40 --- /dev/null
41 +++ b/app-containers/lxd/files/lxd-4.0.9.initd
42 @@ -0,0 +1,49 @@
43 +#!/sbin/openrc-run
44 +# Copyright 1999-2022 Gentoo Authors
45 +# Distributed under the terms of the GNU General Public License v2
46 +
47 +DAEMON=/usr/sbin/lxd
48 +PIDFILE=/run/lxd.pid
49 +
50 +depend() {
51 + need net
52 + need lxcfs
53 +}
54 +
55 +start() {
56 + ebegin "Starting lxd service"
57 +
58 + modprobe -f loop > /dev/null 2>&1
59 +
60 + # Fix permissions on /var/lib/lxd and make sure it exists.
61 + # Create a log directory for lxd with correct permissions.
62 + install -d /var/lib/lxd --group lxd --owner root --mode 0775
63 + install -d /var/log/lxd --group lxd --owner root
64 + start-stop-daemon --start \
65 + --pidfile ${PIDFILE} \
66 + --exec ${DAEMON} \
67 + --background \
68 + --make-pidfile \
69 + -- \
70 + ${LXD_OPTIONS}
71 + eend ${?}
72 +}
73 +
74 +stop() {
75 + if [ "${RC_CMD}" = restart ]; then
76 + ebegin "Stopping lxd service (but not containers)"
77 + # start-stop-daemon sends SIGTERM with a timeout of 5s by default.
78 + # SIGTERM indicates to LXD that it will be stopped temporarily.
79 + # Instances will keep running.
80 + start-stop-daemon --stop --quiet -p "${PIDFILE}"
81 + eend ${?}
82 + else
83 + ebegin "Stopping lxd service and containers, waiting 40s"
84 + # SIGPWR indicates to LXD that the host is going down.
85 + # LXD will do a clean shutdown of all instances.
86 + # After 30s all remaining instances will be killed.
87 + # We wait up to 40s for LXD.
88 + start-stop-daemon --stop --quiet -R SIGPWR/40 -p "${PIDFILE}"
89 + eend ${?}
90 + fi
91 +}
92
93 diff --git a/app-containers/lxd/files/lxd-4.0.9.service b/app-containers/lxd/files/lxd-4.0.9.service
94 new file mode 100644
95 index 000000000000..6a218d2c43a7
96 --- /dev/null
97 +++ b/app-containers/lxd/files/lxd-4.0.9.service
98 @@ -0,0 +1,25 @@
99 +[Unit]
100 +Description=LXD - main daemon
101 +After=network-online.target lxcfs.service lxd.socket
102 +Requires=network-online.target lxcfs.service lxd.socket
103 +Documentation=man:lxd(1)
104 +
105 +[Service]
106 +Group=lxd
107 +User=root
108 +EnvironmentFile=-/etc/environment
109 +ExecStart=/usr/sbin/lxd --group lxd --syslog
110 +ExecStartPost=/usr/sbin/lxd waitready --timeout=600
111 +ExecStartPre=/bin/mkdir -p /var/log/lxd
112 +ExecStartPre=/bin/chown -R root:lxd /var/log/lxd
113 +KillMode=process
114 +PermissionsStartOnly=true
115 +TimeoutStartSec=600s
116 +TimeoutStopSec=30s
117 +Restart=on-failure
118 +LimitNOFILE=1048576
119 +LimitNPROC=infinity
120 +TasksMax=infinity
121 +
122 +[Install]
123 +Also=lxd-containers.service lxd.socket
124
125 diff --git a/app-containers/lxd/lxd-4.0.9.ebuild b/app-containers/lxd/lxd-4.0.9.ebuild
126 new file mode 100644
127 index 000000000000..5e1fcec33945
128 --- /dev/null
129 +++ b/app-containers/lxd/lxd-4.0.9.ebuild
130 @@ -0,0 +1,174 @@
131 +# Copyright 1999-2022 Gentoo Authors
132 +# Distributed under the terms of the GNU General Public License v2
133 +
134 +EAPI=7
135 +
136 +inherit bash-completion-r1 go-module linux-info optfeature systemd verify-sig
137 +
138 +DESCRIPTION="Fast, dense and secure container management"
139 +HOMEPAGE="https://linuxcontainers.org/lxd/introduction/ https://github.com/lxc/lxd"
140 +SRC_URI="https://linuxcontainers.org/downloads/lxd/${P}.tar.gz
141 + verify-sig? ( https://linuxcontainers.org/downloads/lxd/${P}.tar.gz.asc )"
142 +
143 +LICENSE="Apache-2.0"
144 +SLOT="0"
145 +KEYWORDS="~amd64 ~x86"
146 +IUSE="apparmor ipv6 nls verify-sig"
147 +
148 +DEPEND="acct-group/lxd
149 + app-arch/xz-utils
150 + >=app-containers/lxc-3.0.0[apparmor?,seccomp(+)]
151 + dev-db/sqlite:3
152 + dev-libs/dqlite
153 + dev-libs/lzo
154 + dev-libs/raft[lz4]
155 + >=dev-util/xdelta-3.0[lzma(+)]
156 + net-dns/dnsmasq[dhcp,ipv6?]
157 + sys-libs/libcap
158 + virtual/udev"
159 +RDEPEND="${DEPEND}
160 + net-firewall/ebtables
161 + net-firewall/iptables[ipv6?]
162 + sys-apps/iproute2[ipv6?]
163 + sys-fs/fuse:*
164 + sys-fs/lxcfs
165 + sys-fs/squashfs-tools[lzma]
166 + virtual/acl"
167 +BDEPEND="dev-lang/go
168 + nls? ( sys-devel/gettext )
169 + verify-sig? ( sec-keys/openpgp-keys-linuxcontainers )"
170 +
171 +CONFIG_CHECK="
172 + ~CGROUPS
173 + ~IPC_NS
174 + ~NET_NS
175 + ~PID_NS
176 +
177 + ~SECCOMP
178 + ~USER_NS
179 + ~UTS_NS
180 +
181 + ~KVM
182 + ~MACVTAP
183 + ~VHOST_VSOCK
184 +"
185 +
186 +ERROR_IPC_NS="CONFIG_IPC_NS is required."
187 +ERROR_NET_NS="CONFIG_NET_NS is required."
188 +ERROR_PID_NS="CONFIG_PID_NS is required."
189 +ERROR_SECCOMP="CONFIG_SECCOMP is required."
190 +ERROR_UTS_NS="CONFIG_UTS_NS is required."
191 +
192 +WARNING_KVM="CONFIG_KVM and CONFIG_KVM_AMD/-INTEL is required for virtual machines."
193 +WARNING_MACVTAP="CONFIG_MACVTAP is required for virtual machines."
194 +WARNING_VHOST_VSOCK="CONFIG_VHOST_VSOCK is required for virtual machines."
195 +
196 +# Go magic.
197 +QA_PREBUILT="/usr/bin/fuidshift
198 + /usr/bin/lxc
199 + /usr/bin/lxc-to-lxd
200 + /usr/bin/lxd-agent
201 + /usr/bin/lxd-benchmark
202 + /usr/bin/lxd-p2c
203 + /usr/sbin/lxd"
204 +
205 +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/linuxcontainers.asc
206 +
207 +# The testsuite must be run as root.
208 +# make: *** [Makefile:156: check] Error 1
209 +RESTRICT="test"
210 +
211 +GOPATH="${S}/_dist"
212 +
213 +src_prepare() {
214 + export GOPATH="${S}/_dist"
215 +
216 + default
217 +
218 + sed -i \
219 + -e "s:\./configure:./configure --prefix=/usr --libdir=${EPREFIX}/usr/lib/lxd:g" \
220 + -e "s:make:make ${MAKEOPTS}:g" \
221 + Makefile || die
222 +
223 + # Fix hardcoded ovmf file path, see bug 763180
224 + sed -i \
225 + -e "s:/usr/share/OVMF:/usr/share/edk2-ovmf:g" \
226 + -e "s:OVMF_VARS.ms.fd:OVMF_VARS.secboot.fd:g" \
227 + doc/environment.md \
228 + lxd/apparmor/instance.go \
229 + lxd/apparmor/instance_qemu.go \
230 + lxd/instance/drivers/driver_qemu.go || die "Failed to fix hardcoded ovmf paths."
231 +
232 + cp "${FILESDIR}"/lxd-4.0.9.service "${T}"/lxd.service || die
233 + if use apparmor; then
234 + sed -i \
235 + '/^EnvironmentFile=.*/a ExecStartPre=\/usr\/libexec\/lxc\/lxc-apparmor-load' \
236 + "${T}"/lxd.service || die
237 + fi
238 +
239 + # Disable -Werror's from go modules.
240 + find "${S}" -name "cgo.go" -exec sed -i "s/ -Werror / /g" {} + || die
241 +}
242 +
243 +src_configure() { :; }
244 +
245 +src_compile() {
246 + export GOPATH="${S}/_dist"
247 + export CGO_LDFLAGS_ALLOW="-Wl,-z,now"
248 +
249 + for k in fuidshift lxd-benchmark lxc lxc-to-lxd; do
250 + go install -v -x "${S}/${k}" || die "failed compiling ${k}"
251 + done
252 +
253 + go install -v -x -tags libsqlite3 ${S}/lxd || die "Failed to build the daemon"
254 +
255 + # Needs to be built statically
256 + CGO_ENABLED=0 go install -v -tags netgo "${S}"/lxd-p2c
257 + CGO_ENABLED=0 go install -v -tags agent,netgo "${S}"/lxd-agent
258 +
259 + use nls && emake build-mo
260 +}
261 +
262 +src_test() {
263 + emake check
264 +}
265 +
266 +src_install() {
267 + export GOPATH="${S}/_dist"
268 + local bindir="_dist/bin"
269 +
270 + dosbin ${bindir}/lxd
271 +
272 + for l in fuidshift lxd-agent lxd-benchmark lxd-p2c lxc lxc-to-lxd; do
273 + dobin ${bindir}/${l}
274 + done
275 +
276 + newbashcomp scripts/bash/lxd-client lxc
277 +
278 + newconfd "${FILESDIR}"/lxd-4.0.0.confd lxd
279 + newinitd "${FILESDIR}"/lxd-4.0.9.initd lxd
280 +
281 + systemd_dounit "${T}"/lxd.service
282 + systemd_newunit "${FILESDIR}"/lxd-containers-4.0.0.service lxd-containers.service
283 + systemd_newunit "${FILESDIR}"/lxd-4.0.0.socket lxd.socket
284 +
285 + dodoc AUTHORS doc/*
286 + use nls && domo po/*.mo
287 +}
288 +
289 +pkg_postinst() {
290 + elog
291 + elog "Consult https://wiki.gentoo.org/wiki/LXD for more information,"
292 + elog "including a Quick Start."
293 + elog "For virtual machine support, see:"
294 + elog "https://wiki.gentoo.org/wiki/LXD#Virtual_machines"
295 + elog
296 + elog "Please run 'lxc-checkconfig' to see all optional kernel features."
297 + elog
298 + optfeature "virtual machine support" app-emulation/qemu[spice,usbredir,virtfs]
299 + optfeature "btrfs storage backend" sys-fs/btrfs-progs
300 + optfeature "lvm2 storage backend" sys-fs/lvm2
301 + optfeature "zfs storage backend" sys-fs/zfs
302 + elog
303 + elog "Be sure to add your local user to the lxd group."
304 +}