File: preinst

package info (click to toggle)
doc-base 0.8.20
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 224 kB
  • ctags: 133
  • sloc: perl: 1,506; makefile: 161; sh: 97
file content (62 lines) | stat: -rw-r--r-- 1,664 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
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
# $Id: preinst 180 2009-01-23 23:01:19Z robert $
# preinst for doc-base

# Abort if any command returns an error value
set -e

package=doc-base
infodir="/var/lib/$package/info"
docsdir="/var/lib/$package/documents"
omfdir="/var/lib/$package/omf"


remove_obsolete() {
	# remove old dhelp files (from versions <= 0.8.4)
	find $infodir -maxdepth 1 -type f -name "*.list" -print0 | xargs -0 grep -h '^/.*/.dhelp' |  \
	while read f; do
		[ -e "$f" ] || continue;
#		[ -x /usr/sbin/dhelp_parse ] && /usr/sbin/dhelp_parse -d "`dirname "$f"`" || true
		rm -f "$f"
	done

	# remove old scrollkeeper files
	find $infodir -maxdepth 1 -type f -name "*.status" -print0 | \
	xargs -0 sed -ne 's/^Scrollkeeper-omf-file: *"*\(.*-C.omf\)"* *$/\1/p'  |  \
	while read f; do
		[ -e "$f" ] || continue;
		rm -f "$f"
		rmdir --ignore-fail-on-non-empty "`dirname "$f"`" || true
	done


	# remove newer dhelp files
	find $infodir -maxdepth 1 -type f -name "*.status" -print0 | \
	xargs -0 sed -ne 's/^Dhelp-file: *"*\(.*\.dhelp\)"* *$/\1/p'  |  \
	while read f; do
		[ -e "$f" ] || continue;
		rm -f "$f"
	done

	# remove newer scrollkeeper files
	find $infodir -maxdepth 2 -type f -name "*.omf" -print0 | xargs -0 rm -f
	find $infodir -maxdepth 1 -type d -print0 | xargs -0 rmdir --ignore-fail-on-non-empty


	# remove status/list files
	find $infodir -maxdepth 1 -type f \( -name "*.status" -o -name "*.list" -o -name "*.db" \) -print0 | \
	xargs -0 rm -f
	
	# remove generated documents
	find $docsdir -maxdepth 1 -type f -print0  | xargs -0 rm -f
}

if [ "$1" = "upgrade" ] &&  dpkg --compare-versions "$2" lt-nl "0.8.12"; then
	remove_obsolete
fi


#DEBHELPER#

exit 0