Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also include other keyboard mappings to support non-US keyboards #1781

Merged
merged 7 commits into from Apr 26, 2018

Conversation

jsmeix
Copy link
Member

@jsmeix jsmeix commented Apr 24, 2018

Also include other keyboard mappings to also support users with a non-US keyboard
because without the right keyboard mapping it could become an awful annoyance
to work in the recovery system.

  • Type: Bug Fix and Enhancement
    Actually this provides a workaround when in
    etc/scripts/system-setup.d/10-console-setup.sh
    the loadkeys /etc/dumpkeys.out fails.

  • Impact: Low and High
    For US-keyboard users the impact is at most low,
    for non-US-keyboard users the impact could be even critical.

  • How was this pull request tested?
    It works for me on a SUSE system.
    I don't know where on other systems the other keyboard mapping files are stored.
    But it is now at least a starting point that can be easily enhanced for other systems.

  • Brief description of the changes in this pull request:

By default the current keyboard mapping is dumped to etc/dumpkeys.out
so that it can be set during recovery system startup by
etc/scripts/system-setup.d/10-console-setup.sh
via loadkeys /etc/dumpkeys.out.

But depending on the keyboard mapping
the loadkeys /etc/dumpkeys.out command
may not work in the recovery system
so that some other keyboard mapping files
are also included so that the user can manually set
his keyboard mapping (e.g. via a command like loadkeys de-latin1).

This increases the recovery system size by about 1 MB
(an usual recovery system size is about 500 MB uncompressed)
but without the right keyboard mapping it could be an awful annoyance
to work in the recovery system.

…-US keyboard because without the right keyboard mapping it could become an awful annoyance to work in the recovery system.
@jsmeix jsmeix added enhancement Adaptions and new features bug The code does not do what it is meant to do labels Apr 24, 2018
@jsmeix jsmeix added this to the ReaR v2.4 milestone Apr 24, 2018
@jsmeix jsmeix self-assigned this Apr 24, 2018
@jsmeix
Copy link
Member Author

jsmeix commented Apr 24, 2018

@gdha @gozora @schabrolles
because my knowledge about keyboard setup is basically zero
(I did this pull request based on a lot of trial and error)
I would very much appreciate it if you could have a look.
Perhaps I did something stupid and the real solution is "just simple".

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

In my case the keyboad mapping on the original system
fails to load in the recovery system via loadkeys /etc/dumpkeys.out
with this error message:

adding map 3 violates explicit keymaps line

and I get a keyboard with a default (presumably US) layout
but actually I use a German qwertz keyboard.

On the original system I have a /etc/vconsole.conf file that contains

KEYMAP=de-latin1-nodeadkeys
FONT=eurlatgr.psfu
FONT_MAP=none
FONT_UNIMAP=

The unexpected thing is that in the recovery system
I can run loadkeys de-latin1-nodeadkeys
which "just works" so that one could assume
the dumped keyboad mapping on the original system
is not de-latin1-nodeadkeys but something different
but on the original system

# dumpkeys -f >/tmp/dumpkeys.out

# loadkeys de-latin1-nodeadkeys

# dumpkeys -f >/tmp/dumpkeys.de-latin1-nodeadkeys

# diff -s /tmp/dumpkeys.out /tmp/dumpkeys.de-latin1-nodeadkeys
Files /tmp/dumpkeys.out and /tmp/dumpkeys.de-latin1-nodeadkeys are identical

# loadkeys /tmp/dumpkeys.out

# loadkeys /tmp/dumpkeys.de-latin1-nodeadkeys 

so something subtle makes in the recovery system
loadkeys /etc/dumpkeys.out fail...

@gdha
Copy link
Member

gdha commented Apr 25, 2018

@jsmeix Perhaps it would be better we load all the keyboard keys like the plain Linux OS? Is lot of overhead but this way we have all keyboards. Just a though...

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

It is the -f1 in dumpkeys -f1 >$ROOTFS_DIR/etc/dumpkeys.out
in rescue/GNU/Linux/500_clone_keyboard_mappings.sh
that makes things fail:

