Jonathan Nieder wrote:
> The real benefits of the change will only come once the postinst logic
> is changed.
Here's a quick example. It adds a choice "custom" to the debconf
prompt that asks where /bin/sh should points. Admins choosing that
can point /bin/sh where they please with commands like
ln -sf mksh /bin/sh
As a nice side-effect, if this package is installed from lenny (the
scenario of bugs #538822, #540512) then diversions by other packages
would be left alone and respected, though there would still be a
file conflict with bash until the latter removes its copy of /bin/sh.
But it requires bash or dash to remove its copy of /bin/sh to be
completely robust.
Moreover, I don't think this particular change is actually a good
idea, because of the following sequence of commands:
dpkg-reconfigure dash; # choose "custom"
ln -sf mksh /bin/sh
dpkg --remove mksh
A better system would have to include some logic in or dependencies
on packages that provide a system shell candidate to prevent removal
when they are being used as /bin/sh. So hopefully this demo
illustrates how far the change to preinst would unravel the diversion
mess (i.e., a little, but not all the way).
debian/changelog | 10 +++++++++
debian/dash.postinst | 51 +++++++++++++++++++++++++++++++++++++--------
debian/dash.templates.in | 17 +++++++--------
3 files changed, 60 insertions(+), 18 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 155786e0..015dae24 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+dash (0.5.7-2~exp1.1) local; urgency=low
+
+ * Add a choice "custom" to the debconf prompt for choice of
+ system shell. When it is selected, /bin/sh will be left alone
+ by dash and the administrator can point the symlink to any shell.
+ * Change the default system shell to "custom" (helps: #538822,
+ #540512).
+
+ -- Jonathan Nieder <[email protected]> Wed, 17 Aug 2011 15:23:13 -0500
+
dash (0.5.7-2~exp1) experimental; urgency=low
* debian/diff/0003-VAR-Disable-LINENO-support.diff: remove
diff --git a/debian/dash.postinst b/debian/dash.postinst
index 799a4237..7931dd14 100644
--- a/debian/dash.postinst
+++ b/debian/dash.postinst
@@ -20,6 +20,29 @@ replace_with_link() {
mv -f "$temp" "$dfile"
}
+divert_binsh() {
+ # dash's preinst takes a diversion on behalf of bash.
+ # So when bash is unpacked, _its_ copy of /bin/sh is not
+ # diverted, and dpkg would happily overwrite /bin/sh with a
+ # symlink to bash unless we take the diversion back again.
+ #
+ # When /bin/sh is dropped from bash's files list, this
+ # function will not be needed any more.
+
+ dfile=$1 distrib=${2:-$dfile.distrib}
+ diverter=$(dpkg-divert --listpackage $dfile)
+ ltarget=$(echo $dfile | sed -e s/sh/bash/)
+
+ if [ "$diverter" != bash ]; then
+ # good.
+ return 0
+ fi
+
+ dpkg-divert --package bash --remove $dfile
+ dpkg-divert --package dash --divert $distrib --add $dfile
+ replace_with_link $distrib $ltarget
+}
+
claim_binsh() {
dfile=$1 ltarget=$2 distrib=${3:-$dfile.distrib}
diverter=$(dpkg-divert --listpackage $dfile)
@@ -128,17 +151,27 @@ elif [ "$1" = configure ] && dpkg --compare-versions "$2"
lt 0.4.18; then
add_shell
fi
+# Which shell should /bin/sh point to?
+RET=custom
if [ $debconf ]; then
db_get dash/sh
- if [ "$RET" = true ]; then
- claim_binsh /bin/sh dash
- claim_binsh /usr/share/man/man1/sh.1.gz dash.1.gz \
- /usr/share/man/man1/sh.distrib.1.gz
- else
- unclaim_binsh /bin/sh dash
- unclaim_binsh /usr/share/man/man1/sh.1.gz dash.1.gz \
- /usr/share/man/man1/sh.distrib.1.gz
- fi
+fi
+
+if [ "$RET" = true ]; then
+ # dash.
+ claim_binsh /bin/sh dash
+ claim_binsh /usr/share/man/man1/sh.1.gz dash.1.gz \
+ /usr/share/man/man1/sh.distrib.1.gz
+elif [ "$RET" = false ]; then
+ # bash.
+ unclaim_binsh /bin/sh dash
+ unclaim_binsh /usr/share/man/man1/sh.1.gz dash.1.gz \
+ /usr/share/man/man1/sh.distrib.1.gz
+else
+ # Something else.
+ divert_binsh /bin/sh
+ divert_binsh /usr/share/man/man1/sh.1.gz \
+ /usr/share/man/man1/sh.distrib.1.gz
fi
test "$1" = 'configure' || exit 0
diff --git a/debian/dash.templates.in b/debian/dash.templates.in
index dfaf25db..f5ea0eac 100644
--- a/debian/dash.templates.in
+++ b/debian/dash.templates.in
@@ -7,17 +7,16 @@
# Even minor modifications require translation updates and such
# changes should be coordinated with translators and reviewers.
Template: dash/sh
-Type: boolean
-Default: true
-_Description: Use dash as the default system shell (/bin/sh)?
+Type: select
+Choices-C: true, false, custom
+Choices: dash, bash, custom
+Default: custom
+_Description: System shell (/bin/sh):
The system shell is the default command interpreter for shell scripts.
.
Using dash as the system shell will improve the system's overall
performance. It does not alter the shell presented to interactive
users.
-# _Description: Install dash as /bin/sh?
-# The default /bin/sh shell on Debian and Debian-based systems is bash.
-# .
-# However, since the default shell is required to be POSIX-compliant,
-# any shell that conforms to POSIX, such as dash, can serve as /bin/sh.
-# You may wish to do this because dash is faster and smaller than bash.
+ .
+ If you choose "custom", the dash package will leave the /bin/sh
+ symbolic link unchanged.
--
1.7.6
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]