From 4360c9b4faa07323049822d4c8e9231000950c3bede6a1963d1e336a1f2ca361 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Fri, 14 Jan 2011 12:54:21 +0000 Subject: [PATCH] Accepting request 57985 from home:lnussel:branches:Base:System OBS-URL: https://build.opensuse.org/request/show/57985 OBS-URL: https://build.opensuse.org/package/show/Base:System/kbd?expand=0&rev=23 --- kbd.changes | 6 ++ kbd.init | 153 ++++++++++++++++++++++++--------------------- sysconfig.keyboard | 6 +- 3 files changed, 92 insertions(+), 73 deletions(-) diff --git a/kbd.changes b/kbd.changes index e8a8fea..aa0f824 100644 --- a/kbd.changes +++ b/kbd.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Jan 12 14:22:09 UTC 2011 - lnussel@suse.de + +- use /etc/defkeymap.name if possible to avoid find call +- move some code that is only needed for start to actual start section + ------------------------------------------------------------------- Tue Sep 7 14:48:34 CEST 2010 - anicka@suse.cz diff --git a/kbd.init b/kbd.init index c72d652..c57c405 100644 --- a/kbd.init +++ b/kbd.init @@ -37,76 +37,14 @@ test -n "$KBD_VERBOSE" && set -x +# XXX: is this really needed just for LOCALE_CHARMAP? test -e /etc/SuSEconfig/profile && . /etc/SuSEconfig/profile test -e /etc/profile.d/lang.sh && . /etc/profile.d/lang.sh LOCALE_CHARMAP=`locale charmap` LC_ALL=POSIX -MACHINE=`/bin/uname -m 2> /dev/null` -if test "$MACHINE" = "sparc" -o "$MACHINE" = "sparc64" ; then - # Test if we have a serial console. - (test -c /dev/tty1 && > /dev/tty1 ) > /dev/null 2>&1 || exit 0 -fi -# iSeries machines also exit, just a little further down... - -# The variable NON_SUSE_KERNEL determines whether we need to chvt -# to a console before some console settings apply. -# We have no magic to find out about this (at boot time), so we -# leave it to the user to read this comment and put NON_SUSE_KERNEL="yes" -# into /etc/sysconfig/console - -test "$NON_SUSE_KERNEL" = "yes" && FGCONS=`/bin/fgconsole` - KBDBASE="/usr/share/kbd" -# -# first search the wanted keytable. -# -if test $MACHINE = ppc -o $MACHINE = ppc64 ; then - test -f /proc/cpuinfo || mount -n -t proc proc /proc 2>/dev/null - while read line; do - case "$line" in - *MacRISC*) MACHINE="mac" - test -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes && \ - echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes - ;; - *CHRP*) MACHINE="chrp";; - *PReP*) MACHINE="prep" ;; - *PS3*) MACHINE="ps3" ;; - *iSeries*) exit 0 ;; - esac - done < /proc/cpuinfo -fi - -# -# Calculate KBD_TTY array only once -# - -KBD_TTY_DEFAULT="${KBD_TTY:-tty1 tty2 tty3 tty4 tty5 tty6}" - -newkbd="" -for tty in $KBD_TTY_DEFAULT; do - # >=tty7 left out intentionaly (Bug #302010) - test ${tty#tty} -ge 7 2>/dev/null && continue - test -w /dev/$tty || continue - test -c /dev/$tty || continue - > /dev/$tty &> /dev/null || continue - newkbd="${newkbd:+$newkbd }/dev/$tty" -done -KBD_TTY="$newkbd" -unset newkbd - -KEYMAP=() -if test -e /$KEYTABLE ; then - KEYMAP=($KEYTABLE) -else - case "$KEYTABLE" in - *.gz) KBDPATH="*/${KEYTABLE}" ;; - *.map) KBDPATH="*/${KEYTABLE} */${KEYTABLE}.gz" ;; - *) KBDPATH="*/${KEYTABLE} */${KEYTABLE}.gz */${KEYTABLE}.map.gz */${KEYTABLE}.map" ;; - esac - KEYMAP=($(find ${KBDBASE}/keymaps -type f \( -path ${KBDPATH// / -o -path } \) | sort)) -fi # # setup kbdrate and led status # @@ -228,6 +166,80 @@ case "$1" in test -s /var/run/keymap && exit 0 ;; esac + + MACHINE=`/bin/uname -m 2> /dev/null` + if test "$MACHINE" = "sparc" -o "$MACHINE" = "sparc64" ; then + # Test if we have a serial console. + (test -c /dev/tty1 && > /dev/tty1 ) > /dev/null 2>&1 || exit 0 + fi + # iSeries machines also exit, just a little further down... + + # The variable NON_SUSE_KERNEL determines whether we need to chvt + # to a console before some console settings apply. + # We have no magic to find out about this (at boot time), so we + # leave it to the user to read this comment and put NON_SUSE_KERNEL="yes" + # into /etc/sysconfig/console + + test "$NON_SUSE_KERNEL" = "yes" && FGCONS=`/bin/fgconsole` + + # + # first search the wanted keytable. + # + if test $MACHINE = ppc -o $MACHINE = ppc64 ; then + test -f /proc/cpuinfo || mount -n -t proc proc /proc 2>/dev/null + while read line; do + case "$line" in + *MacRISC*) MACHINE="mac" + test -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes && \ + echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes + ;; + *CHRP*) MACHINE="chrp";; + *PReP*) MACHINE="prep" ;; + *PS3*) MACHINE="ps3" ;; + *iSeries*) exit 0 ;; + esac + done < /proc/cpuinfo + fi + + KBD_TTY_DEFAULT="${KBD_TTY:-tty1 tty2 tty3 tty4 tty5 tty6}" + + newkbd="" + for tty in $KBD_TTY_DEFAULT; do + # >=tty7 left out intentionaly (Bug #302010) + test ${tty#tty} -ge 7 2>/dev/null && continue + test -w /dev/$tty || continue + test -c /dev/$tty || continue + > /dev/$tty &> /dev/null || continue + newkbd="${newkbd:+$newkbd }/dev/$tty" + done + KBD_TTY="$newkbd" + unset newkbd + + KEYMAP=() + if test -r /etc/defkeymap.name; then + read cached < /etc/defkeymap.name + a="${cached##*/}" + a="${a%.gz}" + a="${a%.map}" + b="${KEYTABLE%.gz}" + b="${b%.map}" + if [ -n "$a" -a "$a" = "$b" ]; then + KEYMAP=("$cached") + fi + unset a b + fi + if test -z "$KEYMAP"; then + if test -e /$KEYTABLE ; then + KEYMAP=($KEYTABLE) + else + case "$KEYTABLE" in + *.gz) KBDPATH="*/${KEYTABLE}" ;; + *.map) KBDPATH="*/${KEYTABLE} */${KEYTABLE}.gz" ;; + *) KBDPATH="*/${KEYTABLE} */${KEYTABLE}.gz */${KEYTABLE}.map.gz */${KEYTABLE}.map" ;; + esac + KEYMAP=($(find ${KBDBASE}/keymaps -type f \( -path ${KBDPATH// / -o -path } \) | sort)) + fi + fi if test "$MACHINE" = "ps3" ; then # do not mess up console @@ -283,7 +295,6 @@ case "$1" in fi fi - if test -z "$KEYTABLE"; then echo "No keyboard map to load" else @@ -413,27 +424,29 @@ case "$1" in case "$RUNLEVEL" in S|N|1|\#) true ;; *) - trap "rm -f /dev/shm/defkeymap.map" EXIT SIGTERM + map=`mktemp --tmpdir keymap.XXXXXX` && { + trap "rm -f $map" EXIT SIGTERM if test -n "$KBD_TTY" ; then dumpkeys -C ${KBD_TTY%% *} else dumpkeys - fi > /dev/shm/defkeymap.map + fi > $map - if type -p cmp > /dev/null 2>&1 && cmp -s /etc/defkeymap.map /dev/shm/defkeymap.map + if type -p cmp > /dev/null 2>&1 && cmp -s /etc/defkeymap.map $map then - rm -f /dev/shm/defkeymap.map + rm -f $map fi - if test -s /dev/shm/defkeymap.map ; then + if test -s $map; then # FIXME: this should be done much earlier # to avoid bugzilla# 259694 or similar. - mv /dev/shm/defkeymap.map /etc/defkeymap.map + mv $map /etc/defkeymap.map if test "${#KEYMAP[@]}" -gt 0 -a "$KEYMAP" != "/etc/defkeymap.map" ; then echo $KEYMAP > /etc/defkeymap.name fi fi trap - EXIT SIGTERM + } esac ;; diff --git a/sysconfig.keyboard b/sysconfig.keyboard index 4c6e632..da63635 100644 --- a/sysconfig.keyboard +++ b/sysconfig.keyboard @@ -54,11 +54,11 @@ KBD_CAPSLOCK="no" KBD_DISABLE_CAPS_LOCK="no" ## Type: string -## Default: "tty1 tty2 tty3 tty4 tty5 tty6" +## Default: # # ttys for the above settings # Example: "tty1 tty2" -# "" for all tty's +# "" for tty's 1-6 # -KBD_TTY="tty1 tty2 tty3 tty4 tty5 tty6" +KBD_TTY=""