Patchwork [1/3] rpm: redirect output of post install script

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

Comments

Kang Kai - Feb. 20, 2013, 6:16 a.m.
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 <kai.kang@windriver.com>
---
 .../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
Martin Donnelly - Feb. 21, 2013, 2:19 p.m.
On 20/02/2013 06:16, Kang Kai wrote:
> When distro feature "debug-tweak" enabled, redirect output of post
> install script to log file which can be configured.

Is the DISTRO_FEATURE not "debug-tweaks" here and not "debug-tweak"?

Martin
Kang Kai - Feb. 22, 2013, 10:49 a.m.
On 2013?02?21? 22:19, Martin Donnelly wrote:
> On 20/02/2013 06:16, Kang Kai wrote:
>> When distro feature "debug-tweak" enabled, redirect output of post
>> install script to log file which can be configured.
>
> Is the DISTRO_FEATURE not "debug-tweaks" here and not "debug-tweak"?

My mistake. It should be "debug-tweaks". Thanks.
I'll send new patches.

Regards,
Kai


>
> Martin
>

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 <kai.kang@windriver.com>
+
+--- 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"