#!/bin/sh -e # This script can be called in the following ways: # # Before the package is installed: # install # # Before removed package is upgraded: # install # # Before the package is upgraded: # upgrade # # # If postrm fails during upgrade or fails on failed upgrade: # abort-upgrade set -e pathfind() { OLDIFS="$IFS" IFS=: for p in $PATH; do if [ -x "$p/$*" ]; then IFS="$OLDIFS" return 0 fi done IFS="$OLDIFS" return 1 } case "$1" in install) ;; upgrade) # 2.3.0 is not compatible with 2.2.x. Thus we need to create a new db. # Otherwise, the kernel will panic on boot if dpkg --compare-versions "$2" lt 2.4.0-20111025-1; then if [ -d /etc/tomoyo ]; then mv -f /etc/tomoyo /etc/tomoyo.old.$2; fi fi # 2.6 series requires Linux 5.1 and above, also Linux 5.1 does NOT need to specify "security=tomoyo" # tomoyo2.6 + < Linux 5.1 = panic, so old "security=tomoyo" should remove for safety if eval "dpkg --compare-versions "$2" lt 2.6.0-20190305-1 && \ grep -q "^GRUB_CMDLINE_LINUX=.*security=tomoyo.*" /etc/default/grub && \ pathfind update-grub"; then sed -e 's/security=tomoyo//' -i /etc/default/grub && update-grub fi ;; abort-upgrade) ;; *) echo "$0 called with unknown argument \`$1'" 1>&2 exit 1 ;; esac exit 0