File: preinst

package info (click to toggle)
linpopup 1.2.0-7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 600 kB
  • ctags: 251
  • sloc: ansic: 2,885; sh: 250; makefile: 223
file content (85 lines) | stat: -rw-r--r-- 1,905 bytes parent folder | download | duplicates (5)
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
79
80
81
82
83
84
85
#!/bin/sh
# linpopup preinst

set -e


yesno() {
    retval=$1
    question="$2"
    while :
    do
        echo -n "$question"
        read ans
        case "x$ans" in
            x[yY]*)     return 0;;
            x[nN]*)     return 1;;
            x)          return $retval;;  # default
            x*)         echo "Please respond with y or n";;
        esac
    done
}


case "$1" in
    install)
        if [ ! -s /var/state/misc/linpopup ] # nothing in that file
        then
            exit 0
        fi
        if [ "x$2" = "x" ]  # nothing was supposed to be installed already
        then
            rm -f /var/state/misc/linpopup
            exit 0
        fi
        if `dpkg --compare-versions $2 ge 0.9.4`
        then
            rm -f /var/state/misc/linpopup
            exit 0
        fi
        cat << EOF
NOTICE:
-------
The messages file left over from your previous installation of linpopup is no
longer readable by the current version. Sorry. It will be removed.

EOF
        rm -f /var/state/misc/linpopup
        exit 0
        ;;


    upgrade)
        if [ ! -s /var/state/misc/linpopup ] # nothing in that file
        then
            exit 0
        fi
        if `dpkg --compare-versions $2 ge 0.9.4`
        then
            exit 0
        fi
        cat << EOF
NOTICE:
-------
You currently have a version of linpopup which uses a messages file that is
not compatible with the version you're about to install. Installing this
new version will mean that you will not be able to read any messages you
currently have stored in this file.

EOF
        if yesno 0 'Continue with the install? [Y/n] '
        then
            rm -f /var/state/misc/linpopup
            exit 0
        fi
        exit 1
        ;;


    abort-upgrade)
        # should I do anything here?
        ;;
    *)
        echo "preinst called with unexpected argument '$1', ignored."
        ;;
esac