apt.postinst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #! /bin/sh
  2. set -e
  3. # summary of how this script can be called:
  4. # * <postinst> `configure' <most-recently-configured-version>
  5. # * <old-postinst> `abort-upgrade' <new version>
  6. # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  7. # <new-version>
  8. # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  9. # <failed-install-package> <version> `removing'
  10. # <conflicting-package> <version>
  11. # for details, see http://www.debian.org/doc/debian-policy/ or
  12. # the debian-policy package
  13. case "$1" in
  14. configure)
  15. if dpkg --compare-versions "$2" lt 1.0.7; then
  16. # apt-key before 0.9.10 could leave empty keyrings around
  17. find /etc/apt/trusted.gpg.d/ -name '*.gpg' | while read keyring; do
  18. if ! test -s "$keyring"; then
  19. rm -f "$keyring"
  20. fi
  21. done
  22. fi
  23. if dpkg --compare-versions "$2" lt-nl 0.9.9.5; then
  24. # we are using tmpfiles for both
  25. rm -f /etc/apt/trustdb.gpg
  26. # this removal was done unconditional since 0.8.15.3
  27. SECRING='/etc/apt/secring.gpg'
  28. # test if secring is an empty normal file
  29. if test -f $SECRING -a ! -s $SECRING; then
  30. rm -f $SECRING
  31. fi
  32. fi
  33. # add unprivileged user for the apt methods
  34. adduser --force-badname --system -home /var/empty \
  35. --no-create-home --quiet _apt || true
  36. # deal with upgrades from experimental
  37. if dpkg --compare-versions "$2" 'eq' '1.1~exp3'; then
  38. # libapt will setup partial/ at runtime
  39. chown -R root:root /var/lib/apt/lists /var/cache/apt/archives || true
  40. fi
  41. # ensure tighter permissons on the logs, see LP: #975199
  42. if dpkg --compare-versions "$2" lt-nl 0.9.7.7; then
  43. # ensure permissions are right
  44. chmod -f 0640 /var/log/apt/term.log* || true
  45. fi
  46. # create kernel autoremoval blacklist on update
  47. if dpkg --compare-versions "$2" lt 0.9.9.3; then
  48. /etc/kernel/postinst.d/apt-auto-removal
  49. fi
  50. ;;
  51. abort-upgrade|abort-remove|abort-deconfigure)
  52. ;;
  53. *)
  54. echo "postinst called with unknown argument \`$1'" >&2
  55. exit 1
  56. ;;
  57. esac
  58. # dh_installdeb will replace this with shell code automatically
  59. # generated by other debhelper scripts.
  60. #DEBHELPER#
  61. exit 0