Skip to contentSkip to conversation

libvirt: fix do_install with usrmerge

PATCH In review Martin Jansa 2 participants 2 messages May 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libvirt: fix do_install with usrmerge

* meson build uses these paths:
./src/meson.build: systemd_unit_dir = prefix / 'lib' / 'systemd' / 'system'
./tools/meson.build: install_dir: prefix / 'lib' / 'systemd' / 'system',

with usrmerge it fails with:
sed: can't read TOPDIR/tmp-glibc/work/core2-64-oe-linux/libvirt/7.2.0-r0/image//usr/lib/systemd/system/libvirtd.service: No such file or directory because systemd_unitdir and systemd_system_unitdir are different
with and without usrmerge in DISTRO_FEATURES:

env.libvirt-without-usrmerge:export systemd_unitdir="/lib/systemd" env.libvirt-with-usrmerge:export systemd_unitdir="/usr/lib/systemd"

env.libvirt-without-usrmerge:export systemd_system_unitdir="/lib/systemd/system" env.libvirt-with-usrmerge:export systemd_system_unitdir="/usr/lib/systemd/system"

* set -Dinit_script to none when systemd isn't used instead of deleting the files in do_install_append

---
 recipes-extended/libvirt/libvirt_7.2.0.bb | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
recipes-extended/libvirt/libvirt_7.2.0.bb +11 -7
index b569953..19662a7 100644
@@ -65,7 +65,7 @@ FILES_${PN}-libvirtd = " \
 	${sysconfdir}/libvirt/libvirtd.conf \
         /usr/lib/sysctl.d/60-libvirtd.conf \
 	${sbindir}/libvirtd \
-	${systemd_unitdir}/system/* \
+	${systemd_system_unitdir} \
 	${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '', '${libexecdir}/libvirt-guests.sh', d)} \
 	${@bb.utils.contains('PACKAGECONFIG', 'gnutls', '${sysconfdir}/pki/libvirt/* ${sysconfdir}/pki/CA/*', '', d)} \
         "
