Skip to content

Commit

Permalink
Report chrony is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Nov 19, 2018
1 parent 55ab246 commit 463dde6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
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
13 changes: 13 additions & 0 deletions src/modules/Packages.rb
Expand Up @@ -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"

Expand Down Expand Up @@ -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
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 463dde6

Please sign in to comment.