File: console-common.preinst

package info (click to toggle)
console-common 0.7.49
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 724 kB
  • ctags: 67
  • sloc: perl: 519; sh: 341; makefile: 135; awk: 134
file content (175 lines) | stat: -rw-r--r-- 5,415 bytes parent folder | download
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#! /bin/sh

set -e

# Rename old local keymaps dir if any
if [ -d /usr/local/share/keytables ]
then
    if [ -d "`readlink -f /usr/local/share/keymaps`" ]
    then
	files=`find /usr/local/share/keytables -mindepth 1 -maxdepth 1`
        [ "$files" ] && mv $files /usr/local/share/keymaps/
        rmdir /usr/local/share/keytables
    elif [ -e /usr/local/share/keymaps ]
    then
        echo >&2 "/usr/local/share/keymaps is buggy - please check it"
        ls -ld /usr/local/share/keymaps >&2
        echo >&2 "Press RETURN to continue"
        read foo
    else
        mv /usr/local/share/keytables /usr/local/share/keymaps
    fi
elif [ -e /usr/local/share/keytables ]
then
    echo >&2 <<EOF
/usr/local/share/keytables is not a dir.  I won\'t try to mess
with it and you will surely want to do something with it, as the
new location for local keymaps is now /usr/local/share/keymaps/.

Press RETURN to continue
EOF
    read foo
fi


# Import local files from obsolete /usr/lib/kbd directory
if [ -d /usr/lib/kbd ]
then
    echo >&2 Importing local files from obsolete /usr/lib/kbd directory into /usr/local/:
    set +e	# there may be no files in those directories !
    for d in keytables consolefonts consoletrans videomodes; do
	# if the dir exists and is not a link (into /usr/share)
	if [ -d /usr/lib/kbd/${d} -a ! -L /usr/lib/kbd/${d} ]
	then
	    # maybe create local dir
	    test -d /usr/local/share/${d} || mkdir -p /usr/local/share/${d}
	    files=`find /usr/lib/kbd/${d} -mindepth 1 -maxdepth 1`
	    [ "$files" ] && mv $files /usr/local/share/${d}/
	    rmdir /usr/lib/kbd/${d}
	fi
	# remove an eventual symlink
	rm -f /usr/lib/kbd/${d}
    done
    set -e
    echo >&2 " done importing."
    # try to remove the old dir, but be nice when not empty
    rmdir /usr/lib/kbd 2>/dev/null || echo >&2 <<EOF 
WARNING: /usr/lib/kbd/ not removed - other files there ?
Check this and remove it by hand.
EOF
fi

. /usr/share/debconf/confmodule

if db_get console-data/keymap/qwertz/german/standard/keymap && [ "$RET" = "Standard" ];
then
    db_set console-data/keymap/qwertz/german/standard/keymap Programmer
fi

# Remove some old, dodgy entries from the database
if [ "$1" = configure ] && dpkg --compare-versions "$2" lt 0.7.24  ; then
    db_unregister console-data/keymap/full || true
    db_unregister console-data/keymap/azerty/french/variant || true
    db_unregister console-data/keymap/qwertz || true
fi

# Wipe old dodgy escaped values from db too. Closes: #254324.
if db_get console-data/keymap/policy && [ "$RET" = "Don\'t touch keymap" ];
then
  db_set console-data/keymap/policy "Don't touch keymap"
fi

# If the entry contains a / it's broken so overwrite it with a default
# value.  See see #110873
if db_get console-data/keymap/full && echo "$RET" | grep -q "/";
then
    db_set console-data/keymap/full us
fi


# Ensure we don't step on a hand-edited /etc/console/boottime.kmap.gz
BOOT_MAP=/etc/console/boottime.kmap.gz
MD="none"
[ -r $BOOT_MAP ] && MD=`md5sum $BOOT_MAP |  cut -d' ' -f1 `
if  db_get console-data/bootmap-md5sum && [ "$RET" != "$MD" ] ; then
   db_set console-data/keymap/policy "Don't touch keymap"
fi

db_get console-data/keymap/family
CFAMILY=`echo $RET | perl -pe '$_ = lc; s/[^a-z0-9+\-\.\/\n]/_/g';`
LAYOUT=console-data/keymap/$CFAMILY/layout

# Is there a chance that a user-provided keymap has to imported ?
# Let's cross our fingers... it should never break, but...
if db_get $LAYOUT && [ -x /usr/share/console/getkmapchoice.pl ];
then
   # Protect against failure of getkmapchoice.pl by locally turning
   # off set -e.
   set +e
   choice="$(PERL_BADLANG=0 /usr/share/console/getkmapchoice.pl 2>&1)"
   if [ $? != 0 ]; then
      # See comment below
      choice="useless"
   fi
   set -e
else
    # if getkmapchoice is not there, assume the user never had the
    # oportunity to select no keymap to be installed using the
    # console-common framework
    choice="useless"
fi


# Maybe import boottime keymap

if [ "$choice" != KERNEL -a "$choice" != NONE -a ! -r /etc/console/boottime.kmap.gz ]
then
    # if we have to move a file, we need this dir
    mkdir -p /etc/console

    if dpkg --status console-tools 2>/dev/null | grep -q '^Status: .* installed$'; then
	# take it from console-tools

	if [ -r /etc/console-tools/default.kmap.gz ]
	then
	    mv /etc/console-tools/default.kmap.gz /etc/console/boottime.kmap.gz
	elif [ -r /etc/console-tools/default.kmap ]
	then
	    gzip -9f /etc/console-tools/default.kmap
	    mv /etc/console-tools/default.kmap.gz /etc/console/boottime.kmap.gz
	fi

	if [ -r /etc/console/boottime.kmap.gz ]
	then
	    echo >&2 "Imported boot-time keymap from old console-tools settings"
	fi

    elif dpkg --status kbd 2>/dev/null | grep -q '^Status: .* installed$'; then
	# take it from kbd

	if [ -r /etc/kbd/default.kmap.gz ]
	then
	    mv /etc/kbd/default.kmap.gz /etc/console/boottime.kmap.gz
	elif [ -r /etc/kbd/default.kmap ]
	then
	    gzip -9f /etc/kbd/default.kmap
	    mv /etc/kbd/default.kmap.gz /etc/console/boottime.kmap.gz
	elif [ -r /etc/kbd/default.map.gz ]
	then
	    mv /etc/kbd/default.map.gz /etc/console/boottime.kmap.gz
	elif [ -r /etc/kbd/default.map ]
	then
	    gzip -9f /etc/kbd/default.map
	    mv /etc/kbd/default.map.gz /etc/console/boottime.kmap.gz
	fi

	if [ -r /etc/console/boottime.kmap.gz ]
	then
	    echo >&2 "Imported boot-time keymap from old kbd settings"
	fi

    fi
fi

#DEBHELPER#