I’m not the only person affected by upgrade issues with dash /bin/sh diversion, but I thought I would document the behavior and quick fix for upgrading, since I just got bitten (again) by this on armel upgrading my sheevaplug this morning. See http://bugs.debian.org/538822 for lots of detail.
mshuler@sheeva:~$ sudo apt-get upgrade -V Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be upgraded: dash (0.5.5.1-6 => 0.5.5.1-7.2) 1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/101 kB of archives. After this operation, 4,096 B of additional disk space will be used. Do you want to continue [Y/n]? Preconfiguring packages ... (Reading database ... 19484 files and directories currently installed.) Preparing to replace dash 0.5.5.1-6 (using .../dash_0.5.5.1-7.2_armel.deb) ... Unpacking replacement dash ... dpkg: error processing /var/cache/apt/archives/dash_0.5.5.1-7.2_armel.deb (--unpack): trying to overwrite '/bin/sh', which is also in package bash 4.1-3 configured to not write apport reports Processing triggers for man-db ... Errors were encountered while processing: /var/cache/apt/archives/dash_0.5.5.1-7.2_armel.deb localepurge: Disk space freed in /usr/share/locale: 0 KiB localepurge: Disk space freed in /usr/share/man: 0 KiB Total disk space freed by localepurge: 0 KiB E: Sub-process /usr/bin/dpkg returned an error code (1) mshuler@sheeva:~$ dpkg-divert --list /bin/sh local diversion of /bin/sh to /bin/sh.distrib mshuler@sheeva:~$ readlink -f /bin/sh /bin/dash mshuler@sheeva:~$ ls -l /bin/sh.distrib lrwxrwxrwx 1 root root 4 Sep 29 17:37 /bin/sh.distrib -> bash
remove the /bin/sh diversion and upgrade goes smoothly:
dpkg-divert --remove /bin/sh
mshuler@sheeva:~$ sudo dpkg-divert --remove /bin/sh Removing 'local diversion of /bin/sh to /bin/sh.distrib' mshuler@sheeva:~$ dpkg-divert --list /bin/sh mshuler@sheeva:~$ readlink -f /bin/sh /bin/dash mshuler@sheeva:~$ sudo apt-get upgrade -V Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be upgraded: dash (0.5.5.1-6 => 0.5.5.1-7.2) 1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/101 kB of archives. After this operation, 4,096 B of additional disk space will be used. Do you want to continue [Y/n]? Preconfiguring packages ... (Reading database ... 19483 files and directories currently installed.) Preparing to replace dash 0.5.5.1-6 (using .../dash_0.5.5.1-7.2_armel.deb) ... Adding 'diversion of /bin/sh to /bin/sh.distrib by dash' Unpacking replacement dash ... Processing triggers for man-db ... Setting up dash (0.5.5.1-7.2) ... Removing 'diversion of /bin/sh to /bin/sh.distrib by dash' Adding 'diversion of /bin/sh to /bin/sh.distrib by bash' localepurge: Disk space freed in /usr/share/locale: 0 KiB localepurge: Disk space freed in /usr/share/man: 0 KiB Total disk space freed by localepurge: 0 KiB mshuler@sheeva:~$
but I just realized from that last diversion line that /bin/sh is now diverted to bash, which is not where we started, nor where I want to be..
mshuler@sheeva:~$ readlink -f /bin/sh
/bin/bash
mshuler@sheeva:~$ dpkg-divert –list /bin/sh
diversion of /bin/sh to /bin/sh.distrib by bash
again removing the diversion and setting /bin/sh to dash – not sure how this is going to behave in the future again…
mshuler@sheeva:~$ sudo dpkg-divert –remove /bin/sh
Removing ‘diversion of /bin/sh to /bin/sh.distrib by bash’
mshuler@sheeva:~$ sudo dpkg-divert –package dash –add /bin/sh
Adding ‘diversion of /bin/sh to /bin/sh.distrib by dash’
mshuler@sheeva:~$ ls -l /bin/sh.distrib
lrwxrwxrwx 1 root root 4 Nov 11 13:36 /bin/sh.distrib -> dash
mshuler@sheeva:~$ readlink -f /bin/sh
/bin/bash
mshuler@sheeva:~$ sudo ln -sf dash /bin/sh
mshuler@sheeva:~$ readlink -f /bin/sh
/bin/dash
OK – several other boxes that I’ve upgraded dash on today do not have a problem, and I now see the difference. This ARM box has been continuously updated in debian testing for as long as I’ve had it – like 2 years. Somewhere along the way, when the move from bash -> dash was done to provide /bin/sh, the diversion was set as a “local diversion” – not by me. I do believe the following, before upgrading the package would work – remove then add as I did in the last comment:
dpkg-divert –remove /bin/sh
dpkg-divert –package dash –add /bin/sh
then this is no longer a “local” change, but owned by the dash package, as my other boxes show, which upgraded with no problems.
mshuler@sheeva:~$ dpkg-divert –list /bin/sh
diversion of /bin/sh to /bin/sh.distrib by dash