dpkg.preinst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. case "$2" in
  47. # Upgrade from pre-conffile dpkg.cfg
  48. 1.9.21 | 1.10.* )
  49. upgrade_dpkg_non_conffile
  50. ;;
  51. esac
  52. ;;
  53. abort-upgrade)
  54. ;;
  55. *)
  56. echo "$0 called with unknown argument \`$1'" 1>&2
  57. exit 1
  58. ;;
  59. esac
  60. #DEBHELPER#
  61. exit 0