preinst 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. # Pre-install script for ‘python-coverage’.
  3. #
  4. # Man page: ‘dh_installdeb(1)’
  5. set -e
  6. # Summary of ways this script can be called:
  7. # * <new-preinst> ‘install’
  8. # * <new-preinst> ‘install’ <old-version>
  9. # * <new-preinst> ‘upgrade’ <old-version>
  10. # * <old-preinst> ‘abort-upgrade’ <new-version>
  11. # For details, see the Debian Policy §6.5 in the ‘debian-policy’ package
  12. # or on the web at <URL:http://www.debian.org/doc/debian-policy/>.
  13. action="$1"
  14. SCOREFILES="
  15. /var/games/bsdgames/atc_score
  16. /var/games/bsdgames/battlestar.log
  17. /var/games/bsdgames/cfscores
  18. /var/games/bsdgames/criblog
  19. /var/games/bsdgames/saillog
  20. /var/games/bsdgames/snake.log
  21. /var/games/bsdgames/snakerawscores
  22. /var/games/bsdgames/tetris-bsd.scores
  23. /var/games/bsdgames/phantasia/characs
  24. /var/games/bsdgames/phantasia/gold
  25. /var/games/bsdgames/phantasia/lastdead
  26. /var/games/bsdgames/phantasia/mess
  27. /var/games/bsdgames/phantasia/motd
  28. /var/games/bsdgames/phantasia/scoreboard
  29. /var/games/bsdgames/phantasia/void
  30. /var/games/bsdgames/phantasia/monsters"
  31. # We used to keep score files in /var/lib/games, and if files are there,
  32. # move them into the new location.
  33. if [ -d /var/lib/games ]; then
  34. # Have to set up directory hierarchy, since this is running as a
  35. # preinst.
  36. mkdir -p /var/games/bsdgames/phantasia
  37. chown root:games /var/games/bsdgames \
  38. /var/games/bsdgames/phantasia
  39. chmod g+rws /var/games/bsdgames \
  40. /var/games/bsdgames/phantasia
  41. for file in $SCOREFILES; do
  42. oldfile=`echo $file | sed s:/var/games/:/var/lib/games/:`
  43. if [ -e $oldfile ]; then
  44. if [ ! -e $file ]; then
  45. mv -f $oldfile $file
  46. else
  47. rm -f $oldfile
  48. fi
  49. fi
  50. done
  51. # Delete the old directory hierarchy.
  52. rm -rf /var/lib/games/bsdgames
  53. fi
  54. case "$action" in
  55. install|upgrade|abort-upgrade)
  56. ;;
  57. *)
  58. printf "preinst called with unknown action ‘%s’\n" "$action" >&2
  59. exit 1
  60. ;;
  61. esac
  62. # I didn't move robots_roll above, because the version used by old bsdgames has
  63. # a different file format. Make sure that if I'm ugrading from pre 2.8 days,
  64. # the old file is deleted.
  65. if [ "$1" = "upgrade" ] && dpkg --compare-versions "$2" lt 2.8; then
  66. rm -rf /var/games/bsdgames/robots_roll
  67. fi
  68. #DEBHELPER#
  69. exit 0