File: postinst

package info (click to toggle)
emacspeak 29.0-9
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 12,904 kB
  • sloc: xml: 55,354; lisp: 48,335; cpp: 2,321; tcl: 1,500; makefile: 936; python: 836; sh: 785; perl: 459; ansic: 241
file content (120 lines) | stat: -rw-r--r-- 3,221 bytes parent folder | download | duplicates (8)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#! /bin/sh
# postinst script for emacspeak
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#

case "$1" in
    configure)
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# original config file was missing the `$' characters on the variable names
# insert them if necessary
if [ -f /etc/emacspeak.conf ]; then
    sed 's/^if  *\[  *"DTK/if \[ "$DTK/' /etc/emacspeak.conf >/etc/temp.$$
    mv /etc/temp.$$ /etc/emacspeak.conf
    if grep 'export' /etc/emacspeak.conf >/dev/null; then
	true;
    else
	cat >>/etc/emacspeak.conf <<\EOF
export DTK_PROGRAM DTK_PORT DTK_TCL
EOF
    fi
fi

# pre-debconf method
#emacspeakconfig -i

# update the emacspeak config file, as recommended in debconf-devel(7),
# section "Config file handling"
. /usr/share/debconf/confmodule
CONFIGFILE=/etc/emacspeak.conf

# if there is no configuration file, then create one
if [ ! -e $CONFIGFILE ]; then
cat >$CONFIGFILE  <<\EOF
# emacspeak configuration file
#
#
if [ "$DTK_PROGRAM" = "" ]; then
  DTK_PROGRAM=
fi
if [ "$DTK_TCL" = "" ]; then
  DTK_TCL=
fi
if [ "$DTK_PORT" = "" ]; then
  DTK_PORT=
fi
if [ "$DTK_DEVICE" = "" ]; then
  DTK_DEVICE=
fi
export DTK_PROGRAM DTK_PORT DTK_DEVICE
if [ "$DTK_TCL" != "" ]; then export DTK_TCL; fi
EOF
fi

# Substitute in the values from the debconf db.
db_get shared/emacspeak/program
DTK_PROGRAM="$RET"
db_get shared/emacspeak/tcl
DTK_TCL="$RET"
db_get shared/emacspeak/port
DTK_PORT="$RET"
db_get shared/emacspeak/device
DTK_DEVICE="$RET"

# This cp ensures we do not mess up
# the config file's ownership and permissions.
cp -a -f $CONFIGFILE $CONFIGFILE.tmp

# If the admin deleted or commented some variables but then set
# them via debconf, (re-)add them to the conffile.
test -z "$DTK_PROGRAM" || grep -Eq '^ *DTK_PROGRAM=' $CONFIGFILE || \
    echo "DTK_PROGRAM=" >> $CONFIGFILE
test -z "$DTK_TCL" || grep -Eq '^ *DTK_TCL=' $CONFIGFILE || \
    echo "DTK_TCL=" >> $CONFIGFILE
test -z "$DTK_PORT" || grep -Eq '^ *DTK_PORT=' $CONFIGFILE || \
    echo "DTK_PORT=" >> $CONFIGFILE
test -z "$DTK_DEVICE" || grep -Eq '^ *DTK_DEVICE=' $CONFIGFILE || \
    echo "DTK_DEVICE=" >> $CONFIGFILE

# the strings can contain slashes, so use something else to delimit patterns
sed -e "s|^ *DTK_PROGRAM=.*|DTK_PROGRAM=$DTK_PROGRAM|" \
    -e "s|^ *DTK_TCL=.*|DTK_TCL=$DTK_TCL|" \
    -e "s|^ *DTK_PORT=.*|DTK_PORT=$DTK_PORT|" \
    -e "s/^ *DTK_DEVICE=.*/DTK_DEVICE=\"$DTK_DEVICE\"/" \
    < $CONFIGFILE > $CONFIGFILE.tmp
mv -f $CONFIGFILE.tmp $CONFIGFILE


# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0