File: postinst

package info (click to toggle)
typespeed 0.4.4-8sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 220 kB
  • ctags: 90
  • sloc: ansic: 1,924; makefile: 85; sh: 23
file content (49 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download
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
#!/bin/sh

set -e

if test "$1" = "configure"; then
	cd /var/games/typespeed

	# Move high score files created by older versions to the new,
	# FHS-compliant location.

	# If the old high score directory exists, find all high score
	# files in it and move then to the new high score directory
	# unless a file with the same name already exists there.
	test -d /var/lib/games/typespeed && \
		find /var/lib/games/typespeed \
			-name 'high.words.*' \
			-exec sh -c 'test ! -e `basename {}`' \
			-exec mv '{}' . ';'

	# Try and delete the old high score directory if it exists,
	# but don't worry if deletion fails.
	test -d /var/lib/games/typespeed && \
		rmdir --ignore-fail-on-non-empty /var/lib/games/typespeed

	# Create new high score files.

	# Create backup directory.
	BACKUP=`mktemp -d typespeed-upgrade-XXXXXX`

	# Back up current high score files.
	find -maxdepth 1 -name 'high.words.*' -exec mv '{}' $BACKUP ';'

	# Create the new high score files.
	/usr/games/typespeed --makescores > /dev/null

	# Move the old high score files back.
	find $BACKUP -type f -exec mv -f '{}' . ';'

	# Delete backup directory.
	rmdir $BACKUP

	# Fix permissions.
	find -name 'high.words.*' \
		-exec chown root.games '{}' ';' \
		-exec chmod 664 '{}' ';'
fi

#DEBHELPER#