@@ -199,17 +199,21 @@ do_install_append() {
 	fi
 
 	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
-            mkdir -p ${D}/lib
-            mv ${D}/usr/lib/systemd ${D}/lib
+            if [ "${systemd_system_unitdir}" != "${prefix}/lib/systemd/system" ] ; then
+                # ./src/meson.build:    systemd_unit_dir = prefix / 'lib' / 'systemd' / 'system'
+                # ./tools/meson.build:    install_dir: prefix / 'lib' / 'systemd' / 'system',
+                mkdir -p ${D}${systemd_system_unitdir}
+                mv ${D}${prefix}/lib/systemd/system/* ${D}${systemd_system_unitdir}
+                rmdir ${D}${prefix}/lib/systemd/system ${D}${prefix}/lib/systemd
+            fi
+
 	    # This variable is used by libvirtd.service to start libvirtd in the right mode
 	    sed -i '/#LIBVIRTD_ARGS="--listen"/a LIBVIRTD_ARGS="--listen --daemon"' ${D}/${sysconfdir}/sysconfig/libvirtd
 
 	    # We can't use 'notify' when we don't support 'sd_notify' dbus capabilities.
 	    sed -i -e 's/Type=notify/Type=forking/' \
 	           -e '/Type=forking/a PIDFile=/run/libvirtd.pid' \
-		   ${D}/${systemd_unitdir}/system/libvirtd.service
-	else
-	    rm -rf ${D}/usr/lib/systemd
+		   ${D}/${systemd_system_unitdir}/libvirtd.service
 	fi
 
 	# The /run/libvirt directories created by the Makefile are 
@@ -302,7 +306,7 @@ do_install_append() {
 }
 
 EXTRA_OEMESON += " \
-    -Dinit_script=systemd \
+    -Dinit_script=${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd','none', d)} \
     -Drunstatedir=/run \
     -Dtests=enabled \
     "
Signature · 1 line
2.30.2
#1 lore raw
Quoted 10 lines · Martin Jansa

* meson build uses these paths:
./src/meson.build: systemd_unit_dir = prefix / 'lib' / 'systemd' / 'system'
./tools/meson.build: install_dir: prefix / 'lib' / 'systemd' / 'system',

with usrmerge it fails with:
sed: can't read TOPDIR/tmp-glibc/work/core2-64-oe-linux/libvirt/7.2.0-r0/image//usr/lib/systemd/system/libvirtd.service: No such file or directory because systemd_unitdir and systemd_system_unitdir are different
with and without usrmerge in DISTRO_FEATURES:

Quoted 6 lines

env.libvirt-without-usrmerge:export systemd_unitdir="/lib/systemd" env.libvirt-with-usrmerge:export systemd_unitdir="/usr/lib/systemd"

env.libvirt-without-usrmerge:export systemd_system_unitdir="/lib/systemd/system" env.libvirt-with-usrmerge:export systemd_system_unitdir="/usr/lib/systemd/system"

Thanks for the fixups,

I need to get CI to include usrmerge so I can pick these up faster (I just added it to the ever growing TODO).

I've queued this and will fire off my own non-usrmerge tests and push once it passes.

Bruce

Quoted 63 lines

* set -Dinit_script to none when systemd isn't used instead of deleting the files in do_install_append

---
 recipes-extended/libvirt/libvirt_7.2.0.bb | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
recipes-extended/libvirt/libvirt_7.2.0.bb +11 -8
index b569953..19662a7 100644
@@ -65,7 +65,7 @@ FILES_${PN}-libvirtd = " \
        ${sysconfdir}/libvirt/libvirtd.conf \
         /usr/lib/sysctl.d/60-libvirtd.conf \
        ${sbindir}/libvirtd \
-       ${systemd_unitdir}/system/* \
+       ${systemd_system_unitdir} \
        ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '', '${libexecdir}/libvirt-guests.sh', d)} \
        ${@bb.utils.contains('PACKAGECONFIG', 'gnutls', '${sysconfdir}/pki/libvirt/* ${sysconfdir}/pki/CA/*', '', d)} \
         "
@@ -199,17 +199,21 @@ do_install_append() {
        fi
 
        if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
-            mkdir -p ${D}/lib
-            mv ${D}/usr/lib/systemd ${D}/lib
+            if [ "${systemd_system_unitdir}" != "${prefix}/lib/systemd/system" ] ; then
+                # ./src/meson.build:    systemd_unit_dir = prefix / 'lib' / 'systemd' / 'system'
+                # ./tools/meson.build:    install_dir: prefix / 'lib' / 'systemd' / 'system',
+                mkdir -p ${D}${systemd_system_unitdir}
+                mv ${D}${prefix}/lib/systemd/system/* ${D}${systemd_system_unitdir}
+                rmdir ${D}${prefix}/lib/systemd/system ${D}${prefix}/lib/systemd
+            fi
+
            # This variable is used by libvirtd.service to start libvirtd in the right mode
            sed -i '/#LIBVIRTD_ARGS="--listen"/a LIBVIRTD_ARGS="--listen --daemon"' ${D}/${sysconfdir}/sysconfig/libvirtd
 
            # We can't use 'notify' when we don't support 'sd_notify' dbus capabilities.
            sed -i -e 's/Type=notify/Type=forking/' \
                   -e '/Type=forking/a PIDFile=/run/libvirtd.pid' \
-                  ${D}/${systemd_unitdir}/system/libvirtd.service
-       else
-           rm -rf ${D}/usr/lib/systemd
+                  ${D}/${systemd_system_unitdir}/libvirtd.service
        fi
 
        # The /run/libvirt directories created by the Makefile are
@@ -302,7 +306,7 @@ do_install_append() {
 }
 
 EXTRA_OEMESON += " \
-    -Dinit_script=systemd \
+    -Dinit_script=${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd','none', d)} \
     -Drunstatedir=/run \
     -Dtests=enabled \
     "
--

2.30.2

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II