Skip to contentSkip to conversation

bash: add alternative configuration for bin/sh -> /bin/bash

PATCH In review Tim Harvey 3 participants 7 messages Mar 27, 2009 – Apr 1, 2009

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH 1/1 bash: add alternative configuration for bin/sh -> /bin/bash

Add alternative configuration for /bin/sh -> /bin/bash so that for example bash can exist (and override) as shell if busybox is also installed

recipes/bash/bash.inc +0 -0
index 4eba689..7c6122b 100644
@@ -4,7 +4,7 @@ DEPENDS = "ncurses"

SECTION = "base/shell"
LICENSE = "GPL"

-inherit autotools gettext
+inherit autotools gettext update-alternatives

PARALLEL_MAKE = ""

@@ -33,3 +33,8 @@ pkg_postinst () {
       grep -q "bin/bash" $D${sysconfdir}/shells || echo /bin/bash >> 
$D${sysconfdir}/shells
       grep -q "bin/sh" $D${sysconfdir}/shells || echo /bin/sh >> 

$D${sysconfdir}/shells
}
+
+ALTERNATIVE_NAME = "sh"
+ALTERNATIVE_LINK = "${base_bindir}/sh"
+ALTERNATIVE_PATH = "${base_bindir}/bash"
+ALTERNATIVE_PRIORITY = "90"

recipes/bash/bash_3.0.bb +0 -0
index e23887a..8165d07 100644
@@ -1,5 +1,5 @@

require bash.inc
-PR = "r11"
+PR = "r12"

SRC_URI += "\
file://bash-3.0-fixes.patch;patch=1 \

recipes/bash/bash_3.2.bb +0 -0
index 6a48a4b..e175467 100644
@@ -1,6 +1,6 @@

require bash.inc

-PR = "r7"
+PR = "r8"

SRC_URI += "\
           file://builtins.patch;patch=1 \
#1 lore raw

Be very careful with this. Specifically, be sure to thoroughly test installing bash onto a system that currently has busybox, and the upgrade paths for both busybox and bash. You never want to get into a state, due to pre/post rm/install script execution order, where /bin/sh doesn't exist. If that happens, you won't be able to execute the next script to fix it :)

Quoted 57 lines · Tim Harvey

Add alternative configuration for /bin/sh -> /bin/bash so that for example bash can exist (and override) as shell if busybox is also installed

recipes/bash/bash.inc +0 -0
index 4eba689..7c6122b 100644
@@ -4,7 +4,7 @@ DEPENDS = "ncurses"

SECTION = "base/shell"
LICENSE = "GPL"

recipes/bash/bash.inc +1 -1
-inherit autotools gettext
+inherit autotools gettext update-alternatives

PARALLEL_MAKE = ""

recipes/bash/bash.inc +0 -0
@@ -33,3 +33,8 @@ pkg_postinst () {

      grep -q "bin/bash" $D${sysconfdir}/shells || echo /bin/bash >> $D${sysconfdir}/shells
      grep -q "bin/sh" $D${sysconfdir}/shells || echo /bin/sh >> $D${sysconfdir}/shells
}

recipes/bash/bash.inc +5 -0
+
+ALTERNATIVE_NAME = "sh"
+ALTERNATIVE_LINK = "${base_bindir}/sh"
+ALTERNATIVE_PATH = "${base_bindir}/bash"
+ALTERNATIVE_PRIORITY = "90"
recipes/bash/bash_3.0.bb +0 -0
index e23887a..8165d07 100644
@@ -1,5 +1,5 @@

require bash.inc

recipes/bash/bash_3.0.bb +1 -1
-PR = "r11"
+PR = "r12"

SRC_URI += "\
 file://bash-3.0-fixes.patch;patch=1 \

recipes/bash/bash_3.2.bb +0 -0
index 6a48a4b..e175467 100644
@@ -1,6 +1,6 @@

require bash.inc

recipes/bash/bash_3.2.bb +1 -1
-PR = "r7"
+PR = "r8"

SRC_URI += "\
          file://builtins.patch;patch=1 \

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

Signature · 7 lines
Chris Larson
clarson at kergoth dot com
clarson at mvista dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Software Engineer
MontaVista Software, Inc.
#2 lore raw
Quoted 6 lines · Chris Larson

Be very careful with this. Specifically, be sure to thoroughly test installing bash onto a system that currently has busybox, and the upgrade paths for both busybox and bash. You never want to get into a state, due to pre/post rm/install script execution order, where /bin/sh doesn't exist. If that happens, you won't be able to execute the next script to fix it :)

