[OE-core] [PATCH 1/1] image.bbclass: add ability to set systemd default target

Qi.Chen at windriver.com Qi.Chen at windriver.com
Tue Dec 17 09:05:20 UTC 2013


From: Chen Qi <Qi.Chen at windriver.com>

Add ability to set the default target for systemd images.

The default value for the target is derived from checking whether
IMAGE_FEATRUES contains 'x11-base' or not. Each image could override
this value in its own recipe. For now, we don't need to do any change,
because all images that support graphical environment has 'x11-base'
in its IMAGE_FEATRUES.

[YOCTO #3816]

Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
---
 meta/classes/image.bbclass |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index c595721..c8366d6 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -186,6 +186,9 @@ IMAGE_MANIFEST = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest"
 ROOTFS_POSTPROCESS_COMMAND =+ "write_image_manifest ; "
 # Set default postinst log file
 POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log"
+# Set default target for systemd images
+SYSTEMD_DEFAULT_TARGET ?= '${@base_contains("IMAGE_FEATURES", "x11-base", "graphical.target", "multi-user.target", d)}'
+ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("DISTRO_FEATURES", "systemd", "set_systemd_default_target; ", "", d)}'
 
 # some default locales
 IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
@@ -596,6 +599,11 @@ postinst_enable_logging () {
 	echo "LOGFILE=${POSTINST_LOGFILE}" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst
 }
 
+# Modify systemd default target
+set_systemd_default_target () {
+	ln -sf ${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET} ${IMAGE_ROOTFS}${sysconfdir}/systemd/system/default.target
+}
+
 # Turn any symbolic /sbin/init link into a file
 remove_init_link () {
 	if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then
-- 
1.7.9.5




More information about the Openembedded-core mailing list