postinst is in dash 0.5.7-4ubuntu1.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | #!/bin/sh
set -e
# $1: dfile, $2: link target, $3: distrib
replace_with_link() {
dfile=$1; ltarget=$2; distrib=$3
temp=$dfile.tmp
# Safely create a symlink to $ltarget at $dfile, first
# making a backup of $dfile (the file being diverted)
# in $distrib.
#
# The cp / ln -s / mv dance avoids having to live without
# $dfile (think: /bin/sh) for even a moment, so applications
# running in parallel can continue without trouble.
# See dash.preinst for details.
if [ -e "$dfile" ]; then
cp -dp "$dfile" "$distrib"
fi
ln -sf "$ltarget" "$temp"
mv -f "$temp" "$dfile"
}
# $1: case, $2: dfile, $3: ltarget [, $4: distrib]
check_divert() {
dfile=$2; ltarget=$3
distrib=${4:-$dfile.distrib}
diverter=$(dpkg-divert --listpackage $dfile)
truename=$(dpkg-divert --truename $dfile)
case "$1" in
true)
if [ "$diverter" != dash ]; then
# Let dpkg-divert error out; we are not taking
# over the diversion, unless we added it
# ourselves on behalf of bash.
if [ "$diverter" = bash ]; then
dpkg-divert --package bash --remove $dfile
else
dpkg-divert --package dash --remove $dfile
# Make sure we die:
echo "This should never be reached"
exit 1
fi
dpkg-divert --package dash --divert $distrib --add $dfile
# remove the old equivalent of $distrib, if it existed:
# or $dfile if there was no previous diversion! -- should never happen, unless preinst failed
if [ -n "$truename" ]; then
rm -f "$truename"
fi
replace_with_link $dfile $ltarget $distrib
fi
;;
false)
if [ "$diverter" = dash ]; then
# Simple hack. We also divert sh(1), remember?
bash=$(echo "$ltarget"|sed 's/dash/bash/')
dpkg-divert --package dash --remove $dfile
# The diversion is added as if we were bash, leaving
# no diversion would lead to a file conflict later
# when re-checked by dpkg
dpkg-divert --package bash --divert $distrib --add $dfile
# ugh? $truename should always be set (to $distrib)
if [ -n "$truename" ]; then
rm -f "$truename"
fi
# Point everything back to bash
replace_with_link $dfile $bash $distrib
fi
;;
ash)
# Code not modified by the NMU:
div=$(dpkg-divert --list $2)
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 --package ash --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.tmp
mv -f $2.tmp $2
;;
*)
d=${2%/*}
if
[ -h $2 ] && [ -f $2 ] && [ -f $d/$5 ] &&
cmp $2 $d/$5
then
ln -sf $3 $2.tmp
mv -f $2.tmp $2
fi
;;
esac
esac
}
add_shell() {
if ! type add-shell > /dev/null 2>&1; then
return
fi
add-shell /bin/dash
}
reset_default() {
db_fget dash/sh seen
if [ "$RET" = false ]; then
db_reset dash/sh
fi
}
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
reset_default
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
test "$1" = 'configure' || exit 0
test -x /usr/bin/update-menus || exit 0
test -z "$2" || dpkg --compare-versions "$2" lt 0.5.2-3 || exit 0
exec update-menus
|