#!/bin/sh # postinst script for debathena-apparmor-config # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# package=debathena-apparmor-config ours=.debathena theirs=.debathena-orig undivert_unlink_symlink() { file="$1" ourfile="$2" theirfile="$3" if [ ! -L "$file" ] || \ [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \ "$(readlink "$file")" != "$(basename "$theirfile")" ]; then echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2 else rm -f "$file" fi } undivert_unlink_divert() { file="$1" if [ ! -L "$file" ] && [ ! -e "$file" ]; then dpkg-divert --remove --rename --package "$package" "$file" else echo "Not removing diversion of $file by $package" >&2 fi } undivert_unlink() { prefix=$1 suffix=$2 file=$prefix$suffix ourfile=$prefix$ours$suffix theirfile=$prefix$theirs$suffix undivert_unlink_symlink "$file" "$ourfile" "$theirfile" undivert_unlink_divert "$file" "$package" } cleanup_old_diversion() { file="$1" if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${file}${theirs} by ${package}"; then undivert_unlink "$file" fi } cleanup_old_removal() { file="$1" removedfile="$2" if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${removedfile} by ${package}"; then undivert_unlink_divert "$file" fi } case "$1" in configure) if [ -d /etc/apparmor.d/tunables/home.d ]; then cleanup_old_diversion /etc/apparmor.d/tunables/home fi # Ensure local files exist # This should be replaced with something less stupid if fgrep -q '#include /dev/null && apparmor_status --enabled; then if hash invoke-rc.d 2>/dev/null; then invoke-rc.d apparmor reload else /etc/init.d/apparmor reload fi fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac exit 0