mirror of
https://git.yoctoproject.org/poky
synced 2026-04-26 00:32:12 +02:00
classes-recipe: Consolidate machine-id handling
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. (From OE-Core rev: 890b81cdfadc427189eff4bbd2c24e32eb286126) Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
03b8e2ec1e
commit
2fe7f46e17
@@ -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 = ""
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user