apt.postinst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. chown -R _apt:root \
  37. /var/lib/apt/lists \
  38. /var/cache/apt/archives
  39. # ensure tighter permissons on the logs, see LP: #975199
  40. if dpkg --compare-versions "$2" lt-nl 0.9.7.7; then
  41. # ensure permissions are right
  42. chmod -f 0640 /var/log/apt/term.log* || true
  43. fi
  44. # create kernel autoremoval blacklist on update
  45. if dpkg --compare-versions "$2" lt 0.9.9.3; then
  46. /etc/kernel/postinst.d/apt-auto-removal
  47. fi
  48. ;;
  49. abort-upgrade|abort-remove|abort-deconfigure)
  50. ;;
  51. *)
  52. echo "postinst called with unknown argument \`$1'" >&2
  53. exit 1
  54. ;;
  55. esac
  56. # dh_installdeb will replace this with shell code automatically
  57. # generated by other debhelper scripts.
  58. #DEBHELPER#
  59. exit 0