123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- #!/bin/sh -e
- # This script can be called in the following ways:
- #
- # Before the package is installed:
- # <new-preinst> install
- #
- # Before removed package is upgraded:
- # <new-preinst> install <old-version>
- #
- # Before the package is upgraded:
- # <new-preinst> upgrade <old-version>
- #
- #
- # If postrm fails during upgrade or fails on failed upgrade:
- # <old-preinst> abort-upgrade <new-version>
- # Confirm that users are aware that conffile changes will be lost
- confirm_conffile_stomp() {
- tempfile=/var/lib/dpkg/bp.$$
- trap 'status=$?; rm -f $tempfile; exit $status' 0
- perl -000 -ne 'print $x if m/^Package:\s+(\S+\n)/im &&
- ($x=$1) ne "dpkg\n" &&
- m/^Status:.*(unpacked|postinst)/im' \
- /var/lib/dpkg/status >$tempfile
- if [ -s $tempfile ]; then
- echo "
- WARNING - have you read the release notes for this upgrade ?
- The following packages have been unpacked but not yet configured:"
- echo " "`cat $tempfile`
- echo -n "
- If you proceed with the dpkg upgrade with these packages in this state
- you will LOSE ANY CONFIGURATION CHANGES that have been made to their
- configuration files. I recommend that you back out of the upgrade
- now (see below) and then configure each of these packages using:
- dpkg --configure --force-hold <package>
- If you do this and it fails for some packages they are broken anyway, in
- which case you probably don't have that much to lose by going ahead
- with the upgrade.
- Type \"yes\" to confirm that you really want to do the upgrade in
- spite of my warning above; if you give any other response we'll back
- off the upgrade to give you a chance to fix things.
- Continue with upgrade despite probable loss of config data ? "
- read response
- case "$response" in
- [Yy][Ee][Ss])
- echo "OK, going ahead."
- ;;
- *)
- echo "Aborting dpkg upgrade."
- exit 1
- ;;
- esac
- fi
- rm -f $tempfile
- }
- # Confirm that the user isn't upgrading anything else at the same time
- confirm_singleton() {
- echo -n "
- IMPORTANT - you must install this upgrade on its own, not together in
- the same dpkg run as any other packages. Otherwise you risk losing
- configuration information.
- If you say \"no\" to the question below we'll back off the upgrade now,
- and you can then do it later using:
- dpkg --install dpkg-0.93.51.deb
- If you're not sure what to do, say \"no\", and then run that command
- (with the appropriate dpkg-*.deb filename) from a root shell prompt.
- Are you installing only the dpkg upgrade in this dpkg run ? [y/n] "
- read response
- case "$response" in
- [yY]*|"")
- echo "OK, going ahead."
- ;;
- *)
- echo "Aborting dpkg upgrade."
- exit 1
- ;;
- esac
- }
- # Confirm that dselect got split into it's own package
- confirm_dselect_split() {
- if ! grep "^Package: *dselect$" /var/lib/dpkg/status >/dev/null; then
- echo -n "
- IMPORTANT - if you are upgrading this package from within dselect you
- _MUST_ install the dselect package first.
- The dselect frontend has been split into a separate \`dselect' package,
- which has not yet been unpacked onto your system. Continuing the upgrade
- will mean that dselect will temporarily be removed from your system, if
- this happens within dselect the upgrade will fail.
- Type \"yes\" to confirm that you really want to do the upgrade in
- spite of my warning above (because you're not running dselect, for
- example); if you give any other response we'll back off the upgrade to
- give you a change to install the dselect package first.
- Continue with upgrade despite separation of dselect ? "
- read response
- case "$response" in
- [Yy][Ee][Ss])
- echo "OK, going ahead."
- ;;
- *)
- echo "Aborting dpkg upgrade."
- exit 1
- ;;
- esac
- fi
- }
- # Remove obsolete hd method scripts
- remove_hd_method() {
- methoddir=/usr/lib/dpkg/methods/hd
- if [ -d $methoddir ]; then
- echo "Removing obsolete $methoddir ..."
- rm -r $methoddir
- fi
- }
- case "$1" in
- install)
- ;;
- upgrade)
- case "$2" in
- # Upgrade from non-C dpkg (pre-0.93.50)
- 0.93.[01234]* | -)
- echo ""
- echo "Contemplating upgrade of dpkg from pre-0.93.50 version ..."
- confirm_conffile_stomp
- confirm_singleton
- confirm_dselect_split
- remove_hd_method
- ;;
-
- # Upgrade from pre-dselect split
- 0.93.[5678][0-9]* | 1.[023456789]* | 1.1.* | 1.10 | 1.10.[12] )
- confirm_dselect_split
- ;;
- esac
- ;;
- abort-upgrade)
- ;;
- *)
- echo "$0 called with unknown argument \`$1'" 1>&2
- exit 1
- ;;
- esac
- #DEBHELPER#
- exit 0
|