diff options
Diffstat (limited to 'debian/molly-guard.preinst')
-rwxr-xr-x | debian/molly-guard.preinst | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/debian/molly-guard.preinst b/debian/molly-guard.preinst new file mode 100755 index 0000000..1dcd220 --- /dev/null +++ b/debian/molly-guard.preinst @@ -0,0 +1,73 @@ +#!/bin/sh +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * <new-preinst> `install' +# * <new-preinst> `install' <old-version> +# * <new-preinst> `upgrade' <old-version> +# * <old-preinst> `abort-upgrade' <new-version> +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + for cmd in halt poweroff reboot shutdown coldreboot ; do + truenameusr="$(dpkg-divert --truename "/usr/sbin/$cmd")" + truenamealias="$(dpkg-divert --truename "/sbin/$cmd")" + rename_flag=--no-rename + if test "$truenameusr" = "/usr/sbin/$cmd" && test "$truenamealias" = "/sbin/$cmd"; then + rename_flag=--rename + fi + if test "$truenameusr" = "/usr/sbin/$cmd"; then + dpkg-divert --package molly-guard --divert "/usr/sbin/$cmd.no-molly-guard" "$rename_flag" --add "/usr/sbin/$cmd" + elif test "$truenameusr" != "/usr/sbin/$cmd.no-molly-guard"; then + dpkg-divert --package molly-guard --no-rename --remove "/usr/sbin/$cmd" + dpkg-divert --package molly-guard --no-rename --divert "/usr/sbin/$cmd.no-molly-guard" --add "/usr/sbin/$cmd" + if test -e "$truenameusr" || test -h "$truenameusr"; then + mv "$truenameusr" "/usr/sbin/$cmd.no-molly-guard" + fi + fi + if test "$truenamealias" = "/sbin/$cmd"; then + # DEP17 M18 duplicated diversion. Can be --removed after trixie. + dpkg-divert --package molly-guard --divert "/sbin/$cmd.no-molly-guard.usr-is-merged" "$rename_flag" --add "/sbin/$cmd" + elif test "$truenamealias" != "/sbin/$cmd.no-molly-guard.usr-is-merged"; then + dpkg-divert --package molly-guard --no-rename --remove "/sbin/$cmd" + dpkg-divert --package molly-guard --no-rename --divert "/sbin/$cmd.no-molly-guard.usr-is-merged" --add "/sbin/$cmd" + if test -e "$truenamealias" || test -h "$truenamealias"; then + mv "$truenamealias" "/sbin/$cmd.no-molly-guard.usr-is-merged" + fi + fi + done + + for cmd in pm-hibernate pm-suspend pm-suspend-hybrid ; do + truename="$(dpkg-divert --truename "/usr/sbin/$cmd")" + if test "$truename" = "/usr/sbin/$cmd"; then + dpkg-divert --package molly-guard --divert "/usr/sbin/$cmd.no-molly-guard" --rename "/usr/sbin/$cmd" + elif test "$truename" != "/usr/sbin/$cmd.no-molly-guard"; then + dpkg-divert --package molly-guard --no-rename --remove "/usr/sbin/$cmd" + dpkg-divert --package molly-guard --divert "/usr/sbin/$cmd.no-molly-guard" --no-rename --add "/usr/sbin/$cmd" + if test -e "$truename" -o -h "$truename"; then + mv "$truename" "/usr/sbin/$cmd.no-molly-guard" + fi + fi + done + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 |