~medibuntu-maintainers/medibuntu/googleearth-4.2.hardy

« back to all changes in this revision

Viewing changes to debian/googleearth-4.2.preinst

  • Committer: Lionel Le Folgoc
  • Date: 2008-04-21 13:58:17 UTC
  • Revision ID: mrpouit@ubuntu.com-20080421135817-oya4dkxn41t7ox3y
New 4.2 branch; based on the googleearth.hardy branch, r11.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
 
 
3
# Remove remaining dirs when upgrading (LP: #81698)
 
4
case $1 in upgrade)
 
5
        for i in kvw lang res resources xml; do
 
6
                if [ -d /usr/lib/googleearth/${i} ]; then
 
7
                        if  ! [ -h /usr/lib/googleearth/${i} ]; then
 
8
                                rm -rf /usr/lib/googleearth/${i};
 
9
                        fi
 
10
                fi
 
11
        done;;
 
12
esac
 
13
 
 
14
. /usr/share/debconf/confmodule
 
15
db_version 2.0
 
16
db_capb backup
 
17
 
 
18
license=googleearth-eula
 
19
 
 
20
errmsg()
 
21
{
 
22
    echo >&2 ''
 
23
    echo >&2 "$@"
 
24
    echo >&2 "try 'dpkg-reconfigure debconf' to select a frontend other than noninteractive"
 
25
    echo >&2 ''
 
26
}
 
27
 
 
28
db_get shared/accepted-$license
 
29
if [ "$RET" = "true" ]; then
 
30
    echo "$license has already been accepted" >&2
 
31
    exit 0
 
32
fi
 
33
 
 
34
# facilitate backup capability per debconf-devel(7)
 
35
STATE=1
 
36
while true; do
 
37
    case "$STATE" in
 
38
    0)  # ensure going back from license presentment is harmless
 
39
        STATE=1 
 
40
        continue
 
41
        ;;   
 
42
    1)  # present license
 
43
        db_fset shared/present-$license seen false
 
44
        if ! db_input critical shared/present-$license ; then
 
45
            errmsg "$license could not be presented"
 
46
            exit 2
 
47
        fi
 
48
        db_fset shared/accepted-$license seen false
 
49
        if ! db_input critical shared/accepted-$license ; then
 
50
            errmsg "$license agree question could not be asked"
 
51
            exit 2
 
52
        fi
 
53
        ;;      
 
54
    2)  # determine users' choice
 
55
        db_get shared/accepted-$license
 
56
        if [ "$RET" = "true" ]; then
 
57
            # license accepted
 
58
            exit 0
 
59
        fi
 
60
        # error on decline license (give user chance to back up)
 
61
        db_input critical shared/error-$license
 
62
        ;;      
 
63
    3)  # user has confirmed declining license
 
64
        echo "user did not accept the $license" >&2
 
65
        exit 1
 
66
        ;;   
 
67
    *)  # unknown state
 
68
        echo "$license state unknown: $STATE" >&2
 
69
        exit 2
 
70
        ;;   
 
71
    esac
 
72
    if db_go; then
 
73
        STATE=$(($STATE + 1))
 
74
    else
 
75
        STATE=$(($STATE - 1))
 
76
    fi
 
77
done
 
78
 
 
79
#DEBHELPER#
 
80
 
 
81
# proper exit (0 or 1) above
 
82
errmsg "$license could not be presented / was not accepted"
 
83
exit 2