# dumpkeys -f1 >/tmp/dumpkeys.out2

# loadkeys /tmp/dumpkeys.out2
adding map 3 violates explicit keymaps line

On none of my systems down to SLE10 a -f1
is mentioned in man dumpkeys.
It is always only plain -f and that works for me.

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

git log -p --follow usr/share/rear/rescue/GNU/Linux/500_clone_keyboard_mappings.sh
shows that the non-working -f1 was there since the beginning of git history
so that I have no idea if there was a reason or if it is just a typo.

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

@gdha
including the whole keymaps default directory /usr/share/kbd/keymaps/
increases the recovery system size by about 3 MB in my case

# du -hs /usr/share/kbd/keymaps
2.8M    /usr/share/kbd/keymaps

and I know that on POWER architecture the recovery system must be kept very small
(bigger recovery systems on POWER architecture can cause totally weird failures).

But I agree that it can be crucial that the recovery system supports any keyboad
in particular for system migration when the keyboard of the new hardware
may not be known in advance when "rear mkrescue" is run.

So - as always - the right way out is to introduce config variables
where the user can specify what he actually needs.
I will implement that...

@gozora
Copy link
Member

gozora commented Apr 25, 2018

@jsmeix honestly, my knowledge in this area is equal to 0 :-(

V.

@jsmeix jsmeix removed the request for review from gozora April 25, 2018 10:47
@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

@gozora
no worries!
My knowledge in this area was equal to 0 but meanwhile it became a little bit more ;-)

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

An addedum to
#1781 (comment)

Interestingly on SLE10 things work with dumpkeys -f1

# dumpkeys -f1 >/tmp/dumpkeys.out

# loadkeys /tmp/dumpkeys.out && echo OK
Loading /tmp/dumpkeys.out
OK

but also with plain dumpkeys -f

# dumpkeys -f >/tmp/dumpkeys.out

# loadkeys /tmp/dumpkeys.out && echo OK
Loading /tmp/dumpkeys.out
OK

and there is no -f1 described in man dumpkeys or via dumpkeys -h on SLE10:

# man dumpkeys
...
SYNOPSIS
       dumpkeys [ -hilfn -ccharset --help --short-info --long-info --numeric --full-table --funcs-only --keys-only --compose-only --charset=charset ]
...
       -f --full-table
              This makes dumpkeys skip all the short-hand heuristics (see keymaps(5)) and output the key bindings in the canonical form. First a keymaps  line  describing
              the  currently defined modifier combinations is printed. Then for each key a row with a column for each modifier combination is printed. For example, if the
              current keymap in use uses seven modifiers, every row will have seven action code columns. This format can be useful for example to programs that  post-pro‐
              cess the output of dumpkeys.

# dumpkeys -h
dumpkeys version 1.12
...
       -f --full-table     don't use short-hand notations, one row per keycode

so that I will use plain dumpkeys -f in /rescue/GNU/Linux/500_clone_keyboard_mappings.sh

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

Since
e626787
including and setting keyboard mappings in the recovery system
works well for me (and sufficiently fail-safe) for the first time.

Now there are the new (but intentionally not yet documented) config variables

KEYMAPS_DEFAULT_DIRECTORY which specifies the default directory for keymaps

KEYMAPS_DIRECTORIES which is a string of keymap directories that should
get included in the recovery system

KEYMAP which is a keymap file for loadkeys in the recovery system

e.g. what I used in local.conf

KEYMAPS_DEFAULT_DIRECTORY=""
KEYMAPS_DIRECTORIES="/usr/share/kbd/keymaps/legacy"
KEYMAP="de-latin1-nodeadkeys"

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

@gdha @schabrolles
if you do not object against the new KEYMAP* config variables
I would document them tomorrow in default.conf
and then I would like to merge this pull request.

I think with the new KEYMAP* config variables there cannot be
a severe regression because if somehow the default behaviour
does no longer work the user can now manually specify what
is needed to make it work in his particular environment.

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

