apt.postinst 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.1~exp4; 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. # apt-key before 0.9.8.2 could create 0600 trusted.gpg file
  23. if test -e /etc/apt/trusted.gpg ; then
  24. chmod -f 0644 /etc/apt/trusted.gpg || true
  25. fi
  26. fi
  27. if dpkg --compare-versions "$2" lt-nl 0.9.9.5; then
  28. # we are using tmpfiles for both
  29. rm -f /etc/apt/trustdb.gpg
  30. # this removal was done unconditional since 0.8.15.3
  31. SECRING='/etc/apt/secring.gpg'
  32. # test if secring is an empty normal file
  33. if test -f $SECRING -a ! -s $SECRING; then
  34. rm -f $SECRING
  35. fi
  36. fi
  37. # add unprivileged user for the apt methods
  38. adduser --force-badname --system -home /var/empty \
  39. --no-create-home --quiet _apt || true
  40. # deal with upgrades from experimental
  41. if dpkg --compare-versions "$2" 'eq' '1.1~exp3'; then
  42. # libapt will setup partial/ at runtime
  43. chown -R root:root /var/lib/apt/lists /var/cache/apt/archives || true
  44. fi
  45. # ensure tighter permissons on the logs, see LP: #975199
  46. if dpkg --compare-versions "$2" lt-nl 0.9.7.7; then
  47. # ensure permissions are right
  48. chmod -f 0640 /var/log/apt/term.log* || true
  49. fi
  50. # create kernel autoremoval blacklist on update
  51. if dpkg --compare-versions "$2" lt 0.9.9.3; then
  52. /etc/kernel/postinst.d/apt-auto-removal
  53. fi
  54. ;;
  55. abort-upgrade|abort-remove|abort-deconfigure)
  56. ;;
  57. *)
  58. echo "postinst called with unknown argument \`$1'" >&2
  59. exit 1
  60. ;;
  61. esac
  62. # dh_installdeb will replace this with shell code automatically
  63. # generated by other debhelper scripts.
  64. #DEBHELPER#
  65. exit 0