Patchwork [V2,2/4] dpkg: modify the run-postinst script to enable postinst logging

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date May 20, 2013, 2:50 a.m.
Message ID <87754446fd070cded9dee7bff2b18d0f080be934.1369018014.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/50123/
State New
Headers show

Comments

Qi.Chen@windriver.com - May 20, 2013, 2:50 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

Enable postinst logging by checking the configuration in /etc/
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]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-devtools/dpkg/dpkg.inc |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
Paul Eggleton - May 20, 2013, 4:09 p.m.
On Monday 20 May 2013 10:50:29 Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
> 
> Enable postinst logging by checking the configuration in /etc/
> 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]
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  meta/recipes-devtools/dpkg/dpkg.inc |   11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/meta/recipes-devtools/dpkg/dpkg.inc
> b/meta/recipes-devtools/dpkg/dpkg.inc index d773fbd..c5c8aec 100644
> --- a/meta/recipes-devtools/dpkg/dpkg.inc
> +++ b/meta/recipes-devtools/dpkg/dpkg.inc
> @@ -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 /etc/default/postinst ] && . /etc/default/postinst
> +if [ \"\$POSTINST_LOGGING\" = \"ENABLED\" ]; then

Can we use 1 for this instead of ENABLED? This would be more consistent with 
how variables such as this are generally used.

Cheers,
Paul
Qi.Chen@windriver.com - May 21, 2013, 2:25 a.m.
On 05/21/2013 12:09 AM, Paul Eggleton wrote:
> On Monday 20 May 2013 10:50:29 Qi.Chen@windriver.com wrote:
>> From: Chen Qi <Qi.Chen@windriver.com>
>>
>> Enable postinst logging by checking the configuration in /etc/
>> 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]
>>
>> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>> ---
>>   meta/recipes-devtools/dpkg/dpkg.inc |   11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/meta/recipes-devtools/dpkg/dpkg.inc
>> b/meta/recipes-devtools/dpkg/dpkg.inc index d773fbd..c5c8aec 100644
>> --- a/meta/recipes-devtools/dpkg/dpkg.inc
>> +++ b/meta/recipes-devtools/dpkg/dpkg.inc
>> @@ -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 /etc/default/postinst ] && . /etc/default/postinst
>> +if [ \"\$POSTINST_LOGGING\" = \"ENABLED\" ]; then
> Can we use 1 for this instead of ENABLED? This would be more consistent with
> how variables such as this are generally used.
>
> Cheers,
> Paul
>
Thanks, I'll do that and send out a v3 soon.

Best Regards,
Chen Qi

Patch

diff --git a/meta/recipes-devtools/dpkg/dpkg.inc b/meta/recipes-devtools/dpkg/dpkg.inc
index d773fbd..c5c8aec 100644
--- a/meta/recipes-devtools/dpkg/dpkg.inc
+++ b/meta/recipes-devtools/dpkg/dpkg.inc
@@ -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 /etc/default/postinst ] && . /etc/default/postinst
+if [ \"\$POSTINST_LOGGING\" = \"ENABLED\" ]; then
+    dpkg --configure -a >/var/log/postinstall.log 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