File: tomoyo-tools.preinst

package info (click to toggle)
tomoyo-tools 2.6.0-20201111-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,160 kB
  • sloc: ansic: 22,075; sh: 125; makefile: 98
file content (68 lines) | stat: -rw-r--r-- 1,597 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh -e

# This script can be called in the following ways:
#
# Before the package is installed:
#       <new-preinst> install
#
# Before removed package is upgraded:
#       <new-preinst> install <old-version>
#
# Before the package is upgraded:
#       <new-preinst> upgrade <old-version>
#
#
# If postrm fails during upgrade or fails on failed upgrade:
#       <old-preinst> abort-upgrade <new-version>

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

#DEBHELPER#

exit 0