Skip to content

Commit

Permalink
Merge pull request #390 from yast/package_missing
Browse files Browse the repository at this point in the history
Report chrony is missing
  • Loading branch information
teclator committed Nov 20, 2018
2 parents 55ab246 + 28f3cbb commit 7592bcf
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 24 deletions.
8 changes: 8 additions & 0 deletions 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

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 4.0.71
Version: 4.0.72
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
40 changes: 17 additions & 23 deletions src/lib/packager/clients/software_proposal.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions src/modules/Packages.rb
Expand Up @@ -857,6 +857,20 @@ 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
Yast.import "NtpClient"

return "" unless NtpClient.modified
return "" if pkg_will_be_installed(NtpClientClass::REQUIRED_PACKAGE)

# 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
# will be installed on the target system.
# @return [String] empty string or error message if there are missing packages
Expand Down
3 changes: 3 additions & 0 deletions test/lib/clients/software_proposal_test.rb
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Expand Up @@ -26,6 +26,7 @@ def stub_module(name)

stub_module("Language")
stub_module("Proxy")
stub_module("NtpClient")

if ENV["COVERAGE"]
require "simplecov"
Expand Down

0 comments on commit 7592bcf

Please sign in to comment.