summaryrefslogtreecommitdiff
path: root/debian/dpkg.postinst
blob: b29de4725a1cd6a67ad404e2bbe9408957106be3 (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/sh

set -e

dupdaemonhelp () {
	cat <<EOF

Some daemons and similar services whose scripts have links in the
/etc/rcN.d directories have both start (S) and stop (K) links in
some runlevels.  Thus these services get stopped and immediately
restarted at some runlevel changes, which is probably not what
you want.  I can remove the probably-spurious K links if you like.

Type Y to remove then, N to leave them, or L to list them.
If you don't know what to do you can say N now and then delete
them by hand later.

EOF
}

if [ "x$1" = xconfigure ]; then
	if [ -z "$2" -a ! -f /etc/dpkg/dpkg.cfg ] ; then
		cp /usr/share/doc/dpkg/dpkg.cfg /etc/dpkg
	fi

	case "$2" in
	0.* | 1.0.* | 1.1.0 | 1.1.0[^0-9]* | '' )
		for f in 0 1 2 3 4 5 6
		do
			cd /etc/rc$f.d
			for g in K[0-9][0-9]*
			do
				if [ -n "`echo \"x$g\" | tr -d 0-9A-Za-z_-`" ]
				then
					continue
				fi
				h="`echo $g | sed -e 's/^K/S/'`"
				if ! [ -L $h -a -L $g ] \
				  || [ "`ls -Li $g 2>/dev/null | awk '{print $1}'`" != \
				       "`ls -Li $h 2>/dev/null | awk '{print $1}'`" ]
				then
					continue
				fi
				removes="$removes rc$f.d/$g"
			done
		done
		if [ -n "$removes" ]
		then
			cd /etc
			dupdaemonhelp
			while [ -n "$removes" ]
			do
				echo -n 'y=remove, n=leave, l=list, h=help ?  '
				read response
				case "$response" in
				[Yy]*)
					echo "Removing duplicate K links ..."
					rm -v $removes
					removes=""
					;;
				[Nn]*)
					echo -e "OK, leaving them.\n"
					removes=""
					;;
				[Ll]*)
					echo
					echo $removes
					echo
					;;
				[Hh]*)
					dupdaemonhelp
					;;
				esac
			done
		fi
		;;
	1.1.6 | 1.1.6elf | 1.2.[0123] | 1.2.[0123]elf )
		response=''
		while [ -z "$response" ]; do
			echo -n '
The version of dpkg you'\''re upgrading from had a problem with the
install-info program used to maintain the /usr/info/dir file.  It may
have corrupted the file, for example by placing new entries for the
menu in it before the `* Menu'\'' line (thus making them ineffective) or
by creating several identical sections.

I can try to sort these problems out, but beware that this process is
not guaranteed not to mess up a dir file which has things that look
like menu entries in the introductory paragraphs.  The distributed dir
files do not do this, so if you haven'\''t edited /usr/info/dir it'\''s
almost certainly safe to say `yes'\'' to the next question.

If you say `no'\'' you may wish to check and/or edit /usr/info/dir yourself.

Try to check/repair /usr/info/dir automatically ?  [y/n]  '
			read response
			case "$response" in
			[Yy]* | '')	response=yes ;;
			[Nn]*)		response=no ;;
			*)		response='' ;;
			esac
		done
		if [ "$response" = yes ]; then
			echo "
Checking/repairing /usr/info/dir ..."
			cleanup-info --unsafe
			echo
		else
			echo "
OK.
"
		fi
		;;
	esac
fi

if [ -d /usr/info -a ! -L /usr/info -a ! -L /usr/info/dir ]; then              
	echo Moving /usr/info/dir to /usr/share/info/dir.
	mv /usr/info/dir /usr/share/info/dir
	if [ -f /usr/info/dir.old ]; then
		mv /usr/info/dir.old /usr/share/info/dir.old
	fi
	if [ "`find /usr/info -empty`" = "/usr/info" ]; then
		echo Making /usr/info a symlink to /usr/share/info.
		rmdir /usr/info
		ln -s share/info /usr/info
	else
		echo Making /usr/info/dir a symlink to /usr/share/info/dir.
		ln -sf ../share/info/dir /usr/info/dir
	fi
fi


cd /var/lib/dpkg
for f in diversions statoverride status ; do
	if [ ! -f "$f" ] ; then
		touch "$f"
	fi
done