From 8c62a6ed343b8f898ab3fa77c4460edb89731d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 21 Aug 2015 08:55:05 +0200 Subject: [PATCH 1/3] fixed registering a product with POOL flavor (bsc#941402) --- package/yast2-registration.changes | 5 +++++ src/lib/registration/sw_mgmt.rb | 33 ++++++++++++++++++++++-------- test/registration_ui_test.rb | 10 ++++++--- test/sw_mgmt_spec.rb | 4 ++-- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index 6f4afc1b8..96d0c3295 100644 --- a/package/yast2-registration.changes +++ b/package/yast2-registration.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Aug 21 11:38:22 UTC 2015 - lslezak@suse.cz + +- Fixed registering a product with POOL flavor (bsc#941402) + ------------------------------------------------------------------- Mon Aug 17 14:40:05 UTC 2015 - igonzalezsosa@suse.com diff --git a/src/lib/registration/sw_mgmt.rb b/src/lib/registration/sw_mgmt.rb index 3a76b9627..774df67d1 100644 --- a/src/lib/registration/sw_mgmt.rb +++ b/src/lib/registration/sw_mgmt.rb @@ -50,8 +50,11 @@ class SwMgmt ZYPP_DIR = "/etc/zypp" - FAKE_BASE_PRODUCT = { "name" => "SLES", "arch" => "x86_64", "version" => "12", - "release_type" => "DVD", "version_version" => "12" } + FAKE_BASE_PRODUCT = { "name" => "SLES", "arch" => "x86_64", "version" => "12-0", + "flavor" => "DVD", "version_version" => "12", "register_release" => "", + "register_target" => "sle-12-x86_64" } + + OEM_DIR = "/var/lib/suseRegister/OEM" def self.init # false = do not allow continuing without the libzypp lock @@ -145,17 +148,15 @@ def self.product_label(base_product) end def self.base_product_to_register - # just for debugging: - return FAKE_BASE_PRODUCT if ENV["FAKE_BASE_PRODUCT"] - - base_product = find_base_product + # use FAKE_BASE_PRODUCT just for debugging + base_product = ENV["FAKE_BASE_PRODUCT"] ? FAKE_BASE_PRODUCT : find_base_product # filter out not needed data product_info = { "name" => base_product["name"], "arch" => base_product["arch"], - "version" => ::Registration::Helpers.base_version(base_product["version"]), - "release_type" => base_product["flavor"] + "version" => base_product["version_version"], + "release_type" => get_release_type(base_product) } log.info("Base product to register: #{product_info}") @@ -449,6 +450,20 @@ def self.products_from_repo(repo_id) end end - private_class_method :each_repo + def self.get_release_type(product) + if product["product_line"] + oem_file = File.join(OEM_DIR, product["product_line"]) + + if File.exist?(oem_file) + # read only the first line + line = File.open(oem_file, &:readline) + return line.chomp if line + end + end + + product["register_release"] + end + + private_class_method :each_repo, :get_release_type end end diff --git a/test/registration_ui_test.rb b/test/registration_ui_test.rb index b3c492a3a..6a080efcb 100644 --- a/test/registration_ui_test.rb +++ b/test/registration_ui_test.rb @@ -9,8 +9,12 @@ let(:target_distro) { "sles-12-x86_64" } let(:base_product) do { - "arch" => "x86_64", "name" => "SLES", "version" => "12", - "flavor" => "DVD", "register_target" => target_distro + "arch" => "x86_64", + "flavor" => "DVD", + "name" => "SLES", + "version" => "12-0", + "version_version" => "12", + "register_target" => target_distro } end let(:base_product_to_register) do @@ -18,7 +22,7 @@ "arch" => "x86_64", "name" => "SLES", "reg_code" => "reg_code", - "release_type" => "DVD", + "release_type" => nil, "version" => "12" } end diff --git a/test/sw_mgmt_spec.rb b/test/sw_mgmt_spec.rb index f15eb8dff..cdc7881dc 100755 --- a/test/sw_mgmt_spec.rb +++ b/test/sw_mgmt_spec.rb @@ -101,10 +101,10 @@ it "returns base product base version and release_type" do expect(subject).to(receive(:find_base_product) .and_return("name" => "SLES", "arch" => "x86_64", - "version" => "12.1-1.47", "flavor" => "DVD")) + "version" => "12.1-1.47", "version_version" => "12.1", "flavor" => "DVD")) expect(subject.base_product_to_register).to eq("name" => "SLES", - "arch" => "x86_64", "version" => "12.1", "release_type" => "DVD") + "arch" => "x86_64", "version" => "12.1", "release_type" => nil) end end From 8628c5f0ac0ed4f556a89abdad5f7250f38b61c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 21 Aug 2015 15:11:45 +0200 Subject: [PATCH 2/3] addon selection dialog - use a better widget ID to avoid possible ID duplicates when an addon with multiple versions is displayed --- package/yast2-registration.changes | 2 ++ .../ui/addon_selection_base_dialog.rb | 19 ++++++++++++++----- .../ui/addon_selection_registration_dialog.rb | 2 +- test/addon_selection_dialog_test.rb | 9 +++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index 96d0c3295..4bac87781 100644 --- a/package/yast2-registration.changes +++ b/package/yast2-registration.changes @@ -2,6 +2,8 @@ Fri Aug 21 11:38:22 UTC 2015 - lslezak@suse.cz - Fixed registering a product with POOL flavor (bsc#941402) +- Addon selection dialog - avoid possible ID duplicates when + an addon with multiple versions is displayed ------------------------------------------------------------------- Mon Aug 17 14:40:05 UTC 2015 - igonzalezsosa@suse.com diff --git a/src/lib/registration/ui/addon_selection_base_dialog.rb b/src/lib/registration/ui/addon_selection_base_dialog.rb index 70765b36c..4ab592840 100644 --- a/src/lib/registration/ui/addon_selection_base_dialog.rb +++ b/src/lib/registration/ui/addon_selection_base_dialog.rb @@ -44,6 +44,15 @@ def run raise "Not implemented" end + protected + + # create widget ID for an addon + # @param [] addon the addon + # @return [String] widget id + def addon_widget_id(addon) + "#{addon.identifier}-#{addon.version}-#{addon.arch}" + end + private # reimplement this in a subclass @@ -154,7 +163,7 @@ def addon_checkbox_element(addon) # (%s is an extension name) label = addon.available? ? addon.label : (_("%s (not available)") % addon.label) - CheckBox(Id(addon.identifier), Opt(:notify), label, addon_selected?(addon)) + CheckBox(Id(addon_widget_id(addon)), Opt(:notify), label, addon_selected?(addon)) end # the main event loop - handle the user in put in the dialog @@ -191,14 +200,14 @@ def handle_next_button end # handler for changing the addon status in the main loop - # @param id [String] addon identifier + # @param id [String] addon widget id def handle_addon_selection(id) # check whether it's an add-on ID (checkbox clicked) - addon = @addons.find { |a| a.identifier == id } + addon = @addons.find { |a| addon_widget_id(a) == id } return unless addon show_addon_details(addon) - if Yast::UI.QueryWidget(Id(addon.identifier), :Value) + if Yast::UI.QueryWidget(Id(addon_widget_id(addon)), :Value) addon.selected else addon.unselected @@ -217,7 +226,7 @@ def show_addon_details(addon) # update the enabled/disabled status in UI for dependent addons def reactivate_dependencies @addons.each do |addon| - Yast::UI.ChangeWidget(Id(addon.identifier), :Enabled, addon.selectable?) + Yast::UI.ChangeWidget(Id(addon_widget_id(addon)), :Enabled, addon.selectable?) end end diff --git a/src/lib/registration/ui/addon_selection_registration_dialog.rb b/src/lib/registration/ui/addon_selection_registration_dialog.rb index 6d696afdf..b2e1c3279 100644 --- a/src/lib/registration/ui/addon_selection_registration_dialog.rb +++ b/src/lib/registration/ui/addon_selection_registration_dialog.rb @@ -60,7 +60,7 @@ def addon_selected?(addon) # update the enabled/disabled status in UI for dependent addons def reactivate_dependencies @addons.each do |addon| - Yast::UI.ChangeWidget(Id(addon.identifier), :Enabled, addon.selectable?) + Yast::UI.ChangeWidget(Id(addon_widget_id(addon)), :Enabled, addon.selectable?) end end end diff --git a/test/addon_selection_dialog_test.rb b/test/addon_selection_dialog_test.rb index 59d2b13a0..70b481735 100644 --- a/test/addon_selection_dialog_test.rb +++ b/test/addon_selection_dialog_test.rb @@ -29,13 +29,14 @@ end it "returns `:next` if some addons are selected and user click next" do - test_addon = addon_generator - expect(Yast::UI).to receive(:UserInput).and_return(test_addon.identifier, :next) + addon = addon_generator + widget = "#{addon.identifier}-#{addon.version}-#{addon.arch}" + expect(Yast::UI).to receive(:UserInput).and_return(widget, :next) # mock that widget is selected expect(Yast::UI).to receive(:QueryWidget) - .with(Yast::Term.new(:id, test_addon.identifier), :Value) + .with(Yast::Term.new(:id, widget), :Value) .and_return(true) - registration = double(activated_products: [], get_addon_list: [test_addon]) + registration = double(activated_products: [], get_addon_list: [addon]) expect(subject.run(registration)).to eq :next end end From 315094961b2b3adafea1e063cc75bdbde0068240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 21 Aug 2015 15:12:42 +0200 Subject: [PATCH 3/3] 3.1.143 --- package/yast2-registration.changes | 1 + package/yast2-registration.spec | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index 4bac87781..5ba595bb4 100644 --- a/package/yast2-registration.changes +++ b/package/yast2-registration.changes @@ -4,6 +4,7 @@ Fri Aug 21 11:38:22 UTC 2015 - lslezak@suse.cz - Fixed registering a product with POOL flavor (bsc#941402) - Addon selection dialog - avoid possible ID duplicates when an addon with multiple versions is displayed +- 3.1.143 ------------------------------------------------------------------- Mon Aug 17 14:40:05 UTC 2015 - igonzalezsosa@suse.com diff --git a/package/yast2-registration.spec b/package/yast2-registration.spec index df5b8538b..9eb64e563 100644 --- a/package/yast2-registration.spec +++ b/package/yast2-registration.spec @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 3.1.142 +Version: 3.1.143 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build