1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#! /bin/sh
set -e
# This postinst handles the following cases and tasks:
# 1. On initial installation:
# - create highscores data.
# 2. When upgrading:
# - migrate old highscores to new location.
# 3. When aborting an upgrade:
# - restore higscores in old location.
olderscoredir=/var/lib/games/Xbat/Score
oldscoredir=/var/games/Xbat/Score
newscoredir=/var/games/xbat
scorelibdir=/usr/share/games/xbat/Score
case "$1" in
configure)
# Cancel my old stupid use of dpkg-statoverride
if [ "$1" = "configure" ] && [ "$2" != "" ] &&
dpkg --compare-versions "$2" le "1.11-10" &&
[ -x /usr/sbin/dpkg-statoverride ] &&
dpkg-statoverride --list "/usr/games/xbat" >/dev/null
then
dpkg-statoverride --remove "/usr/games/xbat"
fi
# Check if the dynamic highscore files are in place.
#
# The highscore directory is included by the package,
# but dynamic data must not be, or else it would be
# replaced every time the package is upgraded.
#
# If there are any in the old location, then this must
# either be an upgrade or a reinstallation after a
# remove-but-not-purge, and we want to reuse the old
# highscores data.
#
# If there is no trace of existing higscores, copy the
# distributed highscores in place.
for a in 0 1 2 3 4 ; do
if [ ! -e $newscoredir/top10-$a.txt ]; then
if [ -e $oldscoredir/top10-$a.txt ]; then
mv $oldscoredir/top10-$a.txt $newscoredir
elif [ -e $olderscoredir/top10-$a.txt ]; then
mv $olderscoredir/top10-$a.txt $newscoredir
else
cp $scorelibdir/top10-$a.txt $newscoredir
fi
fi
# Fix up system-wide highscores permissions.
chown root:games $newscoredir/top10-$a.txt
chmod 0664 $newscoredir/top10-$a.txt
done
# Finalize highscores migration from /var/lib/games to /var/games
if [ -d /var/lib/games/Xbat ]; then
rm -rf /var/lib/games/Xbat
fi
if [ -d /var/games/Xbat ]; then
rm -rf /var/games/Xbat
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
# Here I think we should put the highscores back
# I'm studying on it :-)
echo "$0 called with exceptional argument \`$1'" >&2;
echo " something bad may be getting away uncaught here" >&2
;;
*)
echo "$0 called with unknown argument \`$1'" >&2;
echo " please check bugs.debian.org/xbat" >&2;
exit 0;
;;
esac
#DEBHELPER#
|