Patchwork [V3,1/4] image.bbclass: add postinst_enable_logging

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date May 21, 2013, 8:12 a.m.
Message ID <f0ba8e93dd5d81375864f8c092a1d189a43a5f18.1369123754.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/50217/
State New
Headers show

Comments

Qi.Chen@windriver.com - May 21, 2013, 8:12 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

Add a function postinst_enable_logging, so that when 'debug-tweaks'
is in IMAGE_FEATURES, we create /etc/default/postinst config file,
which is sourced by run-postinst scripts to determine whether to log
or not, and where to log.

[YOCTO #4262]

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

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 4f07708..c7eedd4 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -175,6 +175,10 @@  MACHINE_POSTPROCESS_COMMAND ?= ""
 ROOTFS_POSTPROCESS_COMMAND_prepend = "run_intercept_scriptlets; "
 # Allow dropbear/openssh to accept logins from accounts with an empty password string if debug-tweaks is enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "ssh_allow_empty_password; ", "",d)}'
+# Enable postinst logging if debug-tweaks is enabled
+ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "postinst_enable_logging; ", "",d)}'
+# Set default postinst log file
+POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log"
 
 # some default locales
 IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
@@ -484,6 +488,13 @@  ssh_allow_empty_password () {
 	fi
 }
 
+# Enable postinst logging if debug-tweaks is enabled
+postinst_enable_logging () {
+	mkdir -p ${IMAGE_ROOTFS}/etc/default
+	echo "POSTINST_LOGGING=1" >> ${IMAGE_ROOTFS}/etc/default/postinst
+	echo "LOGFILE=${POSTINST_LOGFILE}" >> ${IMAGE_ROOTFS}/etc/default/postinst
+}
+
 # Turn any symbolic /sbin/init link into a file
 remove_init_link () {
 	if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then