Hello community, here is the log from the commit of package yast2-country for openSUSE:Factory checked in at 2015-02-22 17:21:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-country (Old) and /work/SRC/openSUSE:Factory/.yast2-country.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-country" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-country/yast2-country.changes 2015-02-20 13:50:41.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-country.new/yast2-country.changes 2015-02-22 17:21:10.000000000 +0100 @@ -1,0 +2,6 @@ +Fri Feb 20 15:43:03 UTC 2015 - ancor@suse.com + +- Display an error if the keyboard was not changed (bnc#918093) +- 3.1.20 + +------------------------------------------------------------------- Old: ---- yast2-country-3.1.19.tar.bz2 New: ---- yast2-country-3.1.20.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-country.spec ++++++ --- /var/tmp/diff_new_pack.kIx4aM/_old 2015-02-22 17:21:11.000000000 +0100 +++ /var/tmp/diff_new_pack.kIx4aM/_new 2015-02-22 17:21:11.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-country -Version: 3.1.19 +Version: 3.1.20 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-country-3.1.19.tar.bz2 -> yast2-country-3.1.20.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-3.1.19/keyboard/src/modules/Keyboard.rb new/yast2-country-3.1.20/keyboard/src/modules/Keyboard.rb --- old/yast2-country-3.1.19/keyboard/src/modules/Keyboard.rb 2015-02-16 13:59:13.000000000 +0100 +++ new/yast2-country-3.1.20/keyboard/src/modules/Keyboard.rb 2015-02-20 18:29:11.000000000 +0100 @@ -120,6 +120,7 @@ Yast.import "ProductFeatures" Yast.import "Stage" Yast.import "XVersion" + Yast.import "Report" # ------------------------------------------------------------------------ # START: Globally defined data to be accessed via Keyboard::<variable> @@ -1021,7 +1022,6 @@ end # SetConsole() - # Set the X11 keyboard to the given keyboard language. # # @param Keyboard language e.g. "english-us" @@ -1030,40 +1030,24 @@ # (also stored in Keyboard::xkb_cmd) def SetX11(keyboard) if Mode.test - Builtins.y2milestone("Test mode - would have called:\n %1", @xkb_cmd) + log.info "Test mode - would have called:\n #{@xkb_cmd}" else # Actually do it only if we are in graphical mode. # - textmode = Linuxrc.text - if !Stage.initial || Mode.live_installation - display_info = UI.GetDisplayInfo - textmode = Ops.get_boolean(display_info, "TextMode", false) - end - display = Builtins.getenv("DISPLAY") - if textmode - Builtins.y2milestone("Not setting X keyboard due to text mode") + if textmode? + log.info "Not setting X keyboard due to text mode" # check if we are running over ssh: bnc#539218,c4 - elsif Ops.greater_or_equal( - Builtins.tointeger( - Ops.get(Builtins.splitstring(display, ":"), 1, "0") - ), - 10 - ) - Builtins.y2milestone("Not setting X keyboard: running over ssh") - elsif Ops.greater_than(Builtins.size(@xkb_cmd), 0) + elsif x11_over_ssh? + # TODO: the check above could not be enough in some cases + # An external X server can be specified via display_ip boot parameter + # (see https://en.opensuse.org/SDB:Linuxrc#p_displayip). + # I that case, the configuration should probably also be skipped + log.info "Not setting X keyboard: running over ssh" + elsif !@xkb_cmd.empty? SetKeyboard(keyboard) - Builtins.y2milestone("Setting X11 keyboard to: <%1>", @current_kbd) - Builtins.y2milestone("Setting X11 keyboard:\n %1", @xkb_cmd) - SCR.Execute(path(".target.bash"), @xkb_cmd) - # bnc#371756: enable autorepeat - if Stage.initial && !Mode.live_installation && !xen_running - cmd = "xset r on" - Builtins.y2milestone( - "calling xset to fix autorepeat problem: %1", - cmd - ) - SCR.Execute(path(".target.bash"), cmd) - end + execute_xkb_cmd + # bnc#371756: enable autorepeat if needed + enable_autorepeat # bnc#885271: set udev rule to handle incoming attached keyboards write_udev_rule if Stage.initial end @@ -1072,7 +1056,6 @@ end # SetX11() - # Set() # # Set the keyboard to the given keyboard language. @@ -1504,6 +1487,41 @@ end end + # Checks if the graphical environment is being executed remotely using + # "ssh -X" + def x11_over_ssh? + display = ENV["DISPLAY"] || "" + display.split(":")[1].to_i >= 10 + end + + # Checks if it's running in text mode (no X11) + def textmode? + if !Stage.initial || Mode.live_installation + UI.TextMode + else + Linuxrc.text + end + end + + # Executes the command to set the keyboard in X11, reporting + # any error to the user + def execute_xkb_cmd + log.info "Setting X11 keyboard to: <#{@current_kbd}>" + log.info "Setting X11 keyboard: #{@xkb_cmd}" + if SCR.Execute(path(".target.bash"), @xkb_cmd) != 0 + log.error "Failed to execute the command" + Report::Error(_("Failed to set X11 keyboard to '%s'") % @current_kbd) + end + end + + # Enables autorepeat if needed + def enable_autorepeat + return nil unless Stage.initial && !Mode.live_installation && !xen_running + cmd = "xset r on" + log.info "calling xset to fix autorepeat problem: #{cmd}" + SCR.Execute(path(".target.bash"), cmd) + end + Keyboard = KeyboardClass.new Keyboard.main end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-3.1.19/keyboard/test/SCRStub.rb new/yast2-country-3.1.20/keyboard/test/SCRStub.rb --- old/yast2-country-3.1.19/keyboard/test/SCRStub.rb 2015-02-16 13:59:13.000000000 +0100 +++ new/yast2-country-3.1.20/keyboard/test/SCRStub.rb 2015-02-20 18:29:11.000000000 +0100 @@ -35,13 +35,11 @@ .and_return(256) end - # Defines an expectation about executing commands using SCR.Execute and - # .target.bash + # Matcher for executing commands using SCR.Execute and .target.bash # - # @return [MessageExpectation] an expectation (that can be further customized - # with usual RSpec methods) - def expect_to_execute(command) - expect(Yast::SCR).to(receive(:Execute).with(path(".target.bash"), command)) + # @return [RSpec::Mocks::Matchers::Receive] + def execute_bash(command) + receive(:Execute).with(path(".target.bash"), command) end # Stub all calls to SCR.Write storing the value for future comparison diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-3.1.19/keyboard/test/keyboard_test.rb new/yast2-country-3.1.20/keyboard/test/keyboard_test.rb --- old/yast2-country-3.1.19/keyboard/test/keyboard_test.rb 2015-02-16 13:59:13.000000000 +0100 +++ new/yast2-country-3.1.20/keyboard/test/keyboard_test.rb 2015-02-20 18:29:11.000000000 +0100 @@ -11,16 +11,21 @@ import "Encoding" import "AsciiFile" import "XVersion" + import "Report" ::RSpec.configure do |c| c.include SCRStub end describe "Keyboard" do + let(:udev_file) { "/usr/lib/udev/rules.d/70-installation-keyboard.rules" } + before(:each) do allow(Stage).to receive(:stage).and_return stage allow(Mode).to receive(:mode).and_return mode allow(Linuxrc).to receive(:text).and_return false + allow(SCR).to receive(:Execute).with(path(".target.remove"), udev_file) + allow(SCR).to receive(:Write).with(anything, udev_file, anything) init_root_path(chroot) end @@ -39,23 +44,26 @@ allow(SCR).to receive(:Write) .with(path(".target.string"), anything, anything).and_call_original allow(SCR).to receive(:Read).with(path(".probe.keyboard.manual")).and_return([]) + + allow(SCR).to execute_bash(/loadkeys/) + allow(SCR).to execute_bash(/xkbctrl/) do |p, cmd| + dump_xkbctrl(new_lang, cmd.split("> ")[1]) + end + allow(SCR).to execute_bash(/setxkbmap/) + # SetX11 sets autorepeat during installation + allow(SCR).to execute_bash(/xset r on$/) end context "during installation" do let(:mode) { "installation" } let(:stage) { "initial" } let(:chroot) { "installing" } + let(:new_lang) { "spanish" } it "writes the configuration" do - expect_to_execute(/loadkeys es\.map\.gz/) - # Called twice, for SetConsole and SetX11 - expect_to_execute(/xkbctrl es/).twice do |p, cmd| - dump_xkbctrl(:spanish, cmd.split("> ")[1]) - end - expect_to_execute(/setxkbmap .*layout es/) - expect_to_execute(/localectl --no-convert set-x11-keymap es microsoftpro basic$/) - # SetX11 sets autorepeat during installation - expect_to_execute(/xset r on$/) + expect(SCR).to execute_bash( + /localectl --no-convert set-x11-keymap es microsoftpro basic$/ + ) expect(AsciiFile).to receive(:AppendLine).with(anything, ["Keytable:", "es.map.gz"]) Keyboard.Set("spanish") @@ -80,15 +88,12 @@ let(:mode) { "normal" } let(:stage) { "normal" } let(:chroot) { "spanish" } + let(:new_lang) { "russian" } it "writes the configuration" do - expect_to_execute(/loadkeys ruwin_alt-UTF-8\.map\.gz/) - # Called twice, for SetConsole and SetX11 - expect_to_execute(/xkbctrl ruwin_alt-UTF-8/).twice do |p, cmd| - dump_xkbctrl(:russian, cmd.split("> ")[1]) - end - expect_to_execute(/setxkbmap .*layout us,ru/) - expect_to_execute(/localectl --no-convert set-x11-keymap us,ru microsoftpro ,winkeys grp:ctrl_shift_toggle,grp_led:scroll$/) + expect(SCR).to execute_bash( + /localectl --no-convert set-x11-keymap us,ru microsoftpro ,winkeys grp:ctrl_shift_toggle,grp_led:scroll$/ + ) Keyboard.Set("russian") Keyboard.Save @@ -115,7 +120,7 @@ let(:chroot) { "spanish" } it "correctly sets all layout variables" do - expect_to_execute(/loadkeys ruwin_alt-UTF-8\.map\.gz/) + expect(SCR).to execute_bash(/loadkeys ruwin_alt-UTF-8\.map\.gz/) Keyboard.Set("russian") expect(Keyboard.current_kbd).to eq("russian") @@ -127,74 +132,167 @@ stub_presence_of "/usr/sbin/xkbctrl" allow(XVersion).to receive(:binPath).and_return "/usr/bin" - expect_to_execute(/loadkeys trq\.map\.gz/) + expect(SCR).to execute_bash(/loadkeys trq\.map\.gz/) # Called twice, for SetConsole and SetX11 - expect_to_execute(/xkbctrl trq\.map\.gz/).twice do |p, cmd| + expect(SCR).to execute_bash(/xkbctrl trq\.map\.gz/).twice do |p, cmd| dump_xkbctrl(:turkish, cmd.split("> ")[1]) end - expect_to_execute(/setxkbmap .*layout tr/) + expect(SCR).to execute_bash(/setxkbmap .*layout tr/) Keyboard.Set("turkish") end it "does not call setxkbmap if graphical system is not installed" do - expect_to_execute(/loadkeys ruwin_alt-UTF-8\.map\.gz/) - expect_to_execute(/xkbctrl ruwin_alt-UTF-8.map.gz/).never - expect_to_execute(/setxkbmap/).never + expect(SCR).to execute_bash(/loadkeys ruwin_alt-UTF-8\.map\.gz/) + expect(SCR).to execute_bash(/xkbctrl ruwin_alt-UTF-8.map.gz/).never + expect(SCR).to execute_bash(/setxkbmap/).never Keyboard.Set("russian") end end describe "#SetX11" do + subject { Keyboard.SetX11(new_lang) } + before(:each) do stub_presence_of "/usr/sbin/xkbctrl" allow(XVersion).to receive(:binPath).and_return "/usr/bin" + + allow(SCR).to execute_bash(/xkbctrl/) do |p, cmd| + dump_xkbctrl(new_lang, cmd.split("> ")[1]) + end + + # This needs to be called in advance + Keyboard.SetKeyboard(new_lang) end context "during installation" do let(:mode) { "installation" } let(:stage) { "initial" } let(:chroot) { "installing" } + let(:new_lang) { "spanish" } it "creates temporary udev rule" do - # Twice, one for SetKeyboard and again for SetX11 - expect_to_execute(/xkbctrl es/).twice do |p, cmd| - dump_xkbctrl(:spanish, cmd.split("> ")[1]) - end - expect_to_execute(/setxkbmap .*layout es/) + allow(SCR).to execute_bash(/setxkbmap .*layout es/) + allow(SCR).to execute_bash(/xset r on$/) rule = "# Generated by Yast to handle the layout of keyboards connected during installation\n" rule += 'ENV{ID_INPUT_KEYBOARD}=="1", ENV{XKBLAYOUT}="es", ENV{XKBMODEL}="microsoftpro", ENV{XKBVARIANT}="basic"' - file = "/usr/lib/udev/rules.d/70-installation-keyboard.rules" - expect(SCR).to receive(:Execute).with(path(".target.remove"), file) - expect(SCR).to receive(:Write).with(path(".target.string"), file, "#{rule}\n") - expect(SCR).to receive(:Write).with(path(".target.string"), file, nil) + expect(SCR).to receive(:Execute).with(path(".target.remove"), udev_file) + expect(SCR).to receive(:Write).with(path(".target.string"), udev_file, "#{rule}\n") + expect(SCR).to receive(:Write).with(path(".target.string"), udev_file, nil) - Keyboard.SetKeyboard("spanish") - Keyboard.SetX11("spanish") + subject end + + it "executes setxkbmap properly" do + allow(SCR).to execute_bash(/xset r on$/) + expect(SCR).to execute_bash(/setxkbmap .*layout es/).and_return(0) + expect(Report).not_to receive(:Error) + + subject + end + + it "alerts user if setxkbmap failed" do + allow(SCR).to execute_bash(/xset r on$/) + allow(SCR).to execute_bash(/setxkbmap/).and_return(253) + expect(Report).to receive(:Error) + + subject + end + + it "sets autorepeat" do + allow(SCR).to execute_bash(/setxkbmap .*layout es/) + expect(SCR).to execute_bash(/xset r on$/) + + subject + end + end context "in an installed system" do let(:mode) { "normal" } let(:stage) { "normal" } let(:chroot) { "spanish" } + let(:new_lang) { "turkish" } it "does not create udev rules" do - # Twice, one for SetKeyboard and again for SetX11 - expect_to_execute(/xkbctrl trq/).twice do |p, cmd| - dump_xkbctrl(:turkish, cmd.split("> ")[1]) - end - expect_to_execute(/setxkbmap .*layout tr/) + allow(SCR).to execute_bash(/setxkbmap .*layout es/) expect(SCR).to_not receive(:Execute) .with(path(".target.remove"), anything) expect(SCR).to_not receive(:Write).with(path(".target.string"), - "/etc/udev/rules.d/70-keyboard.rules", + /udev\/rules\.d/, anything) - Keyboard.SetKeyboard("turkish") - Keyboard.SetX11("turkish") + subject + end + + it "executes setxkbmap properly" do + expect(SCR).to execute_bash(/setxkbmap .*layout tr/).and_return(0) + expect(Report).not_to receive(:Error) + + subject + end + + it "alerts user if setxkbmap failed" do + allow(SCR).to execute_bash(/setxkbmap/).and_return(253) + expect(Report).to receive(:Error) + + subject + end + + it "does not set autorepeat" do + allow(SCR).to execute_bash(/setxkbmap .*layout es/) + expect(SCR).not_to execute_bash(/xset r on$/) + + subject + end + end + + describe "skipping of configuration" do + let(:mode) { "normal" } + let(:stage) { "normal" } + let(:chroot) { "spanish" } + let(:new_lang) { "turkish" } + + before do + ENV["DISPLAY"] = display + end + + context "when DISPLAY is empty" do + let(:display) { "" } + + it "runs X11 configuration" do + expect(SCR).to execute_bash(/setxkbmap/) + subject + end + end + + context "when DISPLAY is nil" do + let(:display) { nil } + + it "runs X11 configuration" do + expect(SCR).to execute_bash(/setxkbmap/) + subject + end + end + + context "when DISPLAY is < 10" do + let(:display) { ":0" } + + it "runs X11 configuration" do + expect(SCR).to execute_bash(/setxkbmap/) + subject + end + end + + context "when DISPLAY is >= 10" do + let(:display) { ":10" } + + it "skips X11 configuration" do + expect(SCR).not_to execute_bash(/setxkbmap/) + subject + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-3.1.19/package/yast2-country.changes new/yast2-country-3.1.20/package/yast2-country.changes --- old/yast2-country-3.1.19/package/yast2-country.changes 2015-02-16 13:59:13.000000000 +0100 +++ new/yast2-country-3.1.20/package/yast2-country.changes 2015-02-20 18:29:11.000000000 +0100 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Feb 20 15:43:03 UTC 2015 - ancor@suse.com + +- Display an error if the keyboard was not changed (bnc#918093) +- 3.1.20 + +------------------------------------------------------------------- Fri Feb 13 14:40:53 UTC 2015 - lslezak@suse.cz - Propose local time when running in a VMware VM, do not display diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-3.1.19/package/yast2-country.spec new/yast2-country-3.1.20/package/yast2-country.spec --- old/yast2-country-3.1.19/package/yast2-country.spec 2015-02-16 13:59:13.000000000 +0100 +++ new/yast2-country-3.1.20/package/yast2-country.spec 2015-02-20 18:29:11.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-country -Version: 3.1.19 +Version: 3.1.20 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org