And we actually have busyboxisms in some scripts, you can't launch e-wm due to the OE wrapper script (which isn't needed anymore, btw) breaking with bash.

regards,

Koen

Quoted 62 lines · Tim Harvey
Quoted 57 lines

Add alternative configuration for /bin/sh -> /bin/bash so that for example bash can exist (and override) as shell if busybox is also installed

recipes/bash/bash.inc +0 -0
index 4eba689..7c6122b 100644
@@ -4,7 +4,7 @@ DEPENDS = "ncurses"

SECTION = "base/shell"
LICENSE = "GPL"

recipes/bash/bash.inc +1 -1
-inherit autotools gettext
+inherit autotools gettext update-alternatives

PARALLEL_MAKE = ""

recipes/bash/bash.inc +0 -0
@@ -33,3 +33,8 @@ pkg_postinst () {
       grep -q "bin/bash" $D${sysconfdir}/shells || echo /bin/bash>>

$D${sysconfdir}/shells

       grep -q "bin/sh" $D${sysconfdir}/shells || echo /bin/sh>>

$D${sysconfdir}/shells
}

recipes/bash/bash.inc +5 -0
+
+ALTERNATIVE_NAME = "sh"
+ALTERNATIVE_LINK = "${base_bindir}/sh"
+ALTERNATIVE_PATH = "${base_bindir}/bash"
+ALTERNATIVE_PRIORITY = "90"
recipes/bash/bash_3.0.bb +0 -0
index e23887a..8165d07 100644
@@ -1,5 +1,5 @@

require bash.inc

recipes/bash/bash_3.0.bb +1 -1
-PR = "r11"
+PR = "r12"

SRC_URI += "\
file://bash-3.0-fixes.patch;patch=1 \

recipes/bash/bash_3.2.bb +0 -0
index 6a48a4b..e175467 100644
@@ -1,6 +1,6 @@

require bash.inc

recipes/bash/bash_3.2.bb +1 -1
-PR = "r7"
+PR = "r8"
SRC_URI += "\
           file://builtins.patch;patch=1 \

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

author
#3 lore raw
In reply to Chris Larson
Quoted 7 lines · Chris Larson

Be very careful with this. Specifically, be sure to thoroughly test installing bash onto a system that currently has busybox, and the upgrade paths for both busybox and bash. You never want to get into a state, due to pre/post rm/install script execution order, where /bin/sh doesn't exist. If that happens, you won't be able to execute the next script to fix it :)

in my case, I have both bash and busybox installed and I want bash to take priority as the /bin/sh which it otherwise does not.

attempting to remove the package that contains your shell is something you need to be careful as anyway.

This seems to me to be a prime example of where alternatives should be used?

Tim

Quoted 64 lines · Tim Harvey
Quoted 59 lines

Add alternative configuration for /bin/sh -> /bin/bash so that for example bash can exist (and override) as shell if busybox is also installed

recipes/bash/bash.inc +0 -0
index 4eba689..7c6122b 100644
@@ -4,7 +4,7 @@ DEPENDS = "ncurses"

SECTION = "base/shell"
LICENSE = "GPL"

recipes/bash/bash.inc +1 -1
-inherit autotools gettext
+inherit autotools gettext update-alternatives

PARALLEL_MAKE = ""

recipes/bash/bash.inc +0 -0
@@ -33,3 +33,8 @@ pkg_postinst () {
      grep -q "bin/bash" $D${sysconfdir}/shells || echo /bin/bash >>

$D${sysconfdir}/shells

      grep -q "bin/sh" $D${sysconfdir}/shells || echo /bin/sh >>

$D${sysconfdir}/shells
}

recipes/bash/bash.inc +5 -0
+
+ALTERNATIVE_NAME = "sh"
+ALTERNATIVE_LINK = "${base_bindir}/sh"
+ALTERNATIVE_PATH = "${base_bindir}/bash"
+ALTERNATIVE_PRIORITY = "90"
recipes/bash/bash_3.0.bb +0 -0
index e23887a..8165d07 100644
@@ -1,5 +1,5 @@

require bash.inc

recipes/bash/bash_3.0.bb +1 -1
-PR = "r11"
+PR = "r12"

SRC_URI += "\
file://bash-3.0-fixes.patch;patch=1 \

