From 463dde6df2a53e2d348ceedf64604bb9bbe983f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Mon, 19 Nov 2018 23:27:27 +0000 Subject: [PATCH 1/3] Report chrony is missing --- src/lib/packager/clients/software_proposal.rb | 40 ++++++++----------- src/modules/Packages.rb | 13 ++++++ test/lib/clients/software_proposal_test.rb | 3 ++ test/test_helper.rb | 1 + 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/lib/packager/clients/software_proposal.rb b/src/lib/packager/clients/software_proposal.rb index 3e7e48e74..b3a832731 100644 --- a/src/lib/packager/clients/software_proposal.rb +++ b/src/lib/packager/clients/software_proposal.rb @@ -83,30 +83,13 @@ def make_proposal(flags) "warning_level" => :blocker ) end - remote_installation_error = Packages.check_remote_installation_packages - unless remote_installation_error.empty? - # The Default warning_level is "error". So the user can continue - # installation. - if @ret["warning"] - @ret["warning"] << "\n" - @ret["warning"] << remote_installation_error - else - @ret["warning"] = remote_installation_error - end - end - if Yast::Mode.auto - # AY: Checking if second stage is needed and the environment has been setup. - error_message = Yast::AutoinstData.autoyast_second_stage_error - unless error_message.empty? - if @ret["warning"] - @ret["warning"] << "\n" - else - @ret["warning"] = "" - end - @ret["warning"] << error_message - end - end + # The Default warning_level is "error". So the user can continue + # installation. + add_warning_if_needed(Packages.check_ntp_installation_packages) + add_warning_if_needed(Packages.check_remote_installation_packages) + # AY: Checking if second stage is needed and the environment has been setup. + add_warning_if_needed(Yast::AutoinstData.autoyast_second_stage_error) if Yast::Mode.auto @ret end @@ -143,6 +126,17 @@ def description private + # @param msg [String] warning message to be added + def add_warning_if_needed(msg) + return if msg.empty? + + if @ret.key?("warning") + @ret["warning"] << "\n#{msg}" + else + @ret["warning"] = msg + end + end + def partitioning_changed? changed = false diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index 4b11ca856..aaca34d1a 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -80,6 +80,7 @@ def main Yast.import "URL" Yast.import "PackagesProposal" Yast.import "HTML" + Yast.import "NtpClient" Yast.include self, "packager/load_release_notes.rb" @@ -857,6 +858,18 @@ def InitializeAddOnProducts nil end + # When the NTP configuration has been modified, it checks whether the + # service package is selected to be installed or not. + # @return [String] empty string or error message if the package is missing + def check_ntp_installation_packages + return "" unless NtpClient.modified + return "" if pkg_will_be_installed(NtpClientClass::REQUIRED_PACKAGE) + + # TRANSLATORS: warning message, %s is the service name + _("The NTP configuration (%s) has been modified, " \ + "but the package is not selected to be installed.") % "chrony" + end + # Checking if all needed packages for remote installation # will be installed on the target system. # @return [String] empty string or error message if there are missing packages diff --git a/test/lib/clients/software_proposal_test.rb b/test/lib/clients/software_proposal_test.rb index f432ebaef..627c602f0 100755 --- a/test/lib/clients/software_proposal_test.rb +++ b/test/lib/clients/software_proposal_test.rb @@ -25,7 +25,10 @@ end describe Yast::SoftwareProposalClient do + let(:ntp) { double("Yast::NtpClient", modified: false) } + before do + stub_const("Yast::NtpClient", ntp) allow(Yast::WFM).to receive(:CallFunction).and_return(:next) end diff --git a/test/test_helper.rb b/test/test_helper.rb index 34cef3de3..140148ac1 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -26,6 +26,7 @@ def stub_module(name) stub_module("Language") stub_module("Proxy") +stub_module("NtpClient") if ENV["COVERAGE"] require "simplecov" From 8799bb109cf14a9ef3228433c40ef94ac7624c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Tue, 20 Nov 2018 10:37:49 +0000 Subject: [PATCH 2/3] Changes based on code review. --- src/modules/Packages.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index aaca34d1a..a11490308 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -80,7 +80,6 @@ def main Yast.import "URL" Yast.import "PackagesProposal" Yast.import "HTML" - Yast.import "NtpClient" Yast.include self, "packager/load_release_notes.rb" @@ -862,12 +861,14 @@ def InitializeAddOnProducts # service package is selected to be installed or not. # @return [String] empty string or error message if the package is missing def check_ntp_installation_packages + Yast.import "NtpClient" + return "" unless NtpClient.modified return "" if pkg_will_be_installed(NtpClientClass::REQUIRED_PACKAGE) - # TRANSLATORS: warning message, %s is the service name - _("The NTP configuration (%s) has been modified, " \ - "but the package is not selected to be installed.") % "chrony" + # TRANSLATORS: warning message + _("The NTP configuration (chrony) has been modified, " \ + "but the package is not selected to be installed.") end # Checking if all needed packages for remote installation From 28f3cbbc9f1b02ea67f7041c55948d911762713d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Tue, 20 Nov 2018 10:45:25 +0000 Subject: [PATCH 3/3] Bump version & changelog --- package/yast2-packager.changes | 8 ++++++++ package/yast2-packager.spec | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package/yast2-packager.changes b/package/yast2-packager.changes index 6c1bbf445..35476a8a5 100644 --- a/package/yast2-packager.changes +++ b/package/yast2-packager.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Nov 20 10:37:59 UTC 2018 - knut.anderssen@suse.com + +- software_proposal: Added warning in case the NTP configuration + was modified but the package is not selected to be installed + (bsc#1082369) +- 4.0.72 + ------------------------------------------------------------------- Fri Nov 16 13:29:45 UTC 2018 - lslezak@suse.cz diff --git a/package/yast2-packager.spec b/package/yast2-packager.spec index 097b6289f..3adfde3d1 100644 --- a/package/yast2-packager.spec +++ b/package/yast2-packager.spec @@ -17,7 +17,7 @@ Name: yast2-packager -Version: 4.0.71 +Version: 4.0.72 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build