From 05c1076ba2d1a68fe7f3a5ae618f786b8898d327 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Mon, 26 Sep 2005 18:32:28 +1000 Subject: Initial import. --- debian/dash.postinst | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 debian/dash.postinst (limited to 'debian/dash.postinst') diff --git a/debian/dash.postinst b/debian/dash.postinst new file mode 100644 index 0000000..6dd59d1 --- /dev/null +++ b/debian/dash.postinst @@ -0,0 +1,92 @@ +#!/bin/sh +# +# post-install script for the Debian GNU/Linux dash package +# +# $Id$ + +set -e + +check_divert() { + div=$(dpkg-divert --list $2) + distrib=${4:-$2.distrib} + case "$1" in + true) + if [ -z "$div" ]; then + dpkg-divert --package dash --divert $distrib --add $2 + cp -dp $2 $distrib + ln -sf $3 $2 + fi + ;; + false) + if [ -n "$div" ] && [ -z "${div%%*by dash}" ]; then + mv $distrib $2 + dpkg-divert --remove $2 + fi + ;; + ash) + case $div in + '') + ;; + *by\ ash) + dst=${div% by ash} + dst=${dst##* to } + + # Work around dpkg-divert bug. + if [ -e "$dst" ]; then + mv "$dst" "$dst.dash-tmp" + fi + dpkg-divert --remove $2 + if [ -e "$dst.dash-tmp" ]; then + mv "$dst.dash-tmp" "$dst" + fi + + dpkg-divert --package dash --divert $distrib --add $2 + if [ "$dst" != $distrib ] && [ -e "$dst" ]; then + mv "$dst" $distrib + fi + ln -sf $3 $2 + ;; + *) + d=${2%/*} + if + [ -h $2 ] && [ -f $2 ] && [ -f $d/$5 ] && + cmp $2 $d/$5 + then + ln -sf $3 $2 + fi + ;; + esac + esac +} + +add_shell() { + if ! type add-shell > /dev/null 2>&1; then + return + fi + + add-shell /bin/dash +} + +debconf= +if [ -f /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule + debconf=yes +fi + +if [ "$1" = configure ] && [ -z "$2" ]; then + check_divert ash /bin/sh dash '' ash + check_divert ash /usr/share/man/man1/sh.1.gz dash.1.gz \ + /usr/share/man/man1/sh.distrib.1.gz ash.1.gz + add_shell +elif [ "$1" = configure ] && dpkg --compare-versions "$2" lt 0.4.18; then + add_shell +fi + +if [ $debconf ]; then + db_get dash/sh + check_divert "$RET" /bin/sh dash + check_divert "$RET" /usr/share/man/man1/sh.1.gz dash.1.gz \ + /usr/share/man/man1/sh.distrib.1.gz +fi + +#DEBHELPER# -- cgit 1.4.1