hybrid systemd/sysvinit
cover hybrid systemd/sysvinit
Hi,
This series allows you to have both sysvinit and systemd in DISTRO_FEATURES. Packages will be built with both init scripts, and some daemons will be linking to libsystemd-daemon so that will be pulled in to sysvinit images.
The init manager used at image construction time is DISTRO_FEATURES_INITMAN (maybe this should be renamed) and that value is also backfilled into DISTRO_FEATURES.
The key change is that systemd.bbclass only recommends systemd, and will check that there's a systemctl binary before calling it - this allows packages built like this to be installed on a systemd-free image.
This is very much a RFC, I've done some basic testing but between illness and having to prepare for a presentation at this conference I've not been able to test it as much as I'd hoped. Review and testing very much appreciated.
Some metrics: adding the systemd feature but still using sysvinit when building the image results in just libsystemd-daemon and the service files being added to the image, with a negliable size increase.
Ross
The following changes since commit 1fd5b960dd36458b7b829f9094df18cd8b5ac201:
systemd: remove libsystemd-daemon linkage in libudev (2013-03-11 10:59:54 -0700)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib ross/systemd
for you to fetch changes up to ba7c15ae47ace8a15d97b4c58d2aa5b2ebb4c47a:
default-distrovars: don't add DISTRO_FEATURES_INITMAN to DISTRO_FEATURES (2013-03-11 12:17:49 -0700)
----------------------------------------------------------------
Radu Moisan (1):
busybox: add systemd enabling for syslog and klogd
Ross Burton (8):
systemd: merge udev-systemd into udev
systemd: make xz support (compressed journal) optional
default-providers: change udev selection logic update-rcd.bbclass: handle both sysvinit and systemd features being present
systemd: allow postinsts to run without systemd being present
systemd: add udev init script for hybrid sysvinit/systemd usage update-rc.d/systemd: change communication variable name
default-distrovars: don't add DISTRO_FEATURES_INITMAN to DISTRO_FEATURES
meta/classes/systemd.bbclass | 37 ++++--- meta/classes/update-rc.d.bbclass | 7 +- meta/conf/distro/include/default-distrovars.inc | 2 +- meta/conf/distro/include/default-providers.inc | 2 +- meta/recipes-core/busybox/busybox.inc | 17 +++- meta/recipes-core/busybox/busybox_1.20.2.bb | 2 + .../busybox/files/busybox-klogd.service.in | 8 ++ .../busybox/files/busybox-syslog.service.in | 13 +++ .../packagegroups/packagegroup-core-boot.bb | 4 +- meta/recipes-core/systemd/systemd/init | 101 ++++++++++++++++++++ meta/recipes-core/systemd/systemd_197.bb | 26 +++-- 11 files changed, 184 insertions(+), 35 deletions(-) create mode 100644 meta/recipes-core/busybox/files/busybox-klogd.service.in create mode 100644 meta/recipes-core/busybox/files/busybox-syslog.service.in create mode 100644 meta/recipes-core/systemd/systemd/init
Radu Moisan (1):
busybox: add systemd enabling for syslog and klogd
Ross Burton (8):
systemd: merge udev-systemd into udev
systemd: make xz support (compressed journal) optional
default-providers: change udev selection logic update-rcd.bbclass: handle both sysvinit and systemd features being
present
systemd: allow postinsts to run without systemd being present
systemd: add udev init script for hybrid sysvinit/systemd usage update-rc.d/systemd: change communication variable name
default-distrovars: don't add DISTRO_FEATURES_INITMAN to
DISTRO_FEATURES
meta/classes/systemd.bbclass | 37 ++++--- meta/classes/update-rc.d.bbclass | 7 +- meta/conf/distro/include/default-distrovars.inc | 2 +- meta/conf/distro/include/default-providers.inc | 2 +- meta/recipes-core/busybox/busybox.inc | 17 +++- meta/recipes-core/busybox/busybox_1.20.2.bb | 2 + .../busybox/files/busybox-klogd.service.in | 8 ++ .../busybox/files/busybox-syslog.service.in | 13 +++ .../packagegroups/packagegroup-core-boot.bb | 4 +- meta/recipes-core/systemd/systemd/init | 101 ++++++++++++++++++++ meta/recipes-core/systemd/systemd_197.bb | 26 +++-- 11 files changed, 184 insertions(+), 35 deletions(-) create mode 100644 meta/recipes-core/busybox/files/busybox-klogd.service.in create mode 100644 meta/recipes-core/busybox/files/busybox-syslog.service.in create mode 100644 meta/recipes-core/systemd/systemd/init
Signature · 1 line
1.7.10.4
PATCH 1/9 systemd: merge udev-systemd into udev
Merge the contents of udev-systemd, which is just the service files, into udev itself.
--- meta/recipes-core/systemd/systemd_197.bb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
meta/recipes-core/systemd/systemd_197.bb +4 -5
@@ -171,7 +171,7 @@ FILES_${PN} = " ${base_bindir}/* \ FILES_${PN}-dbg += "${systemd_unitdir}/.debug ${systemd_unitdir}/*/.debug ${base_libdir}/security/.debug/" FILES_${PN}-dev += "${base_libdir}/security/*.la ${datadir}/dbus-1/interfaces/ ${sysconfdir}/rpm/macros.systemd" -RDEPENDS_${PN} += "dbus udev-systemd" +RDEPENDS_${PN} += "dbus" RRECOMMENDS_${PN} += "systemd-serialgetty \ util-linux-agetty \
@@ -179,7 +179,7 @@ RRECOMMENDS_${PN} += "systemd-serialgetty \ kernel-module-autofs4 kernel-module-unix kernel-module-ipv6 \ " -PACKAGES =+ "udev-dbg udev udev-consolekit udev-utils udev-systemd" +PACKAGES =+ "udev-dbg udev udev-consolekit udev-utils" FILES_udev-dbg += "/lib/udev/.debug"
@@ -210,6 +210,8 @@ FILES_udev += "${base_sbindir}/udevd \ /lib/udev/rules.d/95*.rules \ ${base_libdir}/udev/hwdb.d \ ${sysconfdir}/udev \ + ${systemd_unitdir}/system/*udev* \ + ${systemd_unitdir}/system/*.wants/*udev* \ " FILES_udev-consolekit += "/lib/ConsoleKit"
@@ -217,9 +219,6 @@ RDEPENDS_udev-consolekit += "${@base_contains('DISTRO_FEATURES', 'x11', 'console FILES_udev-utils = "${bindir}/udevadm" -FILES_udev-systemd = "${systemd_unitdir}/system/*udev* ${systemd_unitdir}/system/*.wants/*udev*" -RDEPENDS_udev-systemd = "udev" - # TODO: # u-a for runlevel and telinit
Signature · 1 line
1.7.10.4
PATCH 2/9 busybox: add systemd enabling for syslog and klogd
In reply to Ross BurtonFrom: Radu Moisan <[email protected]>
--- meta/recipes-core/busybox/busybox.inc | 17 ++++++++++++++++- meta/recipes-core/busybox/busybox_1.20.2.bb | 2 ++ .../busybox/files/busybox-klogd.service.in | 8 ++++++++ .../busybox/files/busybox-syslog.service.in | 13 +++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-core/busybox/files/busybox-klogd.service.in create mode 100644 meta/recipes-core/busybox/files/busybox-syslog.service.in
meta/recipes-core/busybox/busybox.inc +16 -1
@@ -23,6 +23,7 @@ FILES_${PN}-mdev = "${sysconfdir}/init.d/mdev ${sysconfdir}/mdev.conf" FILES_${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd" FILES_${PN}-udhcpc = "${sysconfdir}/udhcpc.d ${datadir}/udhcpc" FILES_${PN}-hwclock = "${sysconfdir}/init.d/hwclock.sh" +FILES_${PN}-syslog = "${systemd_unitdir}/system/syslog.service" INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-syslog ${PN}-udhcpd ${PN}-mdev ${PN}-hwclock"
@@ -32,12 +33,16 @@ INITSCRIPT_NAME_${PN}-mdev = "mdev" INITSCRIPT_NAME_${PN}-hwclock = "hwclock.sh" INITSCRIPT_PARAMS_${PN}-mdev = "start 06 S ." INITSCRIPT_NAME_${PN}-udhcpd = "busybox-udhcpd" + +SYSTEMD_PACKAGES = "${PN}-syslog" +SYSTEMD_SERVICE_${PN}-syslog = "${PN}-syslog.service" + CONFFILES_${PN}-syslog = "${sysconfdir}/syslog-startup.conf.${BPN}" CONFFILES_${PN}-mdev = "${sysconfdir}/mdev.conf" RRECOMMENDS_${PN} = "${PN}-syslog ${PN}-udhcpc" -inherit cml1 update-rc.d +inherit cml1 systemd update-rc.d # internal helper def busybox_cfg(feature, features, tokens, cnf, rem):
@@ -213,6 +218,16 @@ do_install () { fi fi install -m 0644 ${S}/busybox.links ${D}${sysconfdir} + + if ${@base_contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${systemd_unitdir}/system + sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-syslog.service.in \ + > ${D}${systemd_unitdir}/system/busybox-syslog.service + sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-klogd.service.in \ + > ${D}${systemd_unitdir}/system/busybox-klogd.service + + ln -sf /dev/null ${D}${systemd_unitdir}/system/syslog.service + fi } inherit update-alternatives
meta/recipes-core/busybox/busybox_1.20.2.bb +2 -0
@@ -28,6 +28,8 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://fix-for-spurious-testsuite-failure.patch \ file://busybox-1.20.2-kernel_ver.patch \ file://stat-usr-bin.patch \ + file://busybox-syslog.service.in \ + file://busybox-klogd.service.in \ file://testsuite-du-du-k-works-fix-false-positive.patch" SRC_URI[tarball.md5sum] = "e025414bc6cd79579cc7a32a45d3ae1c"
meta/recipes-core/busybox/files/busybox-klogd.service.in new file +8 -0
@@ -0,0 +1,8 @@ +[Unit] +Description=Kernel Logging Service + +[Service] +ExecStart=@base_sbindir@/klogd -n + +[Install] +WantedBy=multi-user.target
meta/recipes-core/busybox/files/busybox-syslog.service.in new file +13 -0
@@ -0,0 +1,13 @@ +[Unit] +Description=System Logging Service +Wants=busybox-klogd.service + +[Service] +EnvironmentFile=-/etc/default/busybox-syslog +ExecStart=@base_sbindir@/syslogd -n $OPTIONS +Sockets=syslog.socket + +[Install] +WantedBy=multi-user.target +Also=busybox-klogd.service +Alias=syslog.service
Signature · 1 line
1.7.10.4
PATCH 3/9 systemd: make xz support (compressed journal) optional
In reply to Ross BurtonDefaults to enabled but if you don't want to use the journal and need some space, this can now be disabled.
--- meta/recipes-core/systemd/systemd_197.bb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
meta/recipes-core/systemd/systemd_197.bb +4 -2
@@ -11,7 +11,7 @@ PROVIDES = "udev" PE = "1" PR = "r4" -DEPENDS = "xz kmod docbook-sgml-dtd-4.1-native intltool-native gperf-native acl readline dbus libcap libcgroup tcp-wrappers glib-2.0" +DEPENDS = "kmod docbook-sgml-dtd-4.1-native intltool-native gperf-native acl readline dbus libcap libcgroup tcp-wrappers glib-2.0" DEPENDS += "${@base_contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}" SECTION = "base/shell"
@@ -43,9 +43,11 @@ LDFLAGS_libc-uclibc_append = " -lrt" GTKDOC_DOCDIR = "${S}/docs/" -PACKAGECONFIG ??= "" +PACKAGECONFIG ??= "xz" # Sign the journal for anti-tampering PACKAGECONFIG[gcrypt] = "--enable-gcrypt,--disable-gcrypt,libgcrypt" +# Compress the journal +PACKAGECONFIG[xz] = "--enable-xz,--disable-xz,xz" CACHED_CONFIGUREVARS = "ac_cv_path_KILL=${base_bindir}/kill"
Signature · 1 line
1.7.10.4
PATCH 4/9 default-providers: change udev selection logic
In reply to Ross BurtonChange the logic so that the udev provider is the standalone udev, unless the systemd DISTRO_FEATURE is set. This is required so that hybrid distros with both sysvinit and systemd will have a usable provider (in this case, systemd's udev).
--- meta/conf/distro/include/default-providers.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/conf/distro/include/default-providers.inc +1 -1
@@ -38,4 +38,4 @@ PREFERRED_PROVIDER_nativesdk-opkg ?= "nativesdk-opkg" PREFERRED_PROVIDER_console-tools ?= "kbd" PREFERRED_PROVIDER_gzip-native ?= "pigz-native" PREFERRED_PROVIDER_make ?= "make" -PREFERRED_PROVIDER_udev ?= "${@base_contains('DISTRO_FEATURES','sysvinit','udev','',d)}${@base_contains('DISTRO_FEATURES','systemd','systemd','',d)}" +PREFERRED_PROVIDER_udev ?= "${@base_contains('DISTRO_FEATURES','systemd','systemd','udev',d)}"
Signature · 1 line
1.7.10.4
PATCH 5/9 update-rcd.bbclass: handle both sysvinit and systemd features being present
In reply to Ross BurtonRun the helper if the sysvinit feature is present, or if the systemd feature is present but the systemd class hasn't been inherited. We want to run in the latter case as systemd has sysvinit compatibility, but we don't want to always so that pure systemd images don't have redundent sysvinit files.
--- meta/classes/update-rc.d.bbclass | 9 ++++++--- meta/recipes-core/packagegroups/packagegroup-core-boot.bb | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-)
meta/classes/update-rc.d.bbclass +6 -3
@@ -75,9 +75,12 @@ python populate_packages_updatercd () { postrm += d.getVar('updatercd_postrm', True) d.setVar('pkg_postrm_%s' % pkg, postrm) - # If the systemd class has also been inherited, then don't do anything as - # the systemd units will override anything created by update-rc.d. - if not d.getVar("SYSTEMD_BBCLASS_ENABLED", True): + # Run if the sysvinit feature is present, or if the systemd feature is present + # but the systemd class hasn't been inherited. We want to run in the latter case + # as systemd has sysvinit compatibility, but we don't want to always so that + # pure systemd images don't have redundent sysvinit files. + if "sysvinit" in d.getVar("DISTRO_FEATURES").split() or \ + ("systemd" in d.getVar("DISTRO_FEATURES").split() and not d.getVar("SYSTEMD_BBCLASS_ENABLED", True)): pkgs = d.getVar('INITSCRIPT_PACKAGES', True) if pkgs == None: pkgs = d.getVar('UPDATERCPN', True)
meta/recipes-core/packagegroups/packagegroup-core-boot.bb +2 -2
@@ -27,7 +27,7 @@ RCONFLICTS_${PN} = "task-core-boot" VIRTUAL-RUNTIME_dev_manager ?= "udev" VIRTUAL-RUNTIME_login_manager ?= "tinylogin" VIRTUAL-RUNTIME_init_manager ?= "${DISTRO_FEATURES_INITMAN}" -VIRTUAL-RUNTIME_initscripts ?= "${@base_contains('DISTRO_FEATURES', 'sysvinit', 'initscripts', '',d)}" +VIRTUAL-RUNTIME_initscripts ?= "${@base_contains('DISTRO_FEATURES_INITMAN', 'sysvinit', 'initscripts', '',d)}" VIRTUAL-RUNTIME_keymaps ?= "keymaps" RDEPENDS_${PN} = "\
@@ -42,7 +42,7 @@ RDEPENDS_${PN} = "\ ${VIRTUAL-RUNTIME_login_manager} \ ${VIRTUAL-RUNTIME_init_manager} \ ${VIRTUAL-RUNTIME_initscripts} \ - ${@base_contains('DISTRO_FEATURES', 'systemd', 'systemd-compat-units', '',d)} \ + ${@base_contains('DISTRO_FEATURES_INITMAN', 'systemd', 'systemd-compat-units', '',d)} \ ${VIRTUAL-RUNTIME_dev_manager} \ ${VIRTUAL-RUNTIME_update-alternatives} \ ${MACHINE_ESSENTIAL_EXTRA_RDEPENDS}"
Signature · 1 line
1.7.10.4
Re: [PATCH 5/9] update-rcd.bbclass: handle both sysvinit and systemd features being present
Quoted 45 lines · Ross Burton
Run the helper if the sysvinit feature is present, or if the systemd feature is present but the systemd class hasn't been inherited. We want to run in the latter case as systemd has sysvinit compatibility, but we don't want to always so that pure systemd images don't have redundent sysvinit files.
Signed-off-by Ross Burton <[email protected]>--- meta/classes/update-rc.d.bbclass | 9 ++++++--- meta/recipes-core/packagegroups/packagegroup-core-boot.bb | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-)meta/classes/update-rc.d.bbclass +6
-3@@ -75,9 +75,12 @@ python populate_packages_updatercd () { postrm += d.getVar('updatercd_postrm', True) d.setVar('pkg_postrm_%s' % pkg, postrm) - # If the systemd class has also been inherited, then don't do anything as - # the systemd units will override anything created by update-rc.d. - if not d.getVar("SYSTEMD_BBCLASS_ENABLED", True): + # Run if the sysvinit feature is present, or if the systemd feature is present + # but the systemd class hasn't been inherited. We want to run in the latter case + # as systemd has sysvinit compatibility, but we don't want to always so that + # pure systemd images don't have redundent sysvinit files. + if "sysvinit" in d.getVar("DISTRO_FEATURES").split() or \ + ("systemd" in d.getVar("DISTRO_FEATURES").split() and not d.getVar("SYSTEMD_BBCLASS_ENABLED", True)): pkgs = d.getVar('INITSCRIPT_PACKAGES', True) if pkgs == None: pkgs = d.getVar('UPDATERCPN', True)meta/recipes-core/packagegroups/packagegroup-core-boot.bb +1
-1@@ -27,7 +27,7 @@ RCONFLICTS_${PN} = "task-core-boot" VIRTUAL-RUNTIME_dev_manager ?= "udev" VIRTUAL-RUNTIME_login_manager ?= "tinylogin" VIRTUAL-RUNTIME_init_manager ?= "${DISTRO_FEATURES_INITMAN}" -VIRTUAL-RUNTIME_initscripts ?= "${@base_contains('DISTRO_FEATURES', 'sysvinit', 'initscripts', '',d)}" +VIRTUAL-RUNTIME_initscripts ?= "${@base_contains('DISTRO_FEATURES_INITMAN', 'sysvinit', 'initscripts', '',d)}" VIRTUAL-RUNTIME_keymaps ?= "keymaps" RDEPENDS_${PN} = "\
meta/recipes-core/packagegroups/packagegroup-core-boot.bb RDEPENDS_${PN} = "\ · line 45
Quoted 5 lines
meta/recipes-core/packagegroups/packagegroup-core-boot.bb +1
-1@@ -42,7 +42,7 @@ RDEPENDS_${PN} = "\ ${VIRTUAL-RUNTIME_login_manager} \ ${VIRTUAL-RUNTIME_init_manager} \ ${VIRTUAL-RUNTIME_initscripts} \ - ${@base_contains('DISTRO_FEATURES', 'systemd', 'systemd-compat-units', '',d)} \ + ${@base_contains('DISTRO_FEATURES_INITMAN', 'systemd', 'systemd-compat-units', '',d)} \
Why these 2 changes? I don't see any explanation in commit message.
Quoted 11 lines
meta/recipes-core/packagegroups/packagegroup-core-boot.bb +0
-0${VIRTUAL-RUNTIME_dev_manager} \ ${VIRTUAL-RUNTIME_update-alternatives} \ ${MACHINE_ESSENTIAL_EXTRA_RDEPENDS}"Signature · 7 lines
1.7.10.4 _______________________________________________ Openembedded-core mailing list [email protected] http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Signature · 1 line
Martin 'JaMa' Jansa jabber: [email protected]
PATCH 6/9 systemd: allow postinsts to run without systemd being present
In reply to Ross BurtonThese fragments may be used on a system that didn't actually boot with systemd, so check for systemctl first, and don't force systemd to be installed.
--- meta/classes/systemd.bbclass | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-)
meta/classes/systemd.bbclass +11 -16
@@ -24,19 +24,23 @@ if [ -n "$D" ]; then OPTS="--root=$D" fi -systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE} +if which systemctl >/dev/null; then + systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE} -if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then - systemctl start ${SYSTEMD_SERVICE} + if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then + systemctl start ${SYSTEMD_SERVICE} + fi fi } systemd_prerm() { -if [ -z "$D" ]; then - systemctl stop ${SYSTEMD_SERVICE} -fi +if which systemctl >/dev/null; then + if [ -z "$D" ]; then + systemctl stop ${SYSTEMD_SERVICE} + fi -systemctl disable ${SYSTEMD_SERVICE} + systemctl disable ${SYSTEMD_SERVICE} +fi } python systemd_populate_packages() {
@@ -56,14 +60,6 @@ python systemd_populate_packages() { bb.error('%s does not appear in package list, please add it' % pkg_systemd) - # Add a runtime dependency on systemd to pkg - def systemd_add_rdepends(pkg): - rdepends = d.getVar('RDEPENDS_' + pkg, True) or "" - if not 'systemd' in rdepends.split(): - rdepends = '%s %s' % (rdepends, 'systemd') - d.setVar('RDEPENDS_' + pkg, rdepends) - - def systemd_generate_package_scripts(pkg): bb.debug(1, 'adding systemd calls to postinst/postrm for %s' % pkg)
@@ -156,7 +152,6 @@ python systemd_populate_packages() { systemd_check_package(pkg) if d.getVar('SYSTEMD_SERVICE_' + pkg, True): systemd_generate_package_scripts(pkg) - systemd_add_rdepends(pkg) systemd_check_services() }
Signature · 1 line
1.7.10.4
Re: [PATCH 6/9] systemd: allow postinsts to run without systemd being present
Ross Burton <[email protected]>
Quoted 3 lines · writes:
These fragments may be used on a system that didn't actually boot with systemd, so check for systemctl first, and don't force systemd to be installed.
Checking for existence of programs in scriplets is a bad hack which might hide real problems and the scriplets are getting more complicated by this.
Placing scriplets and related files into separate subpackages is a much cleaner solution.
Quoted 1 line
+if which systemctl >/dev/null; then
check with the shell builtin 'type $prog' is more portable and does not require the external 'which' program.
Enrico
Re: [PATCH 6/9] systemd: allow postinsts to run without systemd being present
Quoted 4 lines · Enrico Scholz
Quoted 1 line
+if which systemctl >/dev/null; then
check with the shell builtin 'type $prog' is more portable and does not require the external 'which' program.
Tried that (type -p systemctl), and failed on the host. Really not sure why to be honest.
Ross
Re: [PATCH 6/9] systemd: allow postinsts to run without systemd being present
Quoted 6 lines · Ross
Quoted 4 lines
Quoted 1 line
+if which systemctl >/dev/null; then
check with the shell builtin 'type $prog' is more portable and does not require the external 'which' program.
Tried that (type -p systemctl)
'type systemctl'; 'type -p ...' is a bashism.
Enrico
Re: [PATCH 6/9] systemd: allow postinsts to run without systemd being present
Quoted 1 line · Enrico Scholz
'type systemctl'; 'type -p ...' is a bashism.
Pretty sure I tried both, and busybox source shows it won't error out on "-p". I'll try again.
Ross
Re: [PATCH 6/9] systemd: allow postinsts to run without systemd being present
"Burton, Ross" <[email protected]>
Quoted 4 lines · writes:
Quoted 1 line
'type systemctl'; 'type -p ...' is a bashism.
Pretty sure I tried both, and busybox source shows it won't error out on "-p".
But 'dash' on host will fail.
Enrico
Re: [PATCH 6/9] systemd: allow postinsts to run without systemd being present
In reply to Enrico ScholzQuoted 6 lines · Enrico Scholz
Checking for existence of programs in scriplets is a bad hack which might hide real problems and the scriplets are getting more complicated by this.
Placing scriplets and related files into separate subpackages is a much cleaner solution.
Sure, but then you're just substituting one ugly hack for bigger problems including upgrade paths, which aren't actually solvable in a general way.
Ross
Re: [PATCH 6/9] systemd: allow postinsts to run without systemd being present
Quoted 9 lines · Ross
Quoted 6 lines
Checking for existence of programs in scriplets is a bad hack which might hide real problems and the scriplets are getting more complicated by this.
Placing scriplets and related files into separate subpackages is a much cleaner solution.
Sure, but then you're just substituting one ugly hack for bigger problems including upgrade
What is the problem with subpackages and upgrade paths?
Enrico
PATCH 7/9 systemd: add udev init script for hybrid sysvinit/systemd usage
In reply to Ross BurtonIf a distro is built with both sysvinit and systemd then we may be booting systemd's udev on sysvinit, so add a sysvinit-style init script for udev (copied from udev).
--- meta/recipes-core/systemd/systemd/init | 101 ++++++++++++++++++++++++++++++ meta/recipes-core/systemd/systemd_197.bb | 13 +++- 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-core/systemd/systemd/init
meta/recipes-core/systemd/systemd/init new file +101 -0
@@ -0,0 +1,101 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: udev +# Required-Start: mountvirtfs +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Start udevd, populate /dev and load drivers. +### END INIT INFO + +. /etc/init.d/functions + +export TZ=/etc/localtime + +[ -d /sys/class ] || exit 1 +[ -r /proc/mounts ] || exit 1 +[ -x /lib/udev/udevd ] || exit 1 +[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache +[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf + +readfile () { + filename=$1 + READDATA="" + if [ -r $filename ]; then + while read line; do + READDATA="$READDATA$line" + done < $filename + fi +} + +case "$1" in + start) + export ACTION=add + # propagate /dev from /sys + echo "Starting udev" + + # mount the tmpfs on /dev, if not already done + LANG=C awk '$2 == "/dev" && ($3 == "tmpfs" || $3 == "devtmpfs") { exit 1 }' /proc/mounts && { + mount -n -o mode=0755 -t tmpfs none "/dev" + } + [ -e /dev/pts ] || mkdir -m 0755 /dev/pts + [ -e /dev/shm ] || mkdir -m 1777 /dev/shm + mount -a -t tmpfs 2>/dev/null + mkdir -p /var/volatile/run + + # cache handling + if [ "$DEVCACHE" != "" ]; then + readfile /proc/version + VERSION="$READDATA" + readfile /proc/cmdline + CMDLINE="$READDATA" + readfile /proc/devices + DEVICES="$READDATA" + readfile /proc/atags + ATAGS="$READDATA" + + if [ -e $DEVCACHE ]; then + readfile /etc/udev/cache.data + if [ "$READDATA" = "$VERSION$CMDLINE$DEVICES$ATAGS" ]; then + (cd /; tar xf $DEVCACHE > /dev/null 2>&1) + not_first_boot=1 + fi + + echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache + fi + fi + + # make_extra_nodes + killproc udevd > "/dev/null" 2>&1 + + # trigger the sorted events + echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug + /lib/udev/udevd -d + + /usr/bin/udevadm control --env=STARTUP=1 + if [ "$not_first_boot" != "" ];then + /usr/bin/udevadm trigger --action=add --subsystem-nomatch=tty --subsystem-nomatch=mem --subsystem-nomatch=vc --subsystem-nomatch=vtconsole --subsystem-nomatch=misc --subsystem-nomatch=dcon --subsystem-nomatch=pci_bus --subsystem-nomatch=graphics --subsystem-nomatch=backlight --subsystem-nomatch=video4linux --subsystem-nomatch=platform + (/usr/bin/udevadm settle --timeout=3; /usr/bin/udevadm control --env=STARTUP=)& + else + /usr/bin/udevadm trigger --action=add + /usr/bin/udevadm settle + fi + ;; + stop) + echo "Stopping udevd" + start-stop-daemon --stop --name udevd --quiet + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + status) + status udevd + ;; + *) + echo "Usage: $0 {start|stop|status|restart}" + exit 1 +esac +exit 0
meta/recipes-core/systemd/systemd_197.bb +12 -1
@@ -16,7 +16,7 @@ DEPENDS += "${@base_contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}" SECTION = "base/shell" -inherit gtk-doc useradd pkgconfig autotools perlnative +inherit gtk-doc useradd pkgconfig autotools perlnative update-rc.d SRC_URI = "http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz \ file://touchscreen.rules \
@@ -26,6 +26,7 @@ SRC_URI = "http://www.freedesktop.org/software/systemd/systemd-${PV}.tar.xz \ file://00-create-volatile.conf \ file://0001-systemd-analyze-rewrite-in-C.patch \ file://udev-linkage.patch \ + file://init \ " SRC_URI[md5sum] = "56a860dceadfafe59f40141eb5223743" SRC_URI[sha256sum] = "e6857ea21ae24d7056e7b0f4c2aaaba73b8bf57025b8949c0a8af0c1bc9774b5"
@@ -101,6 +102,11 @@ do_install() { install -m 0644 ${WORKDIR}/var-run.conf ${D}${sysconfdir}/tmpfiles.d/ install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/ + + if ${@base_contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/udev + fi } python populate_packages_prepend (){
@@ -212,6 +218,7 @@ FILES_udev += "${base_sbindir}/udevd \ /lib/udev/rules.d/95*.rules \ ${base_libdir}/udev/hwdb.d \ ${sysconfdir}/udev \ + ${sysconfdir}/init.d/udev \ ${systemd_unitdir}/system/*udev* \ ${systemd_unitdir}/system/*.wants/*udev* \ "
@@ -221,6 +228,10 @@ RDEPENDS_udev-consolekit += "${@base_contains('DISTRO_FEATURES', 'x11', 'console FILES_udev-utils = "${bindir}/udevadm" +INITSCRIPT_PACKAGES = "udev" +INITSCRIPT_NAME_udev = "udev" +INITSCRIPT_PARAMS_udev = "start 03 S ." + # TODO: # u-a for runlevel and telinit
Signature · 1 line
1.7.10.4
PATCH 8/9 update-rc.d/systemd: change communication variable name
In reply to Ross BurtonRename SYSTEMD_BBCLASS_ENABLED to INHIBIT_UPDATERCD_BBCLASS to reflect it's side-effect for clarity.
--- meta/classes/systemd.bbclass | 10 ++++++---- meta/classes/update-rc.d.bbclass | 8 +++----- 2 files changed, 9 insertions(+), 9 deletions(-)
meta/classes/systemd.bbclass +6 -4
@@ -10,11 +10,13 @@ SYSTEMD_AUTO_ENABLE ??= "enable" # even if the systemd DISTRO_FEATURE isn't enabled. As such don't make any # changes directly but check the DISTRO_FEATURES first. python __anonymous() { - if "systemd" in d.getVar("DISTRO_FEATURES", True).split(): + features = d.getVar("DISTRO_FEATURES", True).split() + # If the distro features have systemd but not sysvinit, inhibit update-rcd + # from doing any work so that pure-systemd images don't have redundant init + # files. + if "systemd" in features and "sysvinit" not in features: d.appendVar("DEPENDS", " systemd-systemctl-native") - # Set a variable so that update-rcd.bbclass knows we're active and can - # disable itself. - d.setVar("SYSTEMD_BBCLASS_ENABLED", "1") + d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") } systemd_postinst() {
meta/classes/update-rc.d.bbclass +3 -5
@@ -75,12 +75,10 @@ python populate_packages_updatercd () { postrm += d.getVar('updatercd_postrm', True) d.setVar('pkg_postrm_%s' % pkg, postrm) - # Run if the sysvinit feature is present, or if the systemd feature is present - # but the systemd class hasn't been inherited. We want to run in the latter case - # as systemd has sysvinit compatibility, but we don't want to always so that - # pure systemd images don't have redundent sysvinit files. + # Check that this class isn't being inhibited (generally, by + # systemd.bbclass) before doing any work. if "sysvinit" in d.getVar("DISTRO_FEATURES").split() or \ - ("systemd" in d.getVar("DISTRO_FEATURES").split() and not d.getVar("SYSTEMD_BBCLASS_ENABLED", True)): + not d.getVar("INHIBIT_UPDATERCD_BBCLASS", True): pkgs = d.getVar('INITSCRIPT_PACKAGES', True) if pkgs == None: pkgs = d.getVar('UPDATERCPN', True)
Signature · 1 line
1.7.10.4
PATCH 9/9 default-distrovars: don't add DISTRO_FEATURES_INITMAN to DISTRO_FEATURES
In reply to Ross BurtonIt will be backfilled later, so don't add it to the default DISTRO_FEATURES.
--- meta/conf/distro/include/default-distrovars.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/conf/distro/include/default-distrovars.inc +1 -1
@@ -18,7 +18,7 @@ DISTRO_FEATURES_LIBC_DEFAULT ?= "ipv4 ipv6 libc-backtrace libc-big-macros libc-b DISTRO_FEATURES_LIBC ?= "${DISTRO_FEATURES_LIBC_DEFAULT}" DISTRO_FEATURES_LIBC_class-nativesdk = "${DISTRO_FEATURES_LIBC_DEFAULT}" DISTRO_FEATURES_INITMAN ?= "sysvinit" -DISTRO_FEATURES ?= "alsa argp bluetooth ext2 irda largefile pcmcia usbgadget usbhost wifi xattr nfs zeroconf pci 3g nfc x11 ${DISTRO_FEATURES_LIBC} ${DISTRO_FEATURES_INITMAN}" +DISTRO_FEATURES ?= "alsa argp bluetooth ext2 irda largefile pcmcia usbgadget usbhost wifi xattr nfs zeroconf pci 3g nfc x11 ${DISTRO_FEATURES_LIBC}" IMAGE_FEATURES ?= ""
Signature · 1 line
1.7.10.4
Quoted 3 lines · Ross Burton
This series allows you to have both sysvinit and systemd in
DISTRO_FEATURES. Packages will be built with both init scripts, and some daemons will be linking to libsystemd-daemon so that will be pulled in to sysvinit images.
Regarding the upgrade path, Richard/Paul/myself discussed this over lunch and proposed that oe-core could gain an include file for distro configuration that basically injects the backward compatibility dependencies. So for meta-systemd, it would inject replaces/provides/conflicts for each of the packages in meta-systemd. This would isolate the dependencies into a single location, and be opt-in for distros that previously shipped meta-systemd. Hopefully the implementation of this is obvious, and patches to implement this are welcome.
Ross
Quoted 5 lines · Ross
Quoted 3 lines · Ross Burton
This series allows you to have both sysvinit and systemd in
DISTRO_FEATURES. Packages will be built with both init scripts, and some daemons will be linking to libsystemd-daemon so that will be pulled in to sysvinit images.
Quoted 9 lines
Regarding the upgrade path, Richard/Paul/myself discussed this over lunch and proposed that oe-core could gain an include file for distro configuration that basically injects the backward compatibility dependencies. So for meta-systemd, it would inject replaces/provides/conflicts for each of the packages in meta-systemd. This would isolate the dependencies into a single location, and be opt-in for distros that previously shipped meta-systemd. Hopefully the implementation of this is obvious, and patches to implement this are welcome.
I personally prefer to still use meta-oe systemd class and keep the possibility to product images with choosen init system. I think Martin will also prefer it.
Signature · 3 lines
Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
Hi,
Quoted 3 lines · Otavio Salvador
I personally prefer to still use meta-oe systemd class and keep the possibility to product images with choosen init system. I think Martin will also prefer it.
I'd love Martin to speak for himself in this thread.
The big difference between meta-systemd and this series is that if you enable both, you'll get a few service files in the sysvinit images and probably libsystemd-daemon. In total we're talking about a 50K increase here which is for practical purposes negligible.
Are you objecting to the redundant service files (which you could remove in a image construction hook, along with anything else that can be wiped when you need to save every byte), or something else?
Ross
Quoted 16 lines · Otavio Salvador
Quoted 5 lines · Ross
Quoted 3 lines · Ross Burton
This series allows you to have both sysvinit and systemd in
DISTRO_FEATURES. Packages will be built with both init scripts, and some daemons will be linking to libsystemd-daemon so that will be pulled in to sysvinit images.Quoted 9 lines
Regarding the upgrade path, Richard/Paul/myself discussed this over lunch and proposed that oe-core could gain an include file for distro configuration that basically injects the backward compatibility dependencies. So for meta-systemd, it would inject replaces/provides/conflicts for each of the packages in meta-systemd. This would isolate the dependencies into a single location, and be opt-in for distros that previously shipped meta-systemd. Hopefully the implementation of this is obvious, and patches to implement this are welcome.
Quoted 3 lines
I personally prefer to still use meta-oe systemd class and keep the possibility to product images with choosen init system. I think Martin will also prefer it.
using different init manager is a separate problem than what Ross tried to address here isn't it ? I personally don't have a use case where I would upgrade live from 1.3 to 1.4 so for me I could easily accept a different solution for 1.4
Quoted 10 lines
Signature · 9 lines
-- Otavio Salvador O.S. Systems E-mail: [email protected] http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br _______________________________________________ Openembedded-core mailing list [email protected] http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Quoted 1 line · Khem Raj
using different init manager is a separate problem than what Ross tried to address here isn't it ?
This series lets you do DISTRO_FEATURES="systemd sysvinit" and it will build support for both in the packages, and then based on DISTRO_FEATURES_INITMAN it will build different images.
Ross
Op 12 mrt. 2013, om 00:21 heeft "Burton, Ross" <[email protected]> het volgende geschreven:
Quoted 6 lines · Khem Raj
Quoted 1 line
using different init manager is a separate problem than what Ross tried to address here isn't it ?
This series lets you do DISTRO_FEATURES="systemd sysvinit" and it will build support for both in the packages, and then based on
DISTRO_FEATURES_INITMANit will build different images.
Isn't DISTRO_FEATURES_INITMAN more like an IMAGE_FEATURE now?
Quoted 1 line · Koen Kooi
Isn't
DISTRO_FEATURES_INITMANmore like anIMAGE_FEATUREnow?
In a sense - it populates a distro feature though a backfill and is used when constructing an image, so if you explicitly set DISTRO_FEATURES to include both then swapping this will change the image.
As I said, it should probably be renamed. Any suggestions?
Ross
Op 11 mrt. 2013, om 23:49 heeft Khem Raj <[email protected]> het volgende geschreven:
Quoted 19 lines · Otavio Salvador
Quoted 17 lines · Ross
Quoted 14 lines · Ross Burton
Quoted 3 lines
This series allows you to have both sysvinit and systemd in
DISTRO_FEATURES. Packages will be built with both init scripts, and some daemons will be linking to libsystemd-daemon so that will be pulled in to sysvinit images.Regarding the upgrade path, Richard/Paul/myself discussed this over lunch and proposed that oe-core could gain an include file for distro configuration that basically injects the backward compatibility dependencies. So for meta-systemd, it would inject replaces/provides/conflicts for each of the packages in meta-systemd. This would isolate the dependencies into a single location, and be opt-in for distros that previously shipped meta-systemd. Hopefully the implementation of this is obvious, and patches to implement this are welcome.
Quoted 7 lines
Quoted 3 lines
I personally prefer to still use meta-oe systemd class and keep the possibility to product images with choosen init system. I think Martin will also prefer it.
using different init manager is a separate problem than what Ross tried to address here isn't it ? I personally don't have a use case where I would upgrade live from 1.3 to 1.4 so for me I could easily accept a different solution for 1.4
Upgrading between 1.3 and 1.4 is already impossible for non-systemd related reasons. But that shouldn't be a reason to break upgrade paths for other things, so I'd very much like to see some attention to this for 1.5.
Quoted 25 lines · Koen Kooi
Op 11 mrt. 2013, om 23:49 heeft Khem Raj <[email protected]> het volgende geschreven:
Quoted 23 lines · Otavio Salvador
Quoted 20 lines · Ross
Quoted 5 lines · Ross Burton
Quoted 3 lines
This series allows you to have both sysvinit and systemd in
DISTRO_FEATURES. Packages will be built with both init scripts, and some daemons will be linking to libsystemd-daemon so that will be pulled in to sysvinit images.Quoted 9 lines
Regarding the upgrade path, Richard/Paul/myself discussed this over lunch and proposed that oe-core could gain an include file for distro configuration that basically injects the backward compatibility dependencies. So for meta-systemd, it would inject replaces/provides/conflicts for each of the packages in meta-systemd. This would isolate the dependencies into a single location, and be opt-in for distros that previously shipped meta-systemd. Hopefully the implementation of this is obvious, and patches to implement this are welcome.
I personally prefer to still use meta-oe systemd class and keep the possibility to product images with choosen init system. I think Martin will also prefer it.
Quoted 6 lines
Quoted 3 lines
using different init manager is a separate problem than what Ross tried to address here isn't it ? I personally don't have a use case where I would upgrade live from 1.3 to 1.4 so for me I could easily accept a different solution for 1.4
Upgrading between 1.3 and 1.4 is already impossible for non-systemd related reasons.
Which reasons?
Cheers,
Richard
Op 12 mrt. 2013, om 19:50 heeft Richard Purdie <[email protected]> het volgende geschreven:
Quoted 26 lines · Koen Kooi
Quoted 25 lines
Op 11 mrt. 2013, om 23:49 heeft Khem Raj <[email protected]> het volgende geschreven:
Quoted 23 lines · Otavio Salvador
Quoted 20 lines · Ross
Quoted 5 lines · Ross Burton
Quoted 3 lines
This series allows you to have both sysvinit and systemd in
DISTRO_FEATURES. Packages will be built with both init scripts, and some daemons will be linking to libsystemd-daemon so that will be pulled in to sysvinit images.Quoted 9 lines
Regarding the upgrade path, Richard/Paul/myself discussed this over lunch and proposed that oe-core could gain an include file for distro configuration that basically injects the backward compatibility dependencies. So for meta-systemd, it would inject replaces/provides/conflicts for each of the packages in meta-systemd. This would isolate the dependencies into a single location, and be opt-in for distros that previously shipped meta-systemd. Hopefully the implementation of this is obvious, and patches to implement this are welcome.
I personally prefer to still use meta-oe systemd class and keep the possibility to product images with choosen init system. I think Martin will also prefer it.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
using different init manager is a separate problem than what Ross tried to address here isn't it ? I personally don't have a use case where I would upgrade live from 1.3 to 1.4 so for me I could easily accept a different solution for 1.4
Upgrading between 1.3 and 1.4 is already impossible for non-systemd related reasons.
Which reasons?
Warning, handwaving ahead: Renamed packages, differently split packages et cetera.
Quoted 9 lines · Koen Kooi
Op 12 mrt. 2013, om 19:50 heeft Richard Purdie <[email protected]> het volgende geschreven:
Quoted 6 lines · Koen Kooi
Quoted 3 lines
Op 11 mrt. 2013, om 23:49 heeft Khem Raj <[email protected]> het volgende geschreven:
Upgrading between 1.3 and 1.4 is already impossible for non-systemd related reasons.Which reasons?
Warning, handwaving ahead: Renamed packages, differently split packages et cetera.
I thought we'd put Conflicts/Provides and other pieces in place to try and avoid this? If there are issues, I'm open to patches which help address the problems.
Cheers,
Richard
Quoted 7 lines · Richard Purdie
Quoted 6 lines · Koen Kooi
Op 12 mrt. 2013, om 19:50 heeft Richard Purdie <[email protected]> het volgende geschreven:
Quoted 5 lines · Koen Kooi
Quoted 3 lines
Op 11 mrt. 2013, om 23:49 heeft Khem Raj <[email protected]> het volgende geschreven:
Upgrading between 1.3 and 1.4 is already impossible for non-systemd related reasons.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Which reasons?
Warning, handwaving ahead: Renamed packages, differently split packages et cetera.
I thought we'd put Conflicts/Provides and other pieces in place to try and avoid this? If there are issues, I'm open to patches which help address the problems.
I try to report such issues as soon as they are introduced to developer who introduced them, but quite often those emails got no reply and issue is forgotten.
I know I should report them in bugzilla, but I usually use oe-commits list to find what changed since my last successful opkg upgrade and it's faster to just reply there then to create new bug report.
Most of those issues would be detected by developers if they build with buildhistory enabled and do upgrade on target device.
Signature · 1 line
Martin 'JaMa' Jansa jabber: [email protected]