Postinst logging reimplementation
v4 cover Postinst logging reimplementation
From: Chen Qi <[email protected]>
Goal:
1. Enable postinst logging if 'debug-tweaks' is in IMAGE_FEATURES
2. Make rpm, opkg and dpkg not depend on IMAGE_FEATURES and POSTLOG
Implementation:
1. The run-postinst scripts will log outputs by checking the configuration in ${sysconfdir}/default/postinst.
2. The log location is by default ${localstatedir}/log/postinstall.log.
But it could be configured to a different location.
The following changes since commit 21089515bd18ba18e86ec8f72ff8141b9fb1dea8:
ref-manual: Added xmlto and dblatex packages for docs (2013-05-22 17:23:41 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib ChenQi/postinst-logging-reimplementation
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/postinst-logging-reimplementation
Chen Qi (4):
image.bbclass: add postinst_enable_logging
dpkg: modify the run-postinst script to enable postinst logging
opkg: modify the run-postinst script to enable postinst logging rpm-postinsts.bb: enable postinst logging
meta/classes/image.bbclass | 11 +++++++++++ meta/recipes-devtools/dpkg/dpkg.inc | 11 ++++++----- meta/recipes-devtools/opkg/opkg.inc | 7 ++++++- meta/recipes-devtools/rpm/rpm-postinsts.bb | 17 +++++++++-------- 4 files changed, 32 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v4 1/4 image.bbclass: add postinst_enable_logging
From: Chen Qi <[email protected]>
Add a function postinst_enable_logging, so that when 'debug-tweaks' is in IMAGE_FEATURES, we create ${sysconfdir}/default/postinst config file, which is sourced by run-postinst scripts to determine whether to log or not, and where to log.
[YOCTO #4262]
--- meta/classes/image.bbclass | 11 +++++++++++ 1 file changed, 11 insertions(+)
meta/classes/image.bbclass +11 -0
@@ -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}${sysconfdir}/default + echo "POSTINST_LOGGING=1" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst + echo "LOGFILE=${POSTINST_LOGFILE}" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst +} + # Turn any symbolic /sbin/init link into a file remove_init_link () { if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then
Signature · 1 line
1.7.9.5
PATCH v4 2/4 dpkg: modify the run-postinst script to enable postinst logging
In reply to [email protected]From: Chen Qi <[email protected]>
Enable postinst logging by checking the configuration in ${sysconfdir} /default/postinst.
In this way, the postinst logging is enabled if 'debug-tweaks' is in IMAGE_FEATURES, and at the same time, we avoid unnecessary rebuilt if IMAGE_FEATURES is changed.
[YOCTO #4262]
--- meta/recipes-devtools/dpkg/dpkg.inc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
meta/recipes-devtools/dpkg/dpkg.inc +6 -5
@@ -35,10 +35,6 @@ do_configure () { autotools_do_configure } -POSTLOG ?= "/var/log/postinstall.log" -REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG} 2>&1', '', d)}" -REDIRECT_CMD[vardepsexclude] += "IMAGE_FEATURES POSTLOG" - DPKG_INIT_POSITION ?= "98" do_install_append () {
@@ -67,7 +63,12 @@ if [ "x$D" != "x" ] && [ -f $D/var/lib/dpkg/status ]; then # this happens at S98 where our good 'ole packages script used to run echo "#!/bin/sh -dpkg --configure -a ${REDIRECT_CMD} +[ -e ${sysconfdir}/default/postinst ] && . ${sysconfdir}/default/postinst +if [ \"\$POSTINST_LOGGING\" = \"1\" ]; then + dpkg --configure -a >\$LOGFILE 2>&1 +else + dpkg --configure -a +fi rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts " > $D${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts chmod 0755 $D${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
Signature · 1 line
1.7.9.5
PATCH v4 3/4 opkg: modify the run-postinst script to enable postinst logging
In reply to [email protected]From: Chen Qi <[email protected]>
Enable postinst logging by checking the configuration in ${sysconfdir} /default/postinst.
In this way, the postinst logging is enabled if 'debug-tweaks' is in IMAGE_FEATURES, and at the same time, we avoid unnecessary rebuilt if IMAGE_FEATURES is changed.
[YOCTO #4262]
--- meta/recipes-devtools/opkg/opkg.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
meta/recipes-devtools/opkg/opkg.inc +6 -1
@@ -68,7 +68,12 @@ if [ "x$D" != "x" ] && [ -f $D${OPKGLIBDIR}/opkg/status ]; then # this happens at S98 where our good 'ole packages script used to run echo "#!/bin/sh -opkg-cl configure ${REDIRECT_CMD} +[ -e ${sysconfdir}/default/postinst ] && . ${sysconfdir}/default/postinst +if [ \"\$POSTINST_LOGGING\" = \"1\" ]; then + opkg-cl configure >\$LOGFILE 2>&1 +else + opkg-cl configure +fi rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts " > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts chmod 0755 $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
Signature · 1 line
1.7.9.5
PATCH v4 4/4 rpm-postinsts.bb: enable postinst logging
In reply to [email protected]From: Chen Qi <[email protected]>
Enable postinst logging by checking the configuration in ${sysconfdir} /default/postinst.
In this way, the postinst logging is enabled if 'debug-tweaks' is in IMAGE_FEATURES, and at the same time, we avoid unnecessary rebuild if IMAGE_FEATURES is changed.
[YOCTO #4262]
--- meta/recipes-devtools/rpm/rpm-postinsts.bb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
meta/recipes-devtools/rpm/rpm-postinsts.bb +9 -8
@@ -9,10 +9,6 @@ inherit allarch # POSTINSTALL_INITPOSITION ?= "98" -POSTLOG ?= "/var/log/postinstall.log" -REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>>${POSTLOG} 2>&1', '', d)}" -REDIRECT_CMD[vardepsexclude] += "IMAGE_FEATURES POSTLOG" - do_fetch() { : }
@@ -34,11 +30,16 @@ if [ "x$D" != "x" ] && [ -f $D/var/lib/rpm/Packages ]; then install -d $D/${sysconfdir}/rcS.d cat > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << "EOF" #!/bin/sh - -[ -d /etc/rpm-postinsts ] && for i in `ls /etc/rpm-postinsts/`; do - i=/etc/rpm-postinsts/$i +[ -e ${sysconfdir}/default/postinst ] && . ${sysconfdir}/default/postinst +[ -d ${sysconfdir}/rpm-postinsts ] && for i in `ls ${sysconfdir}/rpm-postinsts/`; do + i=${sysconfdir}/rpm-postinsts/$i echo "Running postinst $i..." - if [ -f $i ] && $i ${REDIRECT_CMD}; then + if [ -x $i ]; then + if [ "$POSTINST_LOGGING" = "1" ]; then + $i >>$LOGFILE 2&>1 + else + $i + fi rm $i else echo "ERROR: postinst $i failed."
Signature · 1 line
1.7.9.5