post_install() {
  touch var/games/glhack/{record,perm,logfile}
  chown root:games var/games/glhack/{record,perm,logfile}
  chmod 664 var/games/glhack/{record,perm,logfile}
}

pre_upgrade() {
  install -d -m775 var/games/glhack
  chown root:games var/games/glhack
  [ -e usr/share/glhack/record ] && cp usr/share/glhack/record var/games/glhack
  [ -e usr/share/glhack/perm ] && cp usr/share/glhack/perm var/games/glhack
  [ -e usr/share/glhack/logfile ] && cp usr/share/glhack/logfile var/games/glhack
  if [ -d usr/share/glhack/save ]; then
    chmod g-s usr/share/glhack/save
    mv usr/share/glhack/save var/games/glhack
  else
    install -d -m775 var/games/glhack/save
  fi
  chown root:games var/games/glhack/save
}

post_upgrade() {
  post_install
}
