systemd: Build the systemctl executable
PATCH v7 1/2 systemd: Build the systemctl executable
From: Vyacheslav Yurkov <[email protected]>
Instead of the python re-implementation build the actual systemctl from the systemd source tree. The python script was used when systemd didn't provide an option to build individual executables. It is possible in the meantime, so instead of always adapting the script when there's a new functionality, we simply use upstream implementation.
License-Update: Base recipe is used
--- .../systemd/systemd-systemctl-native.bb | 23 +- .../systemd/systemd-systemctl/systemctl | 376 ------------------ 2 files changed, 11 insertions(+), 388 deletions(-) delete mode 100755 meta/recipes-core/systemd/systemd-systemctl/systemctl
meta/recipes-core/systemd/systemd-systemctl-native.bb +11 -12
@@ -1,17 +1,16 @@ -SUMMARY = "Wrapper for enabling systemd services" +SUMMARY = "Systemctl executable from systemd" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" +require systemd.inc +DEPENDS = "gperf-native libcap-native util-linux-native python3-jinja2-native" -inherit native +inherit pkgconfig meson native -SRC_URI = "file://systemctl" +MESON_TARGET = "systemctl:executable" +MESON_INSTALL_TAGS = "systemctl" +EXTRA_OEMESON:append = " -Dlink-systemctl-shared=false" -S = "${WORKDIR}/sources" -UNPACKDIR = "${S}" - -do_install() { - install -d ${D}${bindir} - install -m 0755 ${S}/systemctl ${D}${bindir} -} +# Systemctl is supposed to operate on target, but the target sysroot is not +# determined at run-time, but rather set during configure +# More details are here https://github.com/systemd/systemd/issues/35897#issuecomment-2665405887 +EXTRA_OEMESON:append = " --sysconfdir ${sysconfdir_native}"
meta/recipes-core/systemd/systemd-systemctl/systemctl deleted +0 -376
376 lines not on this page · raw message
PATCH v7 2/2 classes-recipe: Consolidate machine-id handling
From: Vyacheslav Yurkov <[email protected]>
Whenever Systemd is used as an init manager, it requires a machine-id file to be present / initialized / or have the RW rootfs. This change does not introduce a new functionality, but rather merges everything we do with machine-id in one place.
--- meta/classes-recipe/image.bbclass | 9 +------ .../rootfs-postcommands.bbclass | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 15 deletions(-)
meta/classes-recipe/image.bbclass +1 -8
@@ -699,13 +699,6 @@ reproducible_final_image_task () { find ${IMAGE_ROOTFS} -print0 | xargs -0 touch -h --date=@$REPRODUCIBLE_TIMESTAMP_ROOTFS } -systemd_preset_all () { - if [ -e ${IMAGE_ROOTFS}${root_prefix}/lib/systemd/systemd ]; then - systemctl --root="${IMAGE_ROOTFS}" --preset-mode=enable-only preset-all - systemctl --root="${IMAGE_ROOTFS}" --global --preset-mode=enable-only preset-all - fi -} - -IMAGE_PREPROCESS_COMMAND:append = " ${@ 'systemd_preset_all' if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and not bb.utils.contains('IMAGE_FEATURES', 'stateless-rootfs', True, False, d) else ''} reproducible_final_image_task " +IMAGE_PREPROCESS_COMMAND:append = " reproducible_final_image_task " CVE_PRODUCT = ""
meta/classes-recipe/rootfs-postcommands.bbclass +18 -7
@@ -43,7 +43,7 @@ ROOTFS_POSTUNINSTALL_COMMAND =+ "write_image_manifest" POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log" # Set default target for systemd images SYSTEMD_DEFAULT_TARGET ?= '${@bb.utils.contains_any("IMAGE_FEATURES", [ "x11-base", "weston" ], "graphical.target", "multi-user.target", d)}' -ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "systemd", "set_systemd_default_target systemd_sysusers_check", "", d)}' +ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "systemd", "set_systemd_default_target systemd_sysusers_check systemd_handle_machine_id", "", d)}' ROOTFS_POSTPROCESS_COMMAND += 'empty_var_volatile'
@@ -173,6 +173,23 @@ python systemd_sysusers_check() { check_group_exists(d, sid) } +systemd_handle_machine_id() { + if ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false", d)}; then + # Create machine-id + # 20:12 < mezcalero> koen: you have three options: a) run systemd-machine-id-setup at install time, b) have / read-only and an empty file there (for stateless) and c) boot with / writable + touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id + fi + # In order to be backward compatible with the previous OE-core specific (re)implementation of systemctl + # we need to touch machine-id when handling presets and when the rootfs is NOT stateless + if ${@ 'true' if not bb.utils.contains('IMAGE_FEATURES', 'stateless-rootfs', True, False, d) else 'false'}; then + touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id + if [ -e ${IMAGE_ROOTFS}${root_prefix}/lib/systemd/systemd ]; then + systemctl --root="${IMAGE_ROOTFS}" --preset-mode=enable-only preset-all + systemctl --root="${IMAGE_ROOTFS}" --global --preset-mode=enable-only preset-all + fi + fi +} + # # A hook function to support read-only-rootfs IMAGE_FEATURES #
@@ -224,12 +241,6 @@ read_only_rootfs_hook () { ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh fi fi - - if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then - # Create machine-id - # 20:12 < mezcalero> koen: you have three options: a) run systemd-machine-id-setup at install time, b) have / read-only and an empty file there (for stateless) and c) boot with / writable - touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id - fi } #