With
4719c5a
I describe KEYMAPS_DEFAULT_DIRECTORY, KEYMAPS_DIRECTORIES, and KEYMAP
in default.conf so that you can have a look how I meant them to be used.

@jsmeix
Copy link
Member Author

jsmeix commented Apr 25, 2018

@gdha @schabrolles @gozora
could you do me a favour and report here
what the default directory for keymaps is
on whatever non-SUSE systems you have.

On my SUSE systems I have in man loadkeys

FILES
       /usr/share/kbd/keymaps
              default directory for keymaps

which is actually true because I get things like

# rpm -qa | grep -i kbd
kbd-...
kbd-legacy-...

# rpm -ql kbd kbd-legacy | grep de-latin1
/usr/share/kbd/keymaps/legacy/i386/qwertz/de-latin1-nodeadkeys.map.gz
/usr/share/kbd/keymaps/legacy/i386/qwertz/de-latin1.map.gz
/usr/share/kbd/keymaps/legacy/mac/all/mac-de-latin1-nodeadkeys.map.gz
/usr/share/kbd/keymaps/legacy/mac/all/mac-de-latin1.map.gz
/usr/share/kbd/keymaps/legacy/sun/sunt5-de-latin1.map.gz

I would like to know how those things look on non-SUSE systems.

@gozora
Copy link
Member

gozora commented Apr 25, 2018

Hello @jsmeix,

  • Debian 9.2 (stretch)
FILES
       /usr/share/keymaps
              default directory for keymaps

       /usr/src/linux/drivers/char/defkeymap.map
              default kernel keymap
  • Centos 7.3.1611 (Core)
FILES
       /lib/kbd/keymaps
              default directory for keymaps

       /usr/src/linux/drivers/char/defkeymap.map
              default kernel keymap
  • Fedora release 26 (Twenty Six)
FILES
       /lib/kbd/keymaps
              default directory for keymaps

       /usr/src/linux/drivers/char/defkeymap.map
              default kernel keymap
  • Arch Linux
FILES
       /usr/share/kbd/keymaps
              default directory for keymaps

       /usr/src/linux/drivers/char/defkeymap.map
              default kernel keymap
  • Ubuntu 12.04.5 LTS (Precise)
FILES
       /usr/share/keymaps
              default directory for keymaps

       /usr/src/linux/drivers/char/defkeymap.map
              default kernel keymap

Hope it helps.

V.

@schabrolles
Copy link
Member

@gozora ... too quick for me ;-)

@gozora
Copy link
Member

gozora commented Apr 25, 2018

Btw, to check whether defaults in man page are really used by loadkeys binary, strace -e open loadkeys any_non_existing_file can be used ...

V.

@jsmeix
Copy link
Member Author

jsmeix commented Apr 26, 2018

@gozora
many thanks for your #1781 (comment)
it helps a lot!
I will enhance KEYMAPS_DEFAULT_DIRECTORY autodetection accordingly.

@jsmeix
Copy link
Member Author

jsmeix commented Apr 26, 2018

@schabrolles @gdha
perhaps you can provide what the default directory for keymaps is
on whatever RHEL systems you have (ideally also on older ones).

@jsmeix
Copy link
Member Author

jsmeix commented Apr 26, 2018

Regarding
#1781 (comment)

This time @gozora won even with a lot of text!
Cf.
#1775 (comment)
;-)
He is getting better with impressive speed!
I get a bit anxious what may happen next.
Perhaps an elaborated answer before the question?

@schabrolles
Copy link
Member

RHEL 6/7 are like CentOS/Fedora ones ... but I don't have anything into /usr/src/linux/ ...

FILES
       /lib/kbd/keymaps
              default directory for keymaps

@jsmeix
Copy link
Member Author

jsmeix commented Apr 26, 2018

@schabrolles
many thanks for your prompt reply!

@jsmeix
Copy link
Member Author

jsmeix commented Apr 26, 2018

FYI related to #1781 (comment)

I found out how one can determine what keymap files plus include files
one particular keyboad mapping needs so that it can be loaded.

