Debian Codegraph @

debian/cryptsetup.postinst

raw
1 #! /bin/sh
2
3 set -e
4
5 # needed for debconf magic in prerm script
6 . /usr/share/debconf/confmodule
7
8 # summary of how this script can be called:
9 # * <postinst> `configure' <most-recently-configured-version>
10 # * <old-postinst> `abort-upgrade' <new version>
11 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12 # <new-version>
13 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
14 # <failed-install-package> <version> `removing'
15 # <conflicting-package> <version>
16
17 # begin-remove-after: released:forky
18 if [ "$1" = configure ] &&
19 [ "$(dpkg-divert --truename /usr/lib/cryptsetup/askpass)" = /usr/lib/cryptsetup/askpass.usr-is-merged ] &&
20 [ "$(dpkg-divert --listpackage /usr/lib/cryptsetup/askpass)" = cryptsetup-nuke-password ]; then
21 # /usr/lib/cryptsetup/askpass is still diverted in the same way as our
22 # preinst did. Conclude that cryptsetup-nuke-password was installed
23 # during preinst, we duplicated the diversion and now
24 # cryptsetup-nuke-password is removed. We have to clean up.
25 echo "Removing duplicated diversion of /usr/lib/cryptsetup/askpass after cryptsetup-nuke-password is removed."
26 dpkg-divert --rename --package cryptsetup-nuke-password \
27 --divert /usr/lib/cryptsetup/askpass.usr-is-merged \
28 --remove /usr/lib/cryptsetup/askpass
29 fi
30 # end-remove-after
31
32 case "$1" in
33 configure)
34 for file in cryptdisks_start cryptdisks_stop; do
35 if [ ! -e "/usr/sbin/$file" ]; then
36 ln -s "/sbin/$file" "/usr/sbin/$file"
37 fi
38 done
39
40 # Do a number of checks on the currently installed crypttab
41 . /lib/cryptsetup/functions
42 crypttab_foreach_entry crypttab_parse_options || true
43 ;;
44
45 abort-upgrade|abort-remove|abort-deconfigure)
46
47 ;;
48
49 *)
50 echo "postinst called with unknown argument \`$1'" >&2
51 exit 1
52 ;;
53 esac
54
55 # dh_installdeb will replace this with shell code automatically
56 # generated by other debhelper scripts.
57
58 #DEBHELPER#
59
60 # try to remove /etc/init if it exists, it's empty and isn't owned
61 # NOTE: this needs to placed *after* the dh_installdeb-replaced snippet
62 # which contains calls to `dpkg-maintscript-helper rm_conffile`
63 if [ "$1" = "configure" ] && [ -d /etc/init ] && dpkg --compare-versions -- "${2-}" lt "2:2.4.0-1" && \
64 ! { dpkg-query -S /etc/init >/dev/null 2>&1 || [ $? -ne 1 ]; } then
65 rmdir --ignore-fail-on-non-empty /etc/init
66 fi
67
68 exit 0