dpkg.preinst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. # <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. # <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. # <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. # <old-preinst> abort-upgrade <new-version>
  16. # Handle upgrades from pre-conffile dpkg.cfg
  17. upgrade_dpkg_non_conffile()
  18. {
  19. if [ -r /etc/dpkg/dpkg.cfg ]; then
  20. dpkg_cfg_md5="535552ad5ee9145dbc7a34c264df4e59 /etc/dpkg/dpkg.cfg"
  21. if echo "$dpkg_cfg_md5" | md5sum -c >/dev/null 2>&1; then
  22. echo "Removing non-modified dpkg.cfg to be replaced by a conffile ..."
  23. rm -f /etc/dpkg/dpkg.cfg
  24. fi
  25. fi
  26. }
  27. clean_alternative()
  28. {
  29. ALTDIR="/var/lib/dpkg/alternatives"
  30. if [ -e "$ALTDIR/$2" ]; then
  31. if [ -e "$ALTDIR/$1" ] && grep -q "^$2$" "$ALTDIR/$1"; then
  32. echo "Removing conflicting alternative $2 ..."
  33. rm -f "$ALTDIR/$2"
  34. fi
  35. fi
  36. }
  37. case "$1" in
  38. install)
  39. ;;
  40. upgrade)
  41. # Cleanup bad alternatives that would choke with new
  42. # update-alternatives (see #530633, #531611, #532739)
  43. clean_alternative x-terminal-emulator x-terminal-emulator.1.gz
  44. clean_alternative x-session-manager x-session-manager.1.gz
  45. clean_alternative x-window-manager x-window-manager.1.gz
  46. clean_alternative awk nawk
  47. case "$2" in
  48. # Upgrade from pre-conffile dpkg.cfg
  49. 1.9.21 | 1.10.* )
  50. upgrade_dpkg_non_conffile
  51. ;;
  52. esac
  53. ;;
  54. abort-upgrade)
  55. ;;
  56. *)
  57. echo "$0 called with unknown argument \`$1'" 1>&2
  58. exit 1
  59. ;;
  60. esac
  61. #DEBHELPER#
  62. exit 0