In my case for loadkeys de-latin1-nodeadkeys it is "just as simple as" ;-)

# for f in $( strace -f -e open loadkeys de-latin1-nodeadkeys 2>&1 | grep '/usr/share/kbd/keymaps/legacy/' | grep -v 'O_DIRECTORY' | grep -o 'open.*,' | cut -d '"' -f2 ) ; do readlink -e $f ; done

/usr/share/kbd/keymaps/legacy/i386/qwertz/de-latin1-nodeadkeys.map.gz
/usr/share/kbd/keymaps/legacy/i386/qwertz/de-latin1.map.gz
/usr/share/kbd/keymaps/legacy/i386/include/qwertz-layout.inc
/usr/share/kbd/keymaps/legacy/i386/include/compose.inc
/usr/share/kbd/keymaps/legacy/i386/include/linux-with-alt-and-altgr.inc
/usr/share/kbd/keymaps/legacy/i386/include/linux-keys-bare.inc
/usr/share/kbd/keymaps/legacy/i386/include/euro2.map.gz
/usr/share/kbd/keymaps/legacy/include/compose.latin1

Simplifying that command is left as an exercise to the reader ;-)

Accordingly with

KEYMAPS_DEFAULT_DIRECTORY="/usr/share/kbd/keymaps"
KEYMAPS_DIRECTORIES="/usr/share/kbd/keymaps/legacy/i386/qwertz/de-latin1-nodeadkeys.map.gz /usr/share/kbd/keymaps/legacy/i386/qwertz/de-latin1.map.gz /usr/share/kbd/keymaps/legacy/i386/include/qwertz-layout.inc /usr/share/kbd/keymaps/legacy/i386/include/compose.inc /usr/share/kbd/keymaps/legacy/i386/include/linux-with-alt-and-altgr.inc /usr/share/kbd/keymaps/legacy/i386/include/linux-keys-bare.inc /usr/share/kbd/keymaps/legacy/i386/include/euro2.map.gz /usr/share/kbd/keymaps/legacy/include/compose.latin1"
KEYMAP="de-latin1-nodeadkeys"

(one can as well specify plain files as KEYMAPS_DIRECTORIES values)
I get a minimal recovery system that contains only what is needed

# find /tmp/rear.owdPbH9RbpT2GqN/rootfs/ | grep keymaps
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/include
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/include/compose.latin1
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/include
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/include/qwertz-layout.inc
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/include/linux-keys-bare.inc
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/include/linux-with-alt-and-altgr.inc
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/include/compose.inc
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/include/euro2.map.gz
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/qwertz
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/qwertz/de-latin1-nodeadkeys.map.gz
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/qwertz/de-latin1.map.gz
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/qwerty
/tmp/rear.owdPbH9RbpT2GqN/rootfs/usr/share/kbd/keymaps/legacy/i386/qwerty/defkeymap.map.gz

(defkeymap.map.gz gets added in any case by 500_clone_keyboard_mappings.sh)
to run loadkeys de-latin1-nodeadkeys successfully in the recovery system
by etc/scripts/system-setup.d/10-console-setup.sh

…system (e.g. needed on ppc64 with the yaboot bootloader)
…efault directories for keymaps which also simplified the code that finds the defkeymap keymap file
@jsmeix
Copy link
Member Author

jsmeix commented Apr 26, 2018

My "latest greatest" current code here works so well for me
so that I would like to merge it today soon
unless there are objections.

@jsmeix jsmeix added the cleanup label Apr 26, 2018
@jsmeix jsmeix merged commit e5b7b3e into rear:master Apr 26, 2018
@jsmeix jsmeix deleted the include_also_other_keyboard_mappings branch April 26, 2018 12:18
jsmeix added a commit that referenced this pull request Apr 27, 2018
…scription_follow-up_of_pull_request_1781

Fix KEYMAPS_DEFAULT_DIRECTORY description in default.conf
(follow-up of pull request #1781).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The code does not do what it is meant to do cleanup enhancement Adaptions and new features fixed / solved / done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants