source: trunk/debathena/config/apparmor-config/debian/debathena-apparmor-config.postinst @ 24726

Revision 24726, 2.6 KB checked in by broder, 14 years ago (diff)
In apparmor-config: * Cleanup /etc/apparmor.d/tunables/home diversion when we upgrade to a release that has <tunables/home.d> (i.e. Lucid)
Line 
1#!/bin/sh
2# postinst script for debathena-apparmor-config
3#
4# see: dh_installdeb(1)
5
6set -e
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#        * <postinst> `abort-remove'
14#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15#          <failed-install-package> <version> `removing'
16#          <conflicting-package> <version>
17# for details, see http://www.debian.org/doc/debian-policy/ or
18# the debian-policy package
19
20# dh_installdeb will replace this with shell code automatically
21# generated by other debhelper scripts.
22
23#DEBHELPER#
24
25package=debathena-apparmor-config
26ours=.debathena
27theirs=.debathena-orig
28
29undivert_unlink_symlink()
30{
31    file="$1"
32    ourfile="$2"
33    theirfile="$3"
34    if [ ! -L "$file" ] || \
35        [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
36          "$(readlink "$file")" != "$(basename "$theirfile")" ]; then
37        echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
38    else
39        rm -f "$file"
40    fi
41}
42
43undivert_unlink_divert()
44{
45    file="$1"
46    if [ ! -L "$file" ] && [ ! -e "$file" ]; then
47        dpkg-divert --remove --rename --package "$package" "$file"
48    else
49        echo "Not removing diversion of $file by $package" >&2
50    fi
51}
52
53undivert_unlink()
54{
55    prefix=$1
56    suffix=$2
57
58    file=$prefix$suffix
59    ourfile=$prefix$ours$suffix
60    theirfile=$prefix$theirs$suffix
61
62    undivert_unlink_symlink "$file" "$ourfile" "$theirfile"
63    undivert_unlink_divert "$file" "$package"
64}
65
66cleanup_old_diversion() {
67    file="$1"
68    if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${file}${theirs} by ${package}"; then
69        undivert_unlink "$file"
70    fi
71}
72
73cleanup_old_removal() {
74    file="$1"
75    removedfile="$2"
76    if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${removedfile} by ${package}"; then
77        undivert_unlink_divert "$file"
78    fi
79}
80
81case "$1" in
82    configure)
83        if [ -d /etc/apparmor.d/tunables/home.d ]; then
84            cleanup_old_diversion /etc/apparmor.d/tunables/home
85        fi
86
87        if hash apparmor_status 2>/dev/null && apparmor_status --enabled; then
88            if hash invoke-rc.d 2>/dev/null; then
89                invoke-rc.d apparmor reload
90            else
91                /etc/init.d/apparmor reload
92            fi
93        fi
94    ;;
95
96    abort-upgrade|abort-remove|abort-deconfigure)
97    ;;
98
99    *)
100        echo "postinst called with unknown argument \`$1'" >&2
101        exit 1
102    ;;
103esac
104
105exit 0
Note: See TracBrowser for help on using the repository browser.