recipes/bash/bash_3.2.bb +0 -0
index 6a48a4b..e175467 100644
@@ -1,6 +1,6 @@

require bash.inc

recipes/bash/bash_3.2.bb +1 -1
-PR = "r7"
+PR = "r8"
SRC_URI += "\
          file://builtins.patch;patch=1 \

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

#4 lore raw
Quoted 10 lines · Tim Harvey
Quoted 8 lines · Chris Larson

Be very careful with this.  Specifically, be sure to thoroughly test installing bash onto a system that currently has busybox, and the upgrade paths for both busybox and bash.  You never want to get into a state, due to pre/post rm/install script execution order, where /bin/sh doesn't exist.  If that happens, you won't be able to execute the next script to fix it :)

Quoted 7 lines

in my case, I have both bash and busybox installed and I want bash to take priority as the /bin/sh which it otherwise does not.

attempting to remove the package that contains your shell is something you need to be careful as anyway.

This seems to me to be a prime example of where alternatives should be used?

You missed my point, it seems. I was talking about update-alternatives. Depending on how update-alternatives is implemented, there could be issues similar to what I mentioned in the previous email. Consider: if it uses system(), which calls /bin/sh, to remove the old /bin/sh link, and then calls system() again to create the new, it will fail. Speculation, but again, it's something you always need to keep in mind if you're messing with /bin/sh in any way.

Signature · 7 lines
Chris Larson
clarson at kergoth dot com
clarson at mvista dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Software Engineer
MontaVista Software, Inc.
#5 lore raw
Quoted 19 lines · Chris Larson
Quoted 10 lines · Tim Harvey
Quoted 8 lines · Chris Larson

Be very careful with this. Specifically, be sure to thoroughly test installing bash onto a system that currently has busybox, and the upgrade paths for both busybox and bash. You never want to get into a state, due to pre/post rm/install script execution order, where /bin/sh doesn't exist. If that happens, you won't be able to execute the next script to fix it :)

Quoted 7 lines

in my case, I have both bash and busybox installed and I want bash to take priority as the /bin/sh which it otherwise does not.

attempting to remove the package that contains your shell is something you need to be careful as anyway.

This seems to me to be a prime example of where alternatives should be used?

Quoted 8 lines

You missed my point, it seems. I was talking about update-alternatives. Depending on how update-alternatives is implemented, there could be issues similar to what I mentioned in the previous email. Consider: if it uses system(), which calls /bin/sh, to remove the old /bin/sh link, and then calls system() again to create the new, it will fail. Speculation, but again, it's something you always need to keep in mind if you're messing with /bin/sh in any way.

IIRC our default u-a is a shell script, the other version is a perl script. Correct me if I'm wrong, it has been some years since I looked at it :)

regards,

Koen

#6 lore raw
Quoted 34 lines · Koen Kooi
Quoted 24 lines · Chris Larson
Quoted 15 lines · Tim Harvey
Quoted 8 lines · Chris Larson

Be very careful with this.  Specifically, be sure to thoroughly test installing bash onto a system that currently has busybox, and the upgrade paths for both busybox and bash.  You never want to get into a state, due to pre/post rm/install script execution order, where /bin/sh doesn't exist.  If that happens, you won't be able to execute the next script to fix it :)

in my case, I have both bash and busybox installed and I want bash to take
priority as the /bin/sh which it otherwise does not.

Quoted 6 lines

attempting to remove the package that contains your shell is something you
need to be careful as anyway.

This seems to me to be a prime example of where alternatives should be used?

Quoted 8 lines

You missed my point, it seems.  I was talking about update-alternatives.  Depending on how update-alternatives is implemented, there could be issues similar to what I mentioned in the previous email.  Consider: if it uses system(), which calls /bin/sh, to remove the old /bin/sh link, and then calls system() again to create the new, it will fail.  Speculation, but again, it's something you always need to keep in mind if you're messing with /bin/sh in any way.

Quoted 2 lines

IIRC our default u-a is a shell script, the other version is a perl script. Correct me if I'm wrong, it has been some years since I looked at it :)

That reminds me, one of my coworkers pointed me to a C implementation.
If you grab the chkconfig srpm from centos 5.2, or another redhat
based distribution, you'll find an alternatives.c written by redhat, whose syntax is the same as debian update-alternatives. Might be worth looking at.

Signature · 7 lines
Chris Larson
clarson at kergoth dot com
clarson at mvista dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Software Engineer
MontaVista Software, Inc.