From e906d8a1206bd614e2cf9d00416fcfe74eefff87 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Thu, 9 Apr 2020 13:22:22 +0200 Subject: [PATCH 1/6] Added missing require (bsc#1167945) --- src/lib/registration/clients/inst_migration_repos.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/registration/clients/inst_migration_repos.rb b/src/lib/registration/clients/inst_migration_repos.rb index 26cef43e4..8b912bbab 100644 --- a/src/lib/registration/clients/inst_migration_repos.rb +++ b/src/lib/registration/clients/inst_migration_repos.rb @@ -14,6 +14,7 @@ require "yast" require "yast/suse_connect" +require "registration/sw_mgmt" module Registration module Clients From 5bc55f7eb1a431b6621db6f28e2aeb31ca7eff02 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Thu, 9 Apr 2020 14:36:13 +0200 Subject: [PATCH 2/6] Version bump and change log --- package/yast2-registration.changes | 6 ++++++ package/yast2-registration.spec | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index 9cb35d6bd..e9a5bbd40 100644 --- a/package/yast2-registration.changes +++ b/package/yast2-registration.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 9 12:35:25 UTC 2020 - Stefan Hundhammer + +- Crash fix backport: Added missing require (bsc#1167945) +- 4.1.25 + ------------------------------------------------------------------- Thu Oct 10 13:39:18 UTC 2019 - Josef Reidinger diff --git a/package/yast2-registration.spec b/package/yast2-registration.spec index 82c6c4c03..3186a171a 100644 --- a/package/yast2-registration.spec +++ b/package/yast2-registration.spec @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.1.24 +Version: 4.1.25 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build From 574cd1ce5ec64242f565869aaa52f358ec2d10c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Tue, 21 Apr 2020 16:35:35 +0200 Subject: [PATCH 3/6] Adapt Rakefile and Dockerfile for SLE-15-SP2 --- Dockerfile | 2 +- Rakefile | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 94abc8600..159e190b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ -FROM registry.opensuse.org/yast/head/containers/yast-ruby:latest +FROM registry.opensuse.org/yast/sle-15/sp2/containers/yast-ruby COPY . /usr/src/app diff --git a/Rakefile b/Rakefile index 2432dd52a..f7b76ca59 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,7 @@ require "yast/rake" +Yast::Tasks.submit_to :sle15sp2 + Yast::Tasks.configuration do |conf| # lets ignore license check for now conf.skip_license_check << /.*/ From eb645e25de8ddce00380a4281e7105ec73da93bd Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Fri, 22 May 2020 13:53:32 +0200 Subject: [PATCH 4/6] Declining/refusal of an addon license means canceling all addons. (bsc#1169577) Without this, an addon is still installed even if its license is declined. In commit 1c7d041f6b3e71dce6a6f6062f10b1d6f0121754, PR https://github.com/yast/yast-registration/pull/440 , the idea was that we can unselect an addon whose license was declined, and proceed with installing the remaining addons. But that does not work out with autoselected addons ( https://github.com/yast/yast-registration/pull/335 https://github.com/yast/yast-registration/pull/338 ) where we take into account the product dependencies. The new solution is to interpret a refusal of a license as the Back button, which ends installation of ALL selected addons. --- src/lib/registration/ui/addon_eula_dialog.rb | 28 ++++++++++++------- .../registration/ui/addon_eula_dialog_test.rb | 16 +++++------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/lib/registration/ui/addon_eula_dialog.rb b/src/lib/registration/ui/addon_eula_dialog.rb index 0891229b9..75e66f8c7 100644 --- a/src/lib/registration/ui/addon_eula_dialog.rb +++ b/src/lib/registration/ui/addon_eula_dialog.rb @@ -48,6 +48,9 @@ def run false ) + # Default: no EULA specified => accepted + eula_ret = :accepted + addons.each do |addon| next unless addon.eula_acceptance_needed? next if addon.registered? @@ -55,10 +58,13 @@ def run log.info "Addon '#{addon.name}' has an EULA at #{addon.eula_url}" eula_ret = accept_eula(addon) - return eula_ret if eula_ret != :next + # any declined license needs to be handled separately + break if eula_ret != :accepted end - :next + # go back if any EULA has not been accepted, let the user + # deselect the not accepted extension + eula_ret == :accepted ? :next : eula_ret end private @@ -104,34 +110,35 @@ def setup_eula_dialog(addon, eula_reader, tmpdir) display_optional_info(File.join(tmpdir, "README.BETA")) end - # run the EULA agreement dialog + # Run the EULA agreement dialog. # @param [EulaReader] eula_reader read EULAs - # @return [Symbol] :accepted, :back, :abort, :halt - user input + # @return [Symbol] :accepted, :back def run_eula_dialog(eula_reader) base_product = false - cancel_action = "refuse" + cancel_action = "abort" ret = Yast::ProductLicense.HandleLicenseDialogRet(arg_ref(eula_reader.licenses), base_product, cancel_action) + ret = :back if ret == :abort log.debug "EULA dialog result: #{ret}" ret end - # ask user to accept an addon EULA + # Ask user to accept an addon EULA. + # Declining (refusing) the license is translated into Back + # which will fit nicely from the caller's point of view. # @param [Addon] addon the addon - # @return [Symbol] :back, :abort, :halt + # @return [Symbol] :accepted, :back def accept_eula(addon) Dir.mktmpdir("extension-eula-") do |tmpdir| return :back unless download_eula(addon, tmpdir) eula_reader = EulaReader.new(tmpdir) license = find_license(addon, eula_reader) - return :next if license && license.accepted? + return :accepted if license && license.accepted? setup_eula_dialog(addon, eula_reader, tmpdir) ret = run_eula_dialog(eula_reader) license.accept! if ret == :accepted - - return :next if [:accepted, :refused].include?(ret) ret end ensure @@ -144,6 +151,7 @@ def display_optional_info(info_file) Yast::InstShowInfo.show_info_txt(info_file) if File.exist?(info_file) end + # @return [Y2Packager::License] def find_license(addon, eula_reader) license_file = eula_reader.licenses[Y2Packager::License::DEFAULT_LANG] return nil unless license_file diff --git a/test/registration/ui/addon_eula_dialog_test.rb b/test/registration/ui/addon_eula_dialog_test.rb index f33c29187..80881b4f3 100644 --- a/test/registration/ui/addon_eula_dialog_test.rb +++ b/test/registration/ui/addon_eula_dialog_test.rb @@ -53,7 +53,7 @@ context "when there are EULA acceptances pending" do let(:addons) { [addon_with_eula, second_addon_with_eula] } - let(:first_dialog_response) { :refused } + let(:first_dialog_response) { :accepted } let(:second_dialog_response) { :accepted } before do @@ -72,8 +72,8 @@ context "and the user wants to abort" do let(:first_dialog_response) { :abort } - it "returns :abort" do - expect(subject.run).to eq(:abort) + it "returns :back anyway" do + expect(subject.run).to eq(:back) end end @@ -120,15 +120,15 @@ before do allow(Yast::ProductLicense).to receive(:HandleLicenseDialogRet) - .and_return(:refused) + .and_return(:abort) end it "does not set it as accepted" do expect(product_license).to_not receive(:accept!) end - it "returns :next" do - expect(dialog.run).to eq(:next) + it "returns :back" do + expect(dialog.run).to eq(:back) end end end @@ -194,8 +194,8 @@ context "when the license was previously accepted" do let(:accepted?) { true } - it "returns :next" do - expect(dialog.send(:accept_eula, addon)).to eq(:next) + it "returns :accepted" do + expect(dialog.send(:accept_eula, addon)).to eq(:accepted) end it "does not show the eula" do From 990f40874633e29a1c64746e407c30b14206a66c Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Thu, 28 May 2020 12:53:35 +0200 Subject: [PATCH 5/6] version + changelog --- package/yast2-registration.changes | 7 +++++++ package/yast2-registration.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index e9a5bbd40..dc41ce798 100644 --- a/package/yast2-registration.changes +++ b/package/yast2-registration.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu May 28 10:50:51 UTC 2020 - Martin Vidner + +- Declining/refusal of an addon license means canceling all addons. + (bsc#1169577) +- 4.1.26 + ------------------------------------------------------------------- Thu Apr 9 12:35:25 UTC 2020 - Stefan Hundhammer diff --git a/package/yast2-registration.spec b/package/yast2-registration.spec index 3186a171a..a121e12d1 100644 --- a/package/yast2-registration.spec +++ b/package/yast2-registration.spec @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.1.25 +Version: 4.1.26 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build From 6b047f36a69f2730b400d1b9ec8494c034d585b0 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Thu, 28 May 2020 15:51:55 +0200 Subject: [PATCH 6/6] More yardoc --- src/lib/registration/addon.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/registration/addon.rb b/src/lib/registration/addon.rb index 088ff1ca4..ce9f891a9 100644 --- a/src/lib/registration/addon.rb +++ b/src/lib/registration/addon.rb @@ -26,7 +26,8 @@ require "y2packager/resolvable" module Registration - # this is a wrapper class around SUSE::Connect::Product object + # A wrapper class around SUSE::Connect::Product object, + # https://rubydoc.info/github/SUSE/connect/SUSE/Connect/Product class Addon extend Yast::I18n include Yast::I18n @@ -38,6 +39,7 @@ class << self # read the remote add-on from the registration server # @param registration [Registration::Registration] use this object for # reading the remote add-ons + # @return [Array] def find_all(registration) return @cached_addons if @cached_addons @@ -83,7 +85,7 @@ def reset_auto_selected @auto_selected = nil end - # list of auto selected add-ons + # @return [Array] auto selected add-ons def auto_selected @auto_selected ||= detect_auto_selection end @@ -155,6 +157,7 @@ def create_addon_with_deps(root) result end + # @return [Array] def load_addons(registration) pure_addons = registration.get_addon_list # get IDs of the already activated addons @@ -172,6 +175,7 @@ def load_addons(registration) end end + # @return [Array] def detect_auto_selection required = selected + registered