Patchwork [10/12] busybox: simplify update-rc.d OPT handling

login
register
mail settings
Submitter Bernhard Reutner-Fischer
Date Jan. 3, 2011, 8:02 p.m.
Message ID <1294084926-3115-10-git-send-email-rep.dot.nop@gmail.com>
Download mbox | patch
Permalink /patch/156/
State Accepted
Headers show

Comments

Bernhard Reutner-Fischer - Jan. 3, 2011, 8:02 p.m.
style-only change

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 recipes/busybox/busybox.inc |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)
Roman Khimov - Jan. 3, 2011, 8:30 p.m.
? ????????? ?? ??????????? 03 ?????? 2011 23:02:04 ????? Bernhard Reutner-
Fischer ???????:
> -	if test "x$D" != "x"; then
> -		OPT="-r $D"
> -	else
> -		OPT="-s"
> -	fi
> +	[ -n "$D" ] && OPT="-r $D" || OPT="-s"

I have a strong feeling that this is wrong. Yeah, the first one takes up five 
times more lines but to me it's about five times easier to parse glancing over 
the recipe.

Also, from what I heard '"x$D" != "x"' tests are the most portable ones.
Bernhard Reutner-Fischer - Jan. 3, 2011, 9:09 p.m.
On Mon, Jan 03, 2011 at 11:30:21PM +0300, Roman I Khimov wrote:
>? ????????? ?? ??????????? 03 ?????? 2011 23:02:04 ????? Bernhard Reutner-
>Fischer ???????:
>> -	if test "x$D" != "x"; then
>> -		OPT="-r $D"
>> -	else
>> -		OPT="-s"
>> -	fi
>> +	[ -n "$D" ] && OPT="-r $D" || OPT="-s"
>
>I have a strong feeling that this is wrong. Yeah, the first one takes up five 
>times more lines but to me it's about five times easier to parse glancing over 
>the recipe.
>
>Also, from what I heard '"x$D" != "x"' tests are the most portable ones.

It is more portable, yes. But given that test(1) is required to support
both -n and -z even in SUSv3 -- and still is in SUSv4 and i doubt this
fact will change anytime soon -- it's sane to assume it works.

ok?
Otavio Salvador - Jan. 13, 2011, 10:17 p.m.
Acked-by: Otavio Salvador <otavio@ossystems.com.br>

On Mon, Jan 3, 2011 at 18:02, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> style-only change
>
> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
> ---
>  recipes/busybox/busybox.inc |   12 ++----------
>  1 files changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/recipes/busybox/busybox.inc b/recipes/busybox/busybox.inc
> index 59653e0..b105337 100644
> --- a/recipes/busybox/busybox.inc
> +++ b/recipes/busybox/busybox.inc
> @@ -291,11 +291,7 @@ pkg_prerm_${PN}-shadow () {
>  pkg_postinst_${PN}-syslog () {
>        update-alternatives --install ${sysconfdir}/init.d/syslog syslog-init syslog.${PN} 50
>
> -       if test "x$D" != "x"; then
> -               OPT="-r $D"
> -       else
> -               OPT="-s"
> -       fi
> +       [ -n "$D" ] && OPT="-r $D" || OPT="-s"
>        # remove all rc.d-links potentially created from alternative
>        # syslog packages before creating new ones
>        update-rc.d $OPT -f syslog remove
> @@ -313,13 +309,9 @@ pkg_prerm_${PN}-syslog () {
>  }
>
>  pkg_postrm_${PN}-syslog () {
> -       if test "x$D" != "x"; then
> -               OPT="-r $D"
> -       else
> -               OPT=""
> -       fi
>        if test "$1" = "remove" -o "$1" = "purge"; then
>                if ! test -e "/etc/init.d/syslog"; then
> +                       [ -n "$D" ] && OPT="-r $D" || OPT="-s"
>                        update-rc.d $OPT syslog remove
>                fi
>        fi
> --
> 1.7.2.3
>
>
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
>

Patch

diff --git a/recipes/busybox/busybox.inc b/recipes/busybox/busybox.inc
index 59653e0..b105337 100644
--- a/recipes/busybox/busybox.inc
+++ b/recipes/busybox/busybox.inc
@@ -291,11 +291,7 @@  pkg_prerm_${PN}-shadow () {
 pkg_postinst_${PN}-syslog () {
 	update-alternatives --install ${sysconfdir}/init.d/syslog syslog-init syslog.${PN} 50
 
-	if test "x$D" != "x"; then
-		OPT="-r $D"
-	else
-		OPT="-s"
-	fi
+	[ -n "$D" ] && OPT="-r $D" || OPT="-s"
 	# remove all rc.d-links potentially created from alternative
 	# syslog packages before creating new ones
 	update-rc.d $OPT -f syslog remove
@@ -313,13 +309,9 @@  pkg_prerm_${PN}-syslog () {
 }
 
 pkg_postrm_${PN}-syslog () {
-	if test "x$D" != "x"; then
-		OPT="-r $D"
-	else
-		OPT=""
-	fi
 	if test "$1" = "remove" -o "$1" = "purge"; then
 		if ! test -e "/etc/init.d/syslog"; then
+			[ -n "$D" ] && OPT="-r $D" || OPT="-s"
 			update-rc.d $OPT syslog remove
 		fi
 	fi