apt.postinst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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-nl 0.9.9.5; then
  16. # we are using tmpfiles for both
  17. rm -f /etc/apt/trustdb.gpg
  18. # this removal was done unconditional since 0.8.15.3
  19. SECRING='/etc/apt/secring.gpg'
  20. # test if secring is an empty normal file
  21. if test -f $SECRING -a ! -s $SECRING; then
  22. rm -f $SECRING
  23. fi
  24. fi
  25. # add unprivileged user for the apt methods
  26. adduser --force-badname --system -home /var/empty \
  27. --no-create-home --quiet _apt || true
  28. chown -R _apt:root \
  29. /var/lib/apt/lists \
  30. /var/cache/apt/archives
  31. # ensure tighter permissons on the logs, see LP: #975199
  32. if dpkg --compare-versions "$2" lt-nl 0.9.7.7; then
  33. # ensure permissions are right
  34. chmod -f 0640 /var/log/apt/term.log* || true
  35. fi
  36. # create kernel autoremoval blacklist on update
  37. if dpkg --compare-versions "$2" lt 0.9.9.3; then
  38. /etc/kernel/postinst.d/apt-auto-removal
  39. fi
  40. ;;
  41. abort-upgrade|abort-remove|abort-deconfigure)
  42. ;;
  43. *)
  44. echo "postinst called with unknown argument \`$1'" >&2
  45. exit 1
  46. ;;
  47. esac
  48. # dh_installdeb will replace this with shell code automatically
  49. # generated by other debhelper scripts.
  50. #DEBHELPER#
  51. exit 0