diff options
Diffstat (limited to 'recipes-extended/libvirt/libvirt_git.bb')
-rw-r--r-- | recipes-extended/libvirt/libvirt_git.bb | 337 |
1 files changed, 337 insertions, 0 deletions
diff --git a/recipes-extended/libvirt/libvirt_git.bb b/recipes-extended/libvirt/libvirt_git.bb new file mode 100644 index 00000000..7ed708f5 --- /dev/null +++ b/recipes-extended/libvirt/libvirt_git.bb | |||
@@ -0,0 +1,337 @@ | |||
1 | DESCRIPTION = "A toolkit to interact with the virtualization capabilities of recent versions of Linux." | ||
2 | HOMEPAGE = "http://libvirt.org" | ||
3 | LICENSE = "LGPL-2.1-or-later & GPL-2.0-or-later" | ||
4 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ | ||
5 | file://COPYING.LESSER;md5=4b54a1fd55a448865a0b32d41598759d" | ||
6 | SECTION = "console/tools" | ||
7 | |||
8 | DEPENDS = "bridge-utils gnutls libxml2 lvm2 avahi parted curl libpcap util-linux e2fsprogs pm-utils \ | ||
9 | iptables dnsmasq readline libtasn1 libxslt-native acl libdevmapper libtirpc \ | ||
10 | python3-docutils-native \ | ||
11 | ${@bb.utils.contains('PACKAGECONFIG', 'polkit', 'shadow-native', '', d)} \ | ||
12 | ${@bb.utils.contains('PACKAGECONFIG', 'gnutls', 'gnutls-native', '', d)}" | ||
13 | |||
14 | # libvirt-guests.sh needs gettext.sh | ||
15 | # | ||
16 | RDEPENDS:${PN} = "gettext-runtime" | ||
17 | |||
18 | RDEPENDS:libvirt-libvirtd += "bridge-utils iptables pm-utils dnsmasq netcat-openbsd ebtables" | ||
19 | RDEPENDS:libvirt-libvirtd:append:x86-64 = " dmidecode" | ||
20 | RDEPENDS:libvirt-libvirtd:append:x86 = " dmidecode" | ||
21 | RDEPENDS:libvirt-libvirtd:append:arm = " dmidecode" | ||
22 | RDEPENDS:libvirt-libvirtd:append:aarch64 = " dmidecode" | ||
23 | |||
24 | #connman blocks the 53 port and libvirtd can't start its DNS service | ||
25 | RCONFLICTS:${PN}_libvirtd = "connman" | ||
26 | |||
27 | SRCREV_libvirt = "9cd06737487c8ee311f71b7288c46a5cc70a700a" | ||
28 | |||
29 | LIBVIRT_VERSION = "11.1.0" | ||
30 | PV = "v${LIBVIRT_VERSION}+git" | ||
31 | |||
32 | SRC_URI = "gitsm://github.com/libvirt/libvirt.git;name=libvirt;protocol=https;branch=master \ | ||
33 | file://libvirtd.sh \ | ||
34 | file://libvirtd.conf \ | ||
35 | file://dnsmasq.conf \ | ||
36 | file://hook_support.py \ | ||
37 | file://gnutls-helper.py;subdir=${BP} \ | ||
38 | file://libvirt-qemu.conf \ | ||
39 | file://0001-prevent-gendispatch.pl-generating-build-path-in-code.patch \ | ||
40 | file://0001-messon.build-remove-build-path-information-to-avoid-.patch \ | ||
41 | file://0001-meson.build-clear-abs_top_builddir-to-avoid-QA-warni.patch \ | ||
42 | file://0001-tests-meson-clear-absolute-directory-paths.patch \ | ||
43 | file://0001-qemu_nbdkit.c-use-llu-to-print-time_t.patch \ | ||
44 | " | ||
45 | |||
46 | S = "${WORKDIR}/git" | ||
47 | |||
48 | inherit meson gettext update-rc.d pkgconfig systemd useradd perlnative | ||
49 | USERADD_PACKAGES = "${PN}" | ||
50 | GROUPADD_PARAM:${PN} = "-r qemu; -r kvm; -r libvirt; -r virtlogin" | ||
51 | USERADD_PARAM:${PN} = "-r -g qemu -G kvm qemu" | ||
52 | |||
53 | CFLAGS += "${@oe.utils.vartrue('DEBUG_BUILD', '-Wno-error=inline', '', d)}" | ||
54 | |||
55 | EXTRA_OEMESON += "--cross-file ${WORKDIR}/meson-${PN}.cross" | ||
56 | do_write_config:append() { | ||
57 | cat >${WORKDIR}/meson-${PN}.cross <<EOF | ||
58 | [binaries] | ||
59 | iptables = '/usr/sbin/iptables' | ||
60 | ip6tables = '/usr/sbin/ip6tables' | ||
61 | dmidecode = '/usr/sbin/dmidecode' | ||
62 | ebtables = '/sbin/ebtables' | ||
63 | dnsmasq = '/usr/bin/dnsmasq' | ||
64 | EOF | ||
65 | } | ||
66 | |||
67 | ALLOW_EMPTY:${PN} = "1" | ||
68 | INSANE_SKIP:${PN} += "empty-dirs" | ||
69 | |||
70 | PACKAGES =+ "${PN}-libvirtd ${PN}-virsh" | ||
71 | |||
72 | ALLOW_EMPTY:${PN}-libvirtd = "1" | ||
73 | |||
74 | FILES:${PN}-libvirtd = " \ | ||
75 | ${sysconfdir}/init.d \ | ||
76 | ${sysconfdir}/sysctl.d \ | ||
77 | ${sysconfdir}/logrotate.d \ | ||
78 | ${sysconfdir}/libvirt/libvirtd.conf \ | ||
79 | /usr/lib/sysctl.d/60-libvirtd.conf \ | ||
80 | /usr/lib/sysctl.d/60-qemu-postcopy-migration.conf \ | ||
81 | ${sbindir}/libvirtd \ | ||
82 | ${systemd_system_unitdir} \ | ||
83 | ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '', '${libexecdir}/libvirt-guests.sh', d)} \ | ||
84 | ${@bb.utils.contains('PACKAGECONFIG', 'gnutls', '${sysconfdir}/pki/libvirt/* ${sysconfdir}/pki/CA/*', '', d)} \ | ||
85 | " | ||
86 | |||
87 | FILES:${PN}-virsh = " \ | ||
88 | ${bindir}/virsh \ | ||
89 | ${datadir}/bash-completion/completions/virsh \ | ||
90 | " | ||
91 | RDEPENDS:${PN}-virsh = "${PN}-libvirtd" | ||
92 | |||
93 | FILES:${PN} += "${libdir}/libvirt/connection-driver \ | ||
94 | ${datadir}/augeas \ | ||
95 | ${@bb.utils.contains('PACKAGECONFIG', 'polkit', '${datadir}/polkit-1', '', d)} \ | ||
96 | ${datadir}/bash-completion/completions/vsh \ | ||
97 | ${datadir}/bash-completion/completions/virt-admin \ | ||
98 | /usr/lib/firewalld/ \ | ||
99 | ${nonarch_libdir}/sysusers.d/ \ | ||
100 | " | ||
101 | |||
102 | FILES:${PN}-dbg += "${libdir}/libvirt/connection-driver/.debug ${libdir}/libvirt/lock-driver/.debug" | ||
103 | FILES:${PN}-staticdev += "${libdir}/*.a ${libdir}/libvirt/connection-driver/*.a ${libdir}/libvirt/lock-driver/*.a" | ||
104 | |||
105 | CONFFILES:${PN} += "${sysconfdir}/libvirt/libvirt.conf \ | ||
106 | ${sysconfdir}/libvirt/lxc.conf \ | ||
107 | ${sysconfdir}/libvirt/qemu-lockd.conf \ | ||
108 | ${sysconfdir}/libvirt/qemu.conf \ | ||
109 | ${sysconfdir}/libvirt/virt-login-shell.conf \ | ||
110 | ${sysconfdir}/libvirt/virtlockd.conf" | ||
111 | |||
112 | CONFFILES:${PN}-libvirtd = "${sysconfdir}/logrotate.d/libvirt ${sysconfdir}/logrotate.d/libvirt.lxc \ | ||
113 | ${sysconfdir}/logrotate.d/libvirt.qemu ${sysconfdir}/logrotate.d/libvirt.uml \ | ||
114 | ${sysconfdir}/libvirt/libvirtd.conf \ | ||
115 | /usr/lib/sysctl.d/libvirtd.conf" | ||
116 | |||
117 | INITSCRIPT_PACKAGES = "${PN}-libvirtd" | ||
118 | INITSCRIPT_NAME:${PN}-libvirtd = "libvirtd" | ||
119 | INITSCRIPT_PARAMS:${PN}-libvirtd = "defaults 72" | ||
120 | |||
121 | SYSTEMD_PACKAGES = "${PN}-libvirtd" | ||
122 | SYSTEMD_SERVICE:${PN}-libvirtd = " \ | ||
123 | libvirtd.service \ | ||
124 | virtlockd.service \ | ||
125 | libvirt-guests.service \ | ||
126 | virtlockd.socket \ | ||
127 | " | ||
128 | |||
129 | # xen-minimal config | ||
130 | #PACKAGECONFIG ??= "xen libxl xen-inotify test remote libvirtd" | ||
131 | |||
132 | # full config | ||
133 | PACKAGECONFIG ??= "gnutls qemu openvz vmware vbox esx lxc test remote \ | ||
134 | libvirtd netcf udev python fuse firewalld libpcap \ | ||
135 | ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux audit libcap-ng', '', d)} \ | ||
136 | ${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'libxl', '', d)} \ | ||
137 | ${@bb.utils.contains('DISTRO_FEATURES', 'polkit', 'polkit', '', d)} \ | ||
138 | " | ||
139 | |||
140 | # qemu is NOT compatible with mips64, powerpc and riscv32 | ||
141 | PACKAGECONFIG:remove:mipsarchn32 = "qemu" | ||
142 | PACKAGECONFIG:remove:mipsarchn64 = "qemu" | ||
143 | PACKAGECONFIG:remove:powerpc = "qemu" | ||
144 | PACKAGECONFIG:remove:riscv32 = "qemu" | ||
145 | |||
146 | # numactl is NOT compatible with arm | ||
147 | PACKAGECONFIG:remove:arm = "numactl" | ||
148 | PACKAGECONFIG:remove:armeb = "numactl" | ||
149 | |||
150 | # enable,disable,depends,rdepends | ||
151 | # | ||
152 | PACKAGECONFIG[gnutls] = ",,,gnutls-bin" | ||
153 | PACKAGECONFIG[qemu] = "-Ddriver_qemu=enabled -Dqemu_user=qemu -Dqemu_group=qemu,-Ddriver_qemu=disabled,qemu json-c," | ||
154 | PACKAGECONFIG[libxl] = "-Ddriver_libxl=enabled,-Ddriver_libxl=disabled,xen," | ||
155 | PACKAGECONFIG[openvz] = "-Ddriver_openvz=enabled,-Ddriver_openvz=disabled,," | ||
156 | PACKAGECONFIG[vmware] = "-Ddriver_vmware=enabled,-Ddriver_vmware=disabled,," | ||
157 | PACKAGECONFIG[vbox] = "-Ddriver_vbox=enabled,-Ddriver_vbox=disabled,," | ||
158 | PACKAGECONFIG[esx] = "-Ddriver_esx=enabled,-Ddriver_esx=disabled,," | ||
159 | PACKAGECONFIG[hyperv] = "-Ddriver_hyperv=enabled,-Ddriver_hyperv=disabled,," | ||
160 | PACKAGECONFIG[polkit] = "-Dpolkit=enabled,-Dpolkit=disabled,polkit,polkit" | ||
161 | PACKAGECONFIG[lxc] = "-Ddriver_lxc=enabled,-Ddriver_lxc=disabled,lxc," | ||
162 | PACKAGECONFIG[test] = "-Ddriver_test=enabled,-Ddriver_test=disabled,," | ||
163 | PACKAGECONFIG[remote] = "-Ddriver_remote=enabled,-Ddriver_remote=disabled,," | ||
164 | PACKAGECONFIG[libvirtd] = "-Ddriver_libvirtd=enabled,-Ddriver_libvirtd=disabled,," | ||
165 | PACKAGECONFIG[netcf] = "-Dnetcf=enabled,-Dnetcf=disabled,netcf,netcf" | ||
166 | PACKAGECONFIG[dtrace] = "-Ddtrace=enabled,-Ddtrace=disabled,," | ||
167 | PACKAGECONFIG[udev] = "-Dudev=enabled -Dpciaccess=enabled,-Dudev=disabled,udev libpciaccess," | ||
168 | PACKAGECONFIG[selinux] = "-Dselinux=enabled,-Dselinux=disabled,libselinux," | ||
169 | PACKAGECONFIG[python] = ",,python3," | ||
170 | PACKAGECONFIG[sasl] = "-Dsasl=enabled,-Dsasl=disabled,cyrus-sasl,cyrus-sasl" | ||
171 | PACKAGECONFIG[numactl] = "-Dnumactl=enabled,-Dnumactl=disabled,numactl," | ||
172 | PACKAGECONFIG[fuse] = "-Dfuse=enabled,-Dfuse=disabled,fuse3," | ||
173 | PACKAGECONFIG[audit] = "-Daudit=enabled,-Daudit=disabled,audit," | ||
174 | PACKAGECONFIG[libcap-ng] = "-Dcapng=enabled,-Dcapng=disabled,libcap-ng," | ||
175 | PACKAGECONFIG[wireshark] = "-Dwireshark_dissector=enabled,-Dwireshark_dissector=disabled,wireshark libwsutil," | ||
176 | PACKAGECONFIG[apparmor_profiles] = "-Dapparmor_profiles=enabled, -Dapparmor_profiles=disabled," | ||
177 | PACKAGECONFIG[firewalld] = "-Dfirewalld=enabled, -Dfirewalld=disabled," | ||
178 | PACKAGECONFIG[libpcap] = "-Dlibpcap=enabled, -Dlibpcap=disabled,libpcap,libpcap" | ||
179 | PACKAGECONFIG[numad] = "-Dnumad=enabled, -Dnumad=disabled," | ||
180 | |||
181 | # Enable the Python tool support | ||
182 | require libvirt-python.inc | ||
183 | |||
184 | do_compile() { | ||
185 | cd ${B}/src | ||
186 | # There may be race condition, but without creating these directories | ||
187 | # in the source tree, generation of files fails. | ||
188 | for i in access admin logging esx locking rpc hyperv lxc \ | ||
189 | remote network storage interface nwfilter node_device \ | ||
190 | secret vbox qemu; do | ||
191 | mkdir -p $i; | ||
192 | done | ||
193 | |||
194 | cd ${B} | ||
195 | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${B}/src:" | ||
196 | ninja all | ||
197 | } | ||
198 | |||
199 | do_install:prepend() { | ||
200 | # so the install routines can find the libvirt.pc in the source dir | ||
201 | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${B}/src:" | ||
202 | } | ||
203 | |||
204 | do_install:append() { | ||
205 | install -d ${D}/etc/init.d | ||
206 | install -d ${D}/etc/libvirt | ||
207 | install -d ${D}/etc/dnsmasq.d | ||
208 | install -d ${D}${nonarch_libdir}/sysusers.d/ | ||
209 | |||
210 | install -m 0755 ${UNPACKDIR}/libvirtd.sh ${D}/etc/init.d/libvirtd | ||
211 | install -m 0644 ${UNPACKDIR}/libvirtd.conf ${D}/etc/libvirt/libvirtd.conf | ||
212 | install -m 0644 ${UNPACKDIR}/libvirt-qemu.conf ${D}${nonarch_libdir}/sysusers.d/libvirt-qemu.conf | ||
213 | |||
214 | if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then | ||
215 | # This will wind up in the libvirtd package, but will NOT be invoked by default. | ||
216 | # | ||
217 | mv ${D}/${libexecdir}/libvirt-guests.sh ${D}/${sysconfdir}/init.d | ||
218 | fi | ||
219 | |||
220 | if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then | ||
221 | if [ "${systemd_system_unitdir}" != "${prefix}/lib/systemd/system" ] ; then | ||
222 | # ./src/meson.build: systemd_unit_dir = prefix / 'lib' / 'systemd' / 'system' | ||
223 | # ./tools/meson.build: install_dir: prefix / 'lib' / 'systemd' / 'system', | ||
224 | mkdir -p ${D}${systemd_system_unitdir} | ||
225 | mv ${D}${prefix}/lib/systemd/system/* ${D}${systemd_system_unitdir} | ||
226 | rmdir ${D}${prefix}/lib/systemd/system ${D}${prefix}/lib/systemd | ||
227 | fi | ||
228 | |||
229 | # We can't use 'notify' when we don't support 'sd_notify' dbus capabilities. | ||
230 | # Change default LIBVIRTD_ARGS to start libvirtd in the right mode. | ||
231 | sed -i -e 's/Type=notify/Type=forking/' \ | ||
232 | -e '/Type=forking/a PIDFile=/run/libvirtd.pid' \ | ||
233 | -e 's/\(Environment=LIBVIRTD_ARGS="--timeout 120"\)/#\1\nEnvironment=LIBVIRTD_ARGS="--listen --daemon"/' \ | ||
234 | ${D}/${systemd_system_unitdir}/libvirtd.service | ||
235 | fi | ||
236 | |||
237 | # The /run/libvirt directories created by the Makefile are | ||
238 | # wiped out in volatile, we need to create these at boot. | ||
239 | rm -rf ${D}/run | ||
240 | install -d ${D}${sysconfdir}/default/volatiles | ||
241 | echo "d root root 0755 /run/libvirt none" \ | ||
242 | > ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
243 | echo "d root root 0755 /run/libvirt/lockd none" \ | ||
244 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
245 | echo "d root root 0755 /run/libvirt/lxc none" \ | ||
246 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
247 | echo "d root root 0755 /run/libvirt/network none" \ | ||
248 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
249 | echo "d root root 0755 /run/libvirt/qemu none" \ | ||
250 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
251 | |||
252 | # disable seccomp_sandbox | ||
253 | if [ -e ${D}${sysconfdir}/libvirt/qemu.conf ] ; then | ||
254 | sed -i '/^#seccomp_sandbox = 1/aseccomp_sandbox = 0' \ | ||
255 | ${D}${sysconfdir}/libvirt/qemu.conf | ||
256 | fi | ||
257 | |||
258 | # Add hook support for libvirt | ||
259 | mkdir -p ${D}/etc/libvirt/hooks | ||
260 | for hook in "daemon" "lxc" "network" "qemu" | ||
261 | do | ||
262 | install -m 0755 ${UNPACKDIR}/hook_support.py ${D}/etc/libvirt/hooks/${hook} | ||
263 | done | ||
264 | |||
265 | # Force the main dnsmasq instance to bind only to specified interfaces and | ||
266 | # to not bind to virbr0. Libvirt will run its own instance on this interface. | ||
267 | install -m 644 ${UNPACKDIR}/dnsmasq.conf ${D}/${sysconfdir}/dnsmasq.d/libvirt-daemon | ||
268 | |||
269 | # remove .la references to our working diretory | ||
270 | for i in `find ${D}${libdir} -type f -name *.la`; do | ||
271 | sed -i -e 's#-L${B}/src/.libs##g' $i | ||
272 | done | ||
273 | |||
274 | sed -i -e 's/^\(unix_sock_group\ =\ \).*/\1"kvm"/' ${D}/etc/libvirt/libvirtd.conf | ||
275 | sed -i -e 's/^\(unix_sock_rw_perms\ =\ \).*/\1"0776"/' ${D}/etc/libvirt/libvirtd.conf | ||
276 | |||
277 | case ${MACHINE_ARCH} in | ||
278 | *mips*) | ||
279 | break | ||
280 | ;; | ||
281 | *) | ||
282 | if ${@bb.utils.contains('PACKAGECONFIG', 'qemu', 'true', 'false', d)}; then | ||
283 | chown -R qemu:qemu ${D}/${localstatedir}/lib/libvirt/qemu | ||
284 | echo "d qemu qemu 0755 ${localstatedir}/cache/libvirt/qemu none" \ | ||
285 | >> ${D}${sysconfdir}/default/volatiles/99_libvirt | ||
286 | break | ||
287 | fi | ||
288 | ;; | ||
289 | esac | ||
290 | |||
291 | if ${@bb.utils.contains('PACKAGECONFIG','gnutls','true','false',d)}; then | ||
292 | # Generate sample keys and certificates. | ||
293 | ${UNPACKDIR}/${BP}/gnutls-helper.py -y | ||
294 | |||
295 | # Deploy all sample keys and certificates of CA, server and client | ||
296 | # to target so that libvirtd is able to boot successfully and local | ||
297 | # connection via 127.0.0.1 is available out of box. | ||
298 | install -d ${D}/etc/pki/CA | ||
299 | install -d ${D}/etc/pki/libvirt/private | ||
300 | install -m 0755 ${UNPACKDIR}/${BP}/gnutls-helper.py ${D}/${bindir} | ||
301 | install -m 0644 cakey.pem ${D}/${sysconfdir}/pki/libvirt/private/cakey.pem | ||
302 | install -m 0644 cacert.pem ${D}/${sysconfdir}/pki/CA/cacert.pem | ||
303 | install -m 0644 serverkey.pem ${D}/${sysconfdir}/pki/libvirt/private/serverkey.pem | ||
304 | install -m 0644 servercert.pem ${D}/${sysconfdir}/pki/libvirt/servercert.pem | ||
305 | install -m 0644 clientkey.pem ${D}/${sysconfdir}/pki/libvirt/private/clientkey.pem | ||
306 | install -m 0644 clientcert.pem ${D}/${sysconfdir}/pki/libvirt/clientcert.pem | ||
307 | |||
308 | # Force the connection to be tls. | ||
309 | sed -i -e 's/^\(listen_tls\ =\ .*\)/#\1/' -e 's/^\(listen_tcp\ =\ .*\)/#\1/' ${D}/etc/libvirt/libvirtd.conf | ||
310 | fi | ||
311 | |||
312 | # virt-login-shell needs to run with setuid permission | ||
313 | chmod 4755 ${D}${bindir}/virt-login-shell | ||
314 | } | ||
315 | |||
316 | EXTRA_OEMESON += " \ | ||
317 | -Dinit_script=${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd','none', d)} \ | ||
318 | -Drunstatedir=/run \ | ||
319 | -Dtests=enabled \ | ||
320 | " | ||
321 | |||
322 | # gcc9 end up mis-compiling qemuxml2argvtest.o with Og which then | ||
323 | # crashes on target, so remove -Og and use -O2 as workaround | ||
324 | SELECTED_OPTIMIZATION:remove:virtclass-multilib-lib32:mipsarch = "-Og" | ||
325 | SELECTED_OPTIMIZATION:append:virtclass-multilib-lib32:mipsarch = " -O2" | ||
326 | |||
327 | pkg_postinst:${PN}() { | ||
328 | if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then | ||
329 | /etc/init.d/populate-volatile.sh update | ||
330 | fi | ||
331 | mkdir -m 711 -p $D/data/images | ||
332 | } | ||
333 | |||
334 | python () { | ||
335 | if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): | ||
336 | d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") | ||
337 | } | ||