Patchwork [3/3] opkg: save output of postinst scripts

login
register
mail settings
Submitter Kang Kai
Date Feb. 20, 2013, 6:16 a.m.
Message ID <374a69f7c77f05add8c0f09704923aaa948d08f9.1361265275.git.kai.kang@windriver.com>
Download mbox | patch
Permalink /patch/44907/
State New
Headers show

Comments

Kang Kai - Feb. 20, 2013, 6:16 a.m.
When has distro feature "debug-tweak", redirect output of postinstall
scripts to log file /var/log/postinstall.log. And the log file can be
configured.

[Yocto 3223]

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 .../opkg/opkg/redirect-output.patch                |   29 ++++++++++++++++++++
 meta/recipes-devtools/opkg/opkg_svn.bb             |    6 +++-
 2 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 meta/recipes-devtools/opkg/opkg/redirect-output.patch

Patch

diff --git a/meta/recipes-devtools/opkg/opkg/redirect-output.patch b/meta/recipes-devtools/opkg/opkg/redirect-output.patch
new file mode 100644
index 0000000..6710372
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/redirect-output.patch
@@ -0,0 +1,29 @@ 
+Upstream-Status: Inappropriate [other]
+
+This patch redirect output of post install script to a log file when
+distro feature "debug-tweak" enabled.
+
+[Yocto 3223]
+
+Signed-off-by: Kang Kai <kai.kang@windriver.com>
+
+--- trunk/libopkg/opkg_configure.c.orig	2013-02-18 15:00:42.715289097 +0800
++++ trunk/libopkg/opkg_configure.c	2013-02-18 15:01:43.971291259 +0800
+@@ -26,6 +26,7 @@ int
+ opkg_configure(pkg_t *pkg)
+ {
+     int err;
++    char buf[256];
+ 
+     /* DPKG_INCOMPATIBILITY:
+        dpkg actually does some conffile handling here, rather than at the
+@@ -33,7 +34,8 @@ opkg_configure(pkg_t *pkg)
+     /* DPKG_INCOMPATIBILITY:
+        dpkg actually includes a version number to this script call */
+ 
+-    err = pkg_run_script(pkg, "postinst", "configure");
++    sprintf(buf, "configure | tee %s", LOGFILE);
++    err = pkg_run_script(pkg, "postinst", buf);
+     if (err) {
+         if (!conf->offline_root)
+ 	     opkg_msg(ERROR, "%s.postinst returned %d.\n", pkg->name, err);
diff --git a/meta/recipes-devtools/opkg/opkg_svn.bb b/meta/recipes-devtools/opkg/opkg_svn.bb
index 382bfdd..164af88 100644
--- a/meta/recipes-devtools/opkg/opkg_svn.bb
+++ b/meta/recipes-devtools/opkg/opkg_svn.bb
@@ -3,10 +3,14 @@  require opkg.inc
 SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;protocol=http \
            file://obsolete_automake_macros.patch \
 "
+SRC_URI += "${@base_contains('DISTRO_FEATURES', 'debug-tweak', 'file://redirect-output.patch', '', d)}"
 
 S = "${WORKDIR}/trunk"
 
 SRCREV = "649"
 PV = "0.1.8+svnr${SRCPV}"
 
-PR = "${INC_PR}.0"
+PR = "${INC_PR}.1"
+
+POSTLOG ?= "/var/log/postinstall.log"
+CFLAGS_append += "${@base_contains('DISTRO_FEATURES', 'debug-tweak', ' -DLOGFILE=\'\"${POSTLOG}\"\'', '', d)}"