[24702] | 1 | #!/bin/sh |
---|
| 2 | # postinst script for debathena-apparmor-config |
---|
| 3 | # |
---|
| 4 | # see: dh_installdeb(1) |
---|
| 5 | |
---|
| 6 | set -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 | |
---|
[24709] | 20 | # dh_installdeb will replace this with shell code automatically |
---|
| 21 | # generated by other debhelper scripts. |
---|
| 22 | |
---|
| 23 | #DEBHELPER# |
---|
| 24 | |
---|
[24726] | 25 | package=debathena-apparmor-config |
---|
| 26 | ours=.debathena |
---|
| 27 | theirs=.debathena-orig |
---|
| 28 | |
---|
| 29 | undivert_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 | |
---|
| 43 | undivert_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 | |
---|
| 53 | undivert_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 | |
---|
| 66 | cleanup_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 | |
---|
| 73 | cleanup_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 | |
---|
[24702] | 81 | case "$1" in |
---|
| 82 | configure) |
---|
[24726] | 83 | if [ -d /etc/apparmor.d/tunables/home.d ]; then |
---|
| 84 | cleanup_old_diversion /etc/apparmor.d/tunables/home |
---|
| 85 | fi |
---|
| 86 | |
---|
[25174] | 87 | # Ensure local files exist |
---|
[25184] | 88 | if [ -x /usr/bin/dh_apparmor ]; then |
---|
| 89 | mkdir -p /etc/apparmor.d/local |
---|
| 90 | for f in usr.sbin.cupsd usr.sbin.ntpd; do |
---|
| 91 | [ -f "/etc/apparmor.d/local/$f" ] || touch "/etc/apparmor.d/local/$f" |
---|
| 92 | done |
---|
| 93 | fi |
---|
[25174] | 94 | |
---|
[24703] | 95 | if hash apparmor_status 2>/dev/null && apparmor_status --enabled; then |
---|
| 96 | if hash invoke-rc.d 2>/dev/null; then |
---|
| 97 | invoke-rc.d apparmor reload |
---|
| 98 | else |
---|
| 99 | /etc/init.d/apparmor reload |
---|
| 100 | fi |
---|
[24702] | 101 | fi |
---|
| 102 | ;; |
---|
| 103 | |
---|
| 104 | abort-upgrade|abort-remove|abort-deconfigure) |
---|
| 105 | ;; |
---|
| 106 | |
---|
| 107 | *) |
---|
| 108 | echo "postinst called with unknown argument \`$1'" >&2 |
---|
| 109 | exit 1 |
---|
| 110 | ;; |
---|
| 111 | esac |
---|
| 112 | |
---|
| 113 | exit 0 |
---|