Skip to content

Commit

Permalink
Merge pull request #212 from yast/SLE-15-SP1-bsc-1120957
Browse files Browse the repository at this point in the history
Sle 15 sp1 bsc 1120957
  • Loading branch information
schubi2 committed May 9, 2019
2 parents 64241e9 + a0312aa commit 5fb9eab
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 18 deletions.
31 changes: 21 additions & 10 deletions keyboard/src/modules/Keyboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ def main
#
@ckb_cmd = ""

# The serial console keyboard command
#
@skb_cmd = ""

# The X11 keyboard command
#
@xkb_cmd = ""
Expand Down Expand Up @@ -553,7 +557,10 @@ def SetKeyboard(keyboard)
end

# loadkeys is already escaped and it is multiple params inside, so cannot be escaped here
@ckb_cmd = "/usr/bin/loadkeys #{loadkeys_devices} #{keymap.shellescape}"
devices = loadkeys_devices("tty")
@ckb_cmd = "/usr/bin/loadkeys #{devices} #{keymap.shellescape}"
devices = loadkeys_devices("ttyS")
@skb_cmd = "/usr/bin/loadkeys #{devices} #{keymap.shellescape}"

# X11 command...
# do not try to run this with remote X display
Expand Down Expand Up @@ -980,8 +987,6 @@ def Name
#
# @param Keyboard language e.g. "english-us"
#
# @return The loadkeys command that has been executed to do it.
# (also stored in Keyboard::ckb_cmd)
def SetConsole(keyboard)
if Mode.test
Builtins.y2milestone("Test mode - NOT setting keyboard")
Expand All @@ -992,11 +997,17 @@ def SetConsole(keyboard)

Builtins.y2milestone("Setting console keyboard to: <%1>", @current_kbd)
Builtins.y2milestone("loadkeys command: <%1>", @ckb_cmd)

SCR.Execute(path(".target.bash"), @ckb_cmd)

# It could be that for seriell tty's the keyboard cannot be set. So it will
# be done separately in order to ensure that setting console keyboard
# will be done successfully in the previous call.
Builtins.y2milestone("Setting seriell console keyboard to: <%1>", @current_kbd)
Builtins.y2milestone("loadkeys command: <%1>", @skb_cmd)
SCR.Execute(path(".target.bash"), @skb_cmd)

UI.SetKeyboard
end
@ckb_cmd
end # SetConsole()


Expand Down Expand Up @@ -1332,7 +1343,7 @@ def Summary
publish :function => :Modified, :type => "boolean ()"
publish :function => :Save, :type => "void ()"
publish :function => :Name, :type => "string ()"
publish :function => :SetConsole, :type => "string (string)"
publish :function => :SetConsole, :type => "void (string)"
publish :function => :SetX11, :type => "string (string)"
publish :function => :MakeProposal, :type => "string (boolean, boolean)"
publish :function => :CalledRestore, :type => "boolean ()"
Expand Down Expand Up @@ -1461,12 +1472,12 @@ def keyboard_file

# String to specify all the relevant devices in a loadkeys command
#
# It includes all tty devices (bsc#1010938) except those representing
# AMBA devices (bsc#1080222).
# It includes all tty[0-9]* and ttyS[0-9]* devices (bsc#1010938).
#
# @param [String] kind of tty ("tty", "ttyS")
# @return [String] ready to be passed to the loadkeys command
def loadkeys_devices
tty_dev_names = Dir["/dev/tty*"].grep_v(/ttyAMA/)
def loadkeys_devices (kind)
tty_dev_names = Dir["/dev/#{kind}[0-9]*"]
tty_dev_names.map { |d| "-C #{d.shellescape}" }.join(" ")
end
end
Expand Down
19 changes: 12 additions & 7 deletions keyboard/test/keyboard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ module Yast
let(:stage) { "normal" }
let(:chroot) { "spanish" }

before do
allow(Dir).to receive(:[]).with("/dev/tty[0-9]*").and_return(
["/dev/tty1"]
)
allow(Dir).to receive(:[]).with("/dev/ttyS[0-9]*").and_return(
["/dev/ttyS0"]
)
end

it "correctly sets all layout variables" do
expect(SCR).to execute_bash(/loadkeys -C \/dev\/tty.* ruwin_alt-UTF-8\.map\.gz/)

Expand All @@ -142,7 +151,7 @@ module Yast
stub_presence_of "/usr/sbin/xkbctrl"
allow(XVersion).to receive(:binPath).and_return "/usr/bin"

expect(SCR).to execute_bash(/loadkeys -C \/dev\/tty.* tr\.map\.gz/)
expect(SCR).to execute_bash(/loadkeys -C \/dev\/tty.* tr\.map\.gz/).twice
# Called twice, for SetConsole and SetX11
expect(SCR).to execute_bash(/xkbctrl tr\.map\.gz/).twice do |p, cmd|
dump_xkbctrl(:turkish, cmd.split("> ")[1])
Expand All @@ -161,16 +170,12 @@ module Yast
end

context "if there are AMBA devices in the system" do
before do
allow(Dir).to receive(:[]).and_return(
["/dev/tty1", "/dev/ttyAMA0", "/dev/ttyS0"]
)
end

it "does not try to set the keymap for /dev/ttyAMA devices" do
expect(SCR).to receive(:Execute) do |path, command|
expect(path).to eq path(".target.bash")
expect(command).to include "loadkeys -C /dev/tty1 -C /dev/ttyS0 ruwin_alt-UTF-8"
expect(command).to include "loadkeys -C"
expect(command).to include "ruwin_alt-UTF-8"
expect(command).to_not include "/dev/ttyAMA0"
end

Expand Down
7 changes: 7 additions & 0 deletions package/yast2-country.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu May 9 13:42:57 CEST 2019 - schubi@suse.de

- Fix: Keyboard language cannot be changed in textmode
(bsc#1120957).
- 4.1.12

-------------------------------------------------------------------
Tue Mar 19 07:06:45 UTC 2019 - Dominique Leuenberger <dimstar@opensuse.org>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-country.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-country
Version: 4.1.11
Version: 4.1.12
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down

0 comments on commit 5fb9eab

Please sign in to comment.