Hello community,

here is the log from the commit of package yast2-country for openSUSE:Factory 
checked in at 2020-01-04 19:20:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-country (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-country.new.6675 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-country"

Sat Jan  4 19:20:52 2020 rev:209 rq:760451 version:4.2.14

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-country/yast2-country.changes      
2019-12-14 12:03:23.443403531 +0100
+++ /work/SRC/openSUSE:Factory/.yast2-country.new.6675/yast2-country.changes    
2020-01-04 19:21:02.201129140 +0100
@@ -1,0 +2,25 @@
+Thu Jan  2 15:13:06 UTC 2020 - Josef Reidinger <[email protected]>
+
+- Do not crash when unknown keymap is set on system (bsc#1159286)
+- 4.2.14
+
+-------------------------------------------------------------------
+Mon Dec 30 14:13:44 UTC 2019 - Josef Reidinger <[email protected]>
+
+- fix passing parameters to loadkeys call (bsc#1159185)
+- 4.2.13
+
+-------------------------------------------------------------------
+Thu Dec 19 14:07:30 UTC 2019 - Josef Reidinger <[email protected]>
+
+- Fix incorect dialect offers (bsc#949591)
+- 4.2.12
+
+-------------------------------------------------------------------
+Wed Dec 18 12:03:38 CET 2019 - [email protected]
+
+- Setting keyboard: Ignoring empty keyboard values.
+  (bsc#1158994, bsc#1159210)
+- 4.2.11
+
+-------------------------------------------------------------------

Old:
----
  yast2-country-4.2.10.tar.bz2

New:
----
  yast2-country-4.2.14.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-country.spec ++++++
--- /var/tmp/diff_new_pack.JtET5i/_old  2020-01-04 19:21:02.609129322 +0100
+++ /var/tmp/diff_new_pack.JtET5i/_new  2020-01-04 19:21:02.613129323 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package yast2-country
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-country
-Version:        4.2.10
+Version:        4.2.14
 Release:        0
 Summary:        YaST2 - Country Settings (Language, Keyboard, and Timezone)
 License:        GPL-2.0-only

++++++ yast2-country-4.2.10.tar.bz2 -> yast2-country-4.2.14.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-country-4.2.10/keyboard/src/lib/y2keyboard/strategies/kb_strategy.rb 
new/yast2-country-4.2.14/keyboard/src/lib/y2keyboard/strategies/kb_strategy.rb
--- 
old/yast2-country-4.2.10/keyboard/src/lib/y2keyboard/strategies/kb_strategy.rb  
    2019-12-05 10:52:50.000000000 +0100
+++ 
new/yast2-country-4.2.14/keyboard/src/lib/y2keyboard/strategies/kb_strategy.rb  
    2020-01-02 16:22:14.000000000 +0100
@@ -19,6 +19,7 @@
 
 require "yast"
 require "yast2/execute"
+require "shellwords"
 
 module Y2Keyboard
   module Strategies
@@ -31,7 +32,7 @@
     #
     # Use the systemd strategy for making keyboard changes permanent on
     # the installed system.
-    # 
+    #
     class KbStrategy
       include Yast::Logger
 
@@ -46,13 +47,18 @@
       # @param keyboard_code [String] the keyboard layout (e.g. "us") to set
       # in the running the system (mostly temporary).
       def set_layout(keyboard_code)
+        if keyboard_code.nil? || keyboard_code.empty?
+          log.info "Keyboard has not been defined. Do not set it."
+          return
+        end
+
         if Yast::UI.TextMode
           begin
-            Yast::Execute.on_target!("loadkeys", loadkeys_devices("tty"), 
keyboard_code)
+            Yast::Execute.on_target!("loadkeys", *loadkeys_devices("tty"), 
keyboard_code)
             # 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.
-            Yast::Execute.on_target!("loadkeys", loadkeys_devices("ttyS"), 
keyboard_code)
+            Yast::Execute.on_target!("loadkeys", *loadkeys_devices("ttyS"), 
keyboard_code)
           rescue Cheetah::ExecutionFailed => e
             log.info(e.message)
             log.info("Error output:    #{e.stderr}")
@@ -65,9 +71,9 @@
 
     private
 
-      # set x11 keys on the fly.
-      # @param keyboard_code [String] the keyboard to set.
-      def set_x11_layout(keyboard_code)
+    # set x11 keys on the fly.
+    # @param keyboard_code [String] the keyboard to set.
+    def set_x11_layout(keyboard_code)
         x11data = get_x11_data(keyboard_code)
         return if x11data.empty?
 
@@ -83,10 +89,10 @@
       # 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
+      # @return [Array<String>] array with params for the loadkeys command
       def loadkeys_devices(kind)
         tty_dev_names = Dir["/dev/#{kind}[0-9]*"]
-        tty_dev_names.map { |d| "-C #{d.shellescape}" }.join(" ")
+        tty_dev_names.each_with_object([]) { |d,res| res << "-C" << d }
       end
 
       # GetX11KeyData()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-country-4.2.10/keyboard/src/lib/y2keyboard/strategies/systemd_strategy.rb
 
new/yast2-country-4.2.14/keyboard/src/lib/y2keyboard/strategies/systemd_strategy.rb
--- 
old/yast2-country-4.2.10/keyboard/src/lib/y2keyboard/strategies/systemd_strategy.rb
 2019-12-05 10:52:50.000000000 +0100
+++ 
new/yast2-country-4.2.14/keyboard/src/lib/y2keyboard/strategies/systemd_strategy.rb
 2020-01-02 16:22:14.000000000 +0100
@@ -23,6 +23,8 @@
   module Strategies
     # Class to deal with systemd keyboard configuration management.
     class SystemdStrategy
+      include Yast::Logger
+
       # @return [Array<String>] an array with all available systemd keyboard 
layouts codes.
       def codes
         raw_layouts = Yast::Execute.on_target!("localectl", "list-keymaps", 
stdout: :capture)
@@ -32,6 +34,11 @@
       # Use systemd to apply a new keyboard layout in the system.
       # @param keyboard_code [String] the keyboard layout to apply in the 
system.
       def apply_layout(keyboard_code)
+        if keyboard_code.nil? || keyboard_code.empty?
+          log.info "Keyboard has not been defined. Do not set it."
+          return
+        end
+
         if Yast::Stage.initial
           # systemd is not available here (inst-sys).
           # do use --root option, running in chroot does not work (bsc#1074481)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-country-4.2.10/keyboard/src/modules/Keyboard.rb 
new/yast2-country-4.2.14/keyboard/src/modules/Keyboard.rb
--- old/yast2-country-4.2.10/keyboard/src/modules/Keyboard.rb   2019-12-05 
10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/keyboard/src/modules/Keyboard.rb   2020-01-02 
16:22:14.000000000 +0100
@@ -97,6 +97,10 @@
       # If not in initial mode
       if !Stage.initial || Mode.live_installation
         @curr_kbd = Keyboards.alias(@systemd_strategy.current_layout())
+        if @curr_kbd.nil?
+          log.warn "Unsupported keymap #{@systemd_strategy.current_layout()}."
+          @curr_kbd = ""
+        end
         @keyboard_on_entry = @curr_kbd
       end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-country-4.2.10/keyboard/test/kb_strategy_spec.rb 
new/yast2-country-4.2.14/keyboard/test/kb_strategy_spec.rb
--- old/yast2-country-4.2.10/keyboard/test/kb_strategy_spec.rb  2019-12-05 
10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/keyboard/test/kb_strategy_spec.rb  2020-01-02 
16:22:14.000000000 +0100
@@ -7,17 +7,20 @@
 describe Y2Keyboard::Strategies::KbStrategy do
   subject(:kb_strategy) { Y2Keyboard::Strategies::KbStrategy.new }
   let(:arguments_to_apply) {"-layout es -model microsoftpro -option 
terminate:ctrl_alt_bksp"}
-  
 
   describe "#set_layout" do
     context "in text mode" do
       before do
         allow(Yast::UI).to receive(:TextMode).and_return(true)
+        allow(Dir).to 
receive(:[]).with("/dev/tty[0-9]*").and_return(["/dev/tty1", "/dev/tty2"])
+        allow(Dir).to 
receive(:[]).with("/dev/ttyS[0-9]*").and_return(["/dev/ttyS1"])
       end
 
       it "calls -loadkeys- on the target" do
-        expect(Yast::Execute).to receive(:on_target!).twice.with(
-          "loadkeys", anything, "es")
+        expect(Yast::Execute).to receive(:on_target!).with(
+          "loadkeys", "-C" ,"/dev/tty1", "-C", "/dev/tty2", "es")
+        expect(Yast::Execute).to receive(:on_target!).with(
+          "loadkeys", "-C" ,"/dev/ttyS1", "es")
 
         kb_strategy.set_layout("es")
       end
@@ -37,7 +40,7 @@
       it "does not call -loadkeys- on the target" do
         expect(Yast::Execute).not_to receive(:on_target!).with(
           "loadkeys", anything, "es")
-        expect(kb_strategy).to receive(:set_x11_layout)        
+        expect(kb_strategy).to receive(:set_x11_layout)
 
         kb_strategy.set_layout("es")
       end
@@ -54,8 +57,16 @@
         expect(kb_strategy).to receive(:write_udev_rule)
 
         kb_strategy.set_layout("es")
-      end      
+      end
+    end
 
-    end    
+    context "empty keyboard_code parameter" do
+      it "does not try to set the keyboard layout" do
+        expect(kb_strategy).not_to receive(:set_x11_layout)
+        expect(Yast::Execute).not_to receive(:on_target!).with(
+          "loadkeys", anything, anything)
+        kb_strategy.set_layout("")
+      end
+    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-country-4.2.10/keyboard/test/keyboard_spec.rb 
new/yast2-country-4.2.14/keyboard/test/keyboard_spec.rb
--- old/yast2-country-4.2.10/keyboard/test/keyboard_spec.rb     2019-12-05 
10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/keyboard/test/keyboard_spec.rb     2020-01-02 
16:22:14.000000000 +0100
@@ -32,18 +32,26 @@
           and_return({})
         expect(subject.GetKeyboardForLanguage(search_language,
           "default_language")).to eq("default_language")
-      end      
+      end
     end
   end
 
   describe "#Read" do
-    it "returns the current keyboard" do
+    it "sets the current keyboard" do
       allow(Yast::Stage).to receive(:initial).and_return false
-      expect_any_instance_of(Y2Keyboard::Strategies::SystemdStrategy).
+      allow_any_instance_of(Y2Keyboard::Strategies::SystemdStrategy).
         to receive(:current_layout).and_return("uk")
       subject.Read
       expect(subject.current_kbd).to eq("english-uk")
     end
+
+    it "sets empty current keyboard for unsupported keyboard (bsc#1159286)" do
+      allow(Yast::Stage).to receive(:initial).and_return false
+      allow_any_instance_of(Y2Keyboard::Strategies::SystemdStrategy).
+        to receive(:current_layout).and_return("lt")
+      subject.Read
+      expect(subject.current_kbd).to eq("")
+    end
   end
 
   describe "#Save" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-country-4.2.10/keyboard/test/systemd_strategy_spec.rb 
new/yast2-country-4.2.14/keyboard/test/systemd_strategy_spec.rb
--- old/yast2-country-4.2.10/keyboard/test/systemd_strategy_spec.rb     
2019-12-05 10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/keyboard/test/systemd_strategy_spec.rb     
2020-01-02 16:22:14.000000000 +0100
@@ -41,13 +41,23 @@
   end
 
   describe "#apply_layout" do
-    it "changes the keyboard layout" do
-      new_layout = Y2Keyboard::KeyboardLayout.new("es", "Spanish")
-      expect(Yast::Execute).to receive(:on_target!).with(
-        "localectl", "set-keymap", new_layout.code
-      )
+    context "valid keyboard code" do
+      it "changes the keyboard layout" do
+        new_layout = Y2Keyboard::KeyboardLayout.new("es", "Spanish")
+        expect(Yast::Execute).to receive(:on_target!).with(
+          "localectl", "set-keymap", new_layout.code
+        )
 
-      systemd_strategy.apply_layout(new_layout.code)
+        systemd_strategy.apply_layout(new_layout.code)
+      end
+    end
+
+    context "empty keyboard code" do
+      it "does not try to set the keyboard layout" do
+        expect(Yast::Execute).not_to receive(:on_target!).with(
+          "localectl", "set-keymap", anything)
+        systemd_strategy.apply_layout("")
+      end
     end
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-country-4.2.10/language/src/clients/select_language.rb 
new/yast2-country-4.2.14/language/src/clients/select_language.rb
--- old/yast2-country-4.2.10/language/src/clients/select_language.rb    
2019-12-05 10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/language/src/clients/select_language.rb    
2020-01-02 16:22:14.000000000 +0100
@@ -591,11 +591,11 @@
       Builtins.y2debug("expert values %1", val)
 
       # get the list of locales for our language
-      lang = Builtins.substring(@language, 0, 2)
+      lang = Language.main_language(@language)
       locales_list = []
 
       Builtins.foreach(Language.GetLocales) do |code, i|
-        if Builtins.substring(code, 0, 2) == lang
+        if Language.main_language(code) == lang
           locales_list = Builtins.add(locales_list, code)
         end
       end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-country-4.2.10/language/src/modules/Language.rb 
new/yast2-country-4.2.14/language/src/modules/Language.rb
--- old/yast2-country-4.2.10/language/src/modules/Language.rb   2019-12-05 
10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/language/src/modules/Language.rb   2020-01-02 
16:22:14.000000000 +0100
@@ -321,7 +321,7 @@
       if @available_lang_filenames == nil
         lang_numbers = {}
         Builtins.foreach(GetLanguagesMap(false)) do |code, data|
-          short = Ops.get(Builtins.splitstring(code, "_"), 0, "")
+          short = main_language(code)
           if Ops.get(lang_numbers, short, 0) == 0
             Ops.set(lang_numbers, short, 1)
           else
@@ -333,7 +333,7 @@
           end
         end
         @available_lang_filenames = Builtins.maplist(GetLanguagesMap(false)) 
do |code, data|
-          short = Ops.get(Builtins.splitstring(code, "_"), 0, "")
+          short = main_language(code)
           if Ops.greater_than(Ops.get(lang_numbers, short, 0), 1)
             next code
           else
@@ -345,12 +345,7 @@
       check_for_languages = [language]
 
       # 'en_US' ? add also 'en'
-      if Ops.greater_than(Builtins.size(language), 2)
-        check_for_languages = Builtins.add(
-          check_for_languages,
-          Ops.get(Builtins.splitstring(language, "_"), 0, "")
-        )
-      end
+      check_for_languages << main_language(language) if language.include?("_")
 
       # Default fallback
       filename = "yast2-trans-en_US.rpm"
@@ -361,8 +356,6 @@
           raise Break
         end
       end
-      # yast2-trans-pt.rpm doesn't fit into the algorithm above, see bnc#386298
-      return "yast2-trans-pt.rpm" if language == "pt_PT"
 
       Builtins.y2milestone("Using %1 for %2", filename, language)
       filename
@@ -1074,15 +1067,13 @@
     # Returns true if translation for given language is not complete
     def IncompleteTranslation(lang)
       if !Builtins.haskey(@translation_status, lang)
-        file = Ops.add(Ops.add("/usr/lib/YaST2/trans/", lang), ".status")
+        file = "/usr/lib/YaST2/trans/#{lang}.status"
         if !FileUtils.Exists(file)
-          ll = Ops.get(Builtins.splitstring(lang, "_"), 0, "")
-          if ll != ""
-            file = Ops.add(Ops.add("/usr/lib/YaST2/trans/", ll), ".status")
-          end
+          ll = main_language(lang)
+          file = "/usr/lib/YaST2/trans/#{ll}.status" unless ll.empty?
         end
 
-        status = Convert.to_string(SCR.Read(path(".target.string"), file))
+        status = SCR.Read(path(".target.string"), file)
 
         if status != nil && status != ""
           to_i = Builtins.tointeger(status)
@@ -1335,6 +1326,12 @@
       GetLocaleString @language
     end
 
+    # Returns main language from full locale. E.g. en_US.UTF-8 -> en or agr_PE 
-> agr
+    def main_language(lang)
+      return "" unless lang
+      lang[/^[a-z]+/]
+    end
+
     publish :variable => :language, :type => "string"
     publish :variable => :language_on_entry, :type => "string"
     publish :variable => :preselected, :type => "string"
@@ -1402,7 +1399,7 @@
     # @param lang [String] Language code
     # @return [Boolean]
     def supported_by_fbiterm?(lang)
-      code, _ = lang.split("_")
+      code = main_language(lang)
       UNSUPPORTED_FBITERM_LANGS.none?(code)
     end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-country-4.2.10/language/test/Language_test.rb 
new/yast2-country-4.2.14/language/test/Language_test.rb
--- old/yast2-country-4.2.10/language/test/Language_test.rb     2019-12-05 
10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/language/test/Language_test.rb     2020-01-02 
16:22:14.000000000 +0100
@@ -440,4 +440,23 @@
       expect(subject.EnglishName("de_DE", "missing")).to eq("German")
     end
   end
+
+  describe "#main_language" do
+    it "returns empty string for nil" do
+      expect(subject.main_language(nil)).to eq ""
+    end
+
+    it "returns main language for variant with dialect" do
+      expect(subject.main_language("en_GB")).to eq "en"
+    end
+
+    it "returns main language for variant with dialect and encoding" do
+      expect(subject.main_language("en_GB.utf-8")).to eq "en"
+    end
+
+    # test for bsc#949591
+    it "returns main language even when it has more then two chars" do
+      expect(subject.main_language("csb_PL")).to eq "csb"
+    end
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-country-4.2.10/package/yast2-country.changes 
new/yast2-country-4.2.14/package/yast2-country.changes
--- old/yast2-country-4.2.10/package/yast2-country.changes      2019-12-05 
10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/package/yast2-country.changes      2020-01-02 
16:22:14.000000000 +0100
@@ -1,4 +1,29 @@
 -------------------------------------------------------------------
+Thu Jan  2 15:13:06 UTC 2020 - Josef Reidinger <[email protected]>
+
+- Do not crash when unknown keymap is set on system (bsc#1159286)
+- 4.2.14
+
+-------------------------------------------------------------------
+Mon Dec 30 14:13:44 UTC 2019 - Josef Reidinger <[email protected]>
+
+- fix passing parameters to loadkeys call (bsc#1159185)
+- 4.2.13
+
+-------------------------------------------------------------------
+Thu Dec 19 14:07:30 UTC 2019 - Josef Reidinger <[email protected]>
+
+- Fix incorect dialect offers (bsc#949591)
+- 4.2.12
+
+-------------------------------------------------------------------
+Wed Dec 18 12:03:38 CET 2019 - [email protected]
+
+- Setting keyboard: Ignoring empty keyboard values.
+  (bsc#1158994, bsc#1159210)
+- 4.2.11
+
+-------------------------------------------------------------------
 Wed Dec  4 13:26:52 UTC 2019 - José Iván López González <[email protected]>
 
 - Improve detection of Windows system (related to bsc#1135341).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-country-4.2.10/package/yast2-country.spec 
new/yast2-country-4.2.14/package/yast2-country.spec
--- old/yast2-country-4.2.10/package/yast2-country.spec 2019-12-05 
10:52:50.000000000 +0100
+++ new/yast2-country-4.2.14/package/yast2-country.spec 2020-01-02 
16:22:14.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-country
-Version:        4.2.10
+Version:        4.2.14
 Release:        0
 Summary:        YaST2 - Country Settings (Language, Keyboard, and Timezone)
 License:        GPL-2.0-only


Reply via email to