When distro feature "debug-tweak" enabled, redirect output of post
install script to log file which can be configured.

[Yocto 3223]

Signed-off-by: Kang Kai <[email protected]>
---
 .../recipes-devtools/rpm/rpm/redirect-output.patch |   38 ++++++++++++++++++++
 meta/recipes-devtools/rpm/rpm_5.4.9.bb             |    6 +++-
 2 files changed, 43 insertions(+), 1 deletions(-)
 create mode 100644 meta/recipes-devtools/rpm/rpm/redirect-output.patch

diff --git a/meta/recipes-devtools/rpm/rpm/redirect-output.patch 
b/meta/recipes-devtools/rpm/rpm/redirect-output.patch
new file mode 100644
index 0000000..1bc53dc
--- /dev/null
+++ b/meta/recipes-devtools/rpm/rpm/redirect-output.patch
@@ -0,0 +1,38 @@
+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 <[email protected]>
+
+--- rpm-5.4.9/lib/psm.c.orig   2013-02-18 11:34:19.646852294 +0800
++++ rpm-5.4.9/lib/psm.c        2013-02-18 13:18:00.291071721 +0800
+@@ -1111,6 +1111,14 @@ assert(he->p.str != NULL);
+           if (ssp != NULL)
+               *ssp |= RPMSCRIPT_STATE_EXEC;
+ 
++#ifdef RPM_VENDOR_POKY
++          int fd = open(LOGFILE, O_RDWR|O_CREAT|O_APPEND, 
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
++          if (psm->scriptTag == RPMTAG_POSTIN && fd != -1) {
++              dup2(fd, STDERR_FILENO);
++              dup2(fd, STDOUT_FILENO);
++          }
++#endif
++
+           /* Permit libselinux to do the scriptlet exec. */
+           if (rpmtsSELinuxEnabled(ts) == 1) { 
+               if (ssp != NULL)
+@@ -1121,6 +1129,11 @@ assert(he->p.str != NULL);
+               xx = execv(argv[0], (char *const *)argv);
+ /*@=nullstate@*/
+           }
++
++#ifdef RPM_VENDOR_POKY
++          if (fd)
++              close(fd);
++#endif
+       }
+ 
+       if (ssp != NULL)
diff --git a/meta/recipes-devtools/rpm/rpm_5.4.9.bb 
b/meta/recipes-devtools/rpm/rpm_5.4.9.bb
index 39b0481..dc43678 100644
--- a/meta/recipes-devtools/rpm/rpm_5.4.9.bb
+++ b/meta/recipes-devtools/rpm/rpm_5.4.9.bb
@@ -43,7 +43,7 @@ LICENSE = "LGPLv2.1"
 LIC_FILES_CHKSUM = "file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1"
 
 DEPENDS = "libpcre attr acl popt ossp-uuid file bison-native"
-PR = "r61"
+PR = "r62"
 
 # rpm2cpio is a shell script, which is part of the rpm src.rpm.  It is needed
 # in order to extract the distribution SRPM into a format we can extract...
@@ -85,6 +85,7 @@ SRC_URI = 
"http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex
           file://rpm-reloc-macros.patch \
           file://rpm-platform2.patch \
      file://rpm-remove-sykcparse-decl.patch \
+          ${@base_contains('DISTRO_FEATURES', 'debug-tweak', 
'file://redirect-output.patch', '', d)} \
          "
 
 # Uncomment the following line to enable platform score debugging
@@ -197,6 +198,9 @@ EXTRA_OECONF += "--verbose \
 
 CFLAGS_append = " -DRPM_VENDOR_WINDRIVER -DRPM_VENDOR_POKY -DRPM_VENDOR_OE"
 
+POSTLOG ?= "/var/log/postinstall.log"
+CFLAGS_append += "${@base_contains('DISTRO_FEATURES', 'debug-tweak', ' 
-DLOGFILE=\'\"${POSTLOG}\"\'', '', d)}"
+
 LDFLAGS_append_libc-uclibc = "-lrt -lpthread"
 
 PACKAGES = "${PN}-dbg ${PN} ${PN}-doc ${PN}-libs ${PN}-dev ${PN}-staticdev 
${PN}-common ${PN}-build python-rpm-dbg python-rpm-staticdev python-rpm-dev 
python-rpm perl-module-rpm perl-module-rpm-dev ${PN}-locale"
-- 
1.7.5.4


_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Reply via email to