Redirect output of post-install scripts when "debug-tweak" enabled
cover Redirect output of post-install scripts when "debug-tweak" enabled
The following changes since commit c7b23ab68aafc04d9830ef318015912e5d4f0672:
maintainers.inc: update ownership of recipes (2013-02-17 22:33:30 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib kangkai/redirect-postinst
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/redirect-postinst
Kang Kai (3):
rpm: redirect output of post install script
dpkg: redirect output of postinstall script
opkg: save output of postinst scripts
.../dpkg/dpkg/redirect-output.patch | 37 +++++++++++++++++++ meta/recipes-devtools/dpkg/dpkg_1.16.9.bb | 8 +++- .../opkg/opkg/redirect-output.patch | 29 +++++++++++++++ meta/recipes-devtools/opkg/opkg_svn.bb | 6 +++- .../recipes-devtools/rpm/rpm/redirect-output.patch | 38 ++++++++++++++++++++ meta/recipes-devtools/rpm/rpm_5.4.9.bb | 6 +++- 6 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 meta/recipes-devtools/dpkg/dpkg/redirect-output.patch create mode 100644 meta/recipes-devtools/opkg/opkg/redirect-output.patch create mode 100644 meta/recipes-devtools/rpm/rpm/redirect-output.patch
Signature · 1 line
1.7.5.4
PATCH 1/3 rpm: redirect output of post install script
When distro feature "debug-tweak" enabled, redirect output of post install script to log file which can be configured.
[Yocto 3223]
--- .../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
meta/recipes-devtools/rpm/rpm/redirect-output.patch new file +38 -0
@@ -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)
meta/recipes-devtools/rpm/rpm_5.4.9.bb +5 -1
@@ -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"
Signature · 1 line
1.7.5.4
PATCH 2/3 dpkg: redirect output of postinstall script
In reply to Kang KaiWhen distro feature "debug-tweak" enabled, redirect output of postinstall script to log file /var/log/postinstall.log which can be configured.
[Yocto 3223]
--- .../dpkg/dpkg/redirect-output.patch | 37 ++++++++++++++++++++ meta/recipes-devtools/dpkg/dpkg_1.16.9.bb | 8 +++- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-devtools/dpkg/dpkg/redirect-output.patch
meta/recipes-devtools/dpkg/dpkg/redirect-output.patch new file +37 -0
@@ -0,0 +1,37 @@ +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]> + +--- dpkg-1.16.9/src/script.c.orig 2013-02-19 16:05:33.154474040 +0800 ++++ dpkg-1.16.9/src/script.c 2013-02-19 16:11:20.438486290 +0800 +@@ -30,6 +30,7 @@ + #include <string.h> + #include <unistd.h> + #include <stdlib.h> ++#include <fcntl.h> + + #include <dpkg/i18n.h> + #include <dpkg/dpkg.h> +@@ -193,8 +166,17 @@ vmaintainer_script_installed(struct pkgi + } + ohshite(_("unable to stat %s `%.250s'"), buf, scriptpath); + } ++ ++ int fd = open(LOGFILE, O_RDWR|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); ++ if (strcmp(desc, "post-installation") == 0 && fd != -1) { ++ dup2(fd, STDERR_FILENO); ++ dup2(fd, STDOUT_FILENO); ++ } + do_script(pkg, &pkg->installed, &cmd, &stab, 0); + ++ if (fd) ++ close(fd); ++ + command_destroy(&cmd); + + return 1;
meta/recipes-devtools/dpkg/dpkg_1.16.9.bb +6 -2
@@ -6,9 +6,13 @@ SRC_URI += "file://noman.patch \ file://check_version.patch \ file://preinst.patch \ file://fix-timestamps.patch \ - file://remove-tar-no-timestamp.patch" + file://remove-tar-no-timestamp.patch \ + ${@base_contains('DISTRO_FEATURES', 'debug-tweak', 'file://redirect-output.patch', '', d)}" + +POSTLOG ?= "/var/log/postinstall.log" +CFLAGS_append += "${@base_contains('DISTRO_FEATURES', 'debug-tweak', ' -DLOGFILE=\'\"${POSTLOG}\"\'', '', d)}" SRC_URI[md5sum] = "4df9319b2d17e19cdb6fe94dacee44da" SRC_URI[sha256sum] = "73cd7fba4e54acddd645346b4bc517030b9c35938e82215d3eeb8b4e7af26b7a" -PR = "${INC_PR}.0" +PR = "${INC_PR}.1"
Signature · 1 line
1.7.5.4
PATCH 3/3 opkg: save output of postinst scripts
In reply to Kang KaiWhen 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]
--- .../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
meta/recipes-devtools/opkg/opkg/redirect-output.patch new file +29 -0
@@ -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 <[email protected]> + +--- 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);
meta/recipes-devtools/opkg/opkg_svn.bb +5 -1
@@ -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)}"
Signature · 1 line
1.7.5.4
Re: [PATCH 1/3] rpm: redirect output of post install script
In reply to Kang KaiQuoted 2 lines · Kang Kai
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
Re: [PATCH 1/3] rpm: redirect output of post install script
Quoted 5 lines · Martin Donnelly
Quoted 2 lines · Kang Kai
When distro feature "debug-tweak" enabled, redirect output of post install script to log file which can be configured.
Is the
DISTRO_FEATUREnot "debug-tweaks" here and not "debug-tweak"?
My mistake. It should be "debug-tweaks". Thanks.
I'll send new patches.
Regards,
Kai
Quoted 3 lines
Martin