summaryrefslogtreecommitdiffstats
path: root/debian/firmware-ipw2x00.preinst
blob: 5900671817bbdaa7124da6189bc2a2343bad6936 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh

set -e

. /usr/share/debconf/confmodule
db_version 2.0
db_capb backup

#Valid values are "required" and "no-preseed"
license_accept=required

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

ask()
{
    # 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
            db_get firmware-ipw2x00/license/accepted
            if [ "$RET" != true -o "${license_accept}" = "no-preseed" ]; then
                db_fset firmware-ipw2x00/license/accepted seen false
                if ! db_input critical firmware-ipw2x00/license/accepted ; then
                    errmsg "firmware-ipw2x00 agree question could not be asked"
                    exit 2
                fi
            fi
            ;;      
        2)  # determine users' choice
            db_get firmware-ipw2x00/license/accepted
            if [ "$RET" = "true" ]; then
                exit 0
            fi
            # error on decline license (give user chance to back up)
            db_input critical firmware-ipw2x00/license/error
            ;;      
        3)
            echo "user did not accept the firmware-ipw2x00 license" >&2
            exit 1
            ;;
        *)  # unknown state
            echo "firmware-ipw2x00 license state unknown: $STATE" >&2
            exit 2
            ;;   
        esac
        if db_go; then
            STATE=$(($STATE + 1))
        else
            STATE=$(($STATE - 1))
        fi
    done
}

if [ "$FIRMWARE_IPW2X00_LICENSE_READ_AND_ACCEPTED" = yes ]; then
    db_set firmware-ipw2x00/license/accepted true
fi

db_get firmware-ipw2x00/license/accepted
if [ "$RET" != "true" ]; then
    ask
    RESULT=$?
    [ "$RESULT" = 0 ] || exit $RESULT
fi
 
#DEBHELPER#

exit 0