summaryrefslogtreecommitdiffstats
path: root/debian/cryptsetup-nuke-password.preinst
blob: 2b0580e7c7365da81baa9057d3e0e554f5c9fcc8 (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
#!/bin/sh

set -e

if [ "$1" = "install" ]; then
    dpkg-divert --rename --package cryptsetup-nuke-password \
		--divert /usr/lib/cryptsetup/askpass.cryptsetup \
		--add /usr/lib/cryptsetup/askpass
    dpkg-divert --rename --package cryptsetup-nuke-password \
		--divert /lib/cryptsetup/askpass.cryptsetup.usr-is-merged \
		--add /lib/cryptsetup/askpass
elif [ "$1" = "upgrade" ]; then
    TRUENAME=$(dpkg-divert --truename /usr/lib/cryptsetup/askpass)
    if test "$TRUENAME" = /usr/lib/cryptsetup/askpass.usr-is-merged; then
	# crypsetup.preinst duplicated the diversion for us
	dpkg-divert --no-rename --package cryptsetup-nuke-password \
		    --divert /usr/lib/cryptsetup/askpass.usr-is-merged \
		    --remove /usr/lib/cryptsetup/askpass
	dpkg-divert --no-rename --package cryptsetup-nuke-password \
		    --divert /usr/lib/cryptsetup/askpass.cryptsetup \
		    --add /usr/lib/cryptsetup/askpass
	dpkg-divert --no-rename --package cryptsetup-nuke-password \
		    --remove /lib/cryptsetup/askpass
	dpkg-divert --no-rename --package cryptsetup-nuke-password \
		    --divert /lib/cryptsetup/askpass.cryptsetup.usr-is-merged \
		    --add /lib/cryptsetup/askpass
	mv "$TRUENAME" /usr/lib/cryptsetup/askpass.cryptsetup
    elif test "$TRUENAME" != /usr/lib/cryptsetup/askpass.cryptsetup; then
	dpkg-divert --no-rename --package cryptsetup-nuke-password \
		    --divert /usr/lib/cryptsetup/askpass.cryptsetup \
		    --add /usr/lib/cryptsetup/askpass
	TRUENAME=$(dpkg-divert --truename /lib/cryptsetup/askpass)
	dpkg-divert --no-rename --package cryptsetup-nuke-password \
		    --remove /lib/cryptsetup/askpass
	dpkg-divert --no-rename --package cryptsetup-nuke-password \
		    --divert /lib/cryptsetup/askpass.cryptsetup.usr-is-merged \
		    --add /lib/cryptsetup/askpass
	if test -e "$TRUENAME"; then
	    mv "$TRUENAME" /lib/cryptsetup/askpass.cryptsetup.usr-is-merged
	fi
    fi
fi

#DEBHELPER#