summaryrefslogtreecommitdiffstats
path: root/debian/preinst
blob: 9ff6b11cad22f2c9d8a68b7588ecc42defabaf9e (plain)
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
#!/bin/sh
set -e

#DEBHELPER#

# Source debconf library.
. /usr/share/debconf/confmodule

errmsg()
{
    echo >&2 ''
    echo >&2 "$@"
    echo >&2 "try 'dpkg-reconfigure debconf' to select a frontend other than noninteractive"
    echo >&2 ''
}

db_get virtualbox-ext-pack/license
if [ "$RET" = "true" ]; then
    echo "License has already been accepted." >&2
    exit 0
else
    # show license again
    db_fset virtualbox-ext-pack/license seen false
fi

# facilitate backup capability per debconf-devel(7)
STATE=1
while true; do
    case "$STATE" in
    0)  # ensure going back from license presentment is harmless
        STATE=1
        continue
        ;;
    1)  # present license
        if ! db_get virtualbox-ext-pack/license ; then
            errmsg "Could not display license."
            exit 1
        fi
        if [ "$RET" = "true" ]; then
            # license accepted
            exit 0
        fi
        ;;
    2)  # user has confirmed declining license
        echo "User did not accept the license." >&2
        exit 1
        ;;
    *)  # unknown state
        echo "State unknown: $STATE" >&2
        exit 2
        ;;
    esac
    if db_go; then
        STATE=$(($STATE + 1))
    else
        STATE=$(($STATE - 1))
    fi
done

# proper exit (0 or 1) above
errmsg "License could not be presented / was not accepted."
exit 2