Hello community, here is the log from the commit of package yast2-ntp-client for openSUSE:Factory checked in at 2018-11-01 18:55:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-ntp-client (Old) and /work/SRC/openSUSE:Factory/.yast2-ntp-client.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-ntp-client" Thu Nov 1 18:55:34 2018 rev:107 rq:642235 version:4.1.3 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-ntp-client/yast2-ntp-client.changes 2018-09-04 22:50:13.899780556 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-ntp-client.new/yast2-ntp-client.changes 2018-11-01 18:55:38.289969172 +0100 @@ -1,0 +2,20 @@ +Tue Oct 16 10:28:35 CEST 2018 - sch...@suse.de + +- Fixed license path. Build error for bsc#1110598. +- 4.1.3 + +------------------------------------------------------------------- +Wed Oct 3 14:11:34 UTC 2018 - knut.anders...@suse.com + +- AutoYaST: Do not show the progress when merging the configuration + before writing it (bsc#1110598) +- 4.1.2 + +------------------------------------------------------------------- +Fri Sep 7 15:20:26 UTC 2018 - dgonza...@suse.com + +- Save the service status according to the user preferences + (bsc#1075039) +- 4.1.1 + +------------------------------------------------------------------- Old: ---- yast2-ntp-client-4.1.0.tar.bz2 New: ---- yast2-ntp-client-4.1.3.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-ntp-client.spec ++++++ --- /var/tmp/diff_new_pack.8DXqEY/_old 2018-11-01 18:55:39.217969248 +0100 +++ /var/tmp/diff_new_pack.8DXqEY/_new 2018-11-01 18:55:39.221969249 +0100 @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 4.1.0 +Version: 4.1.3 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0-or-later @@ -82,7 +82,7 @@ %ghost /etc/cron.d/suse-ntp_synchronize %dir %{yast_docdir} -%license %{yast_docdir}/COPYING +%license COPYING %doc %{yast_docdir}/README.md %doc %{yast_docdir}/CONTRIBUTING.md ++++++ yast2-ntp-client-4.1.0.tar.bz2 -> yast2-ntp-client-4.1.3.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-4.1.0/package/yast2-ntp-client.changes new/yast2-ntp-client-4.1.3/package/yast2-ntp-client.changes --- old/yast2-ntp-client-4.1.0/package/yast2-ntp-client.changes 2018-08-23 09:42:03.000000000 +0200 +++ new/yast2-ntp-client-4.1.3/package/yast2-ntp-client.changes 2018-10-16 11:03:32.000000000 +0200 @@ -1,4 +1,24 @@ ------------------------------------------------------------------- +Tue Oct 16 10:28:35 CEST 2018 - sch...@suse.de + +- Fixed license path. Build error for bsc#1110598. +- 4.1.3 + +------------------------------------------------------------------- +Wed Oct 3 14:11:34 UTC 2018 - knut.anders...@suse.com + +- AutoYaST: Do not show the progress when merging the configuration + before writing it (bsc#1110598) +- 4.1.2 + +------------------------------------------------------------------- +Fri Sep 7 15:20:26 UTC 2018 - dgonza...@suse.com + +- Save the service status according to the user preferences + (bsc#1075039) +- 4.1.1 + +------------------------------------------------------------------- Wed Aug 22 16:08:46 CEST 2018 - sch...@suse.de - Switched license in spec file from SPDX2 to SPDX3 format. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-4.1.0/package/yast2-ntp-client.spec new/yast2-ntp-client-4.1.3/package/yast2-ntp-client.spec --- old/yast2-ntp-client-4.1.0/package/yast2-ntp-client.spec 2018-08-23 09:42:03.000000000 +0200 +++ new/yast2-ntp-client-4.1.3/package/yast2-ntp-client.spec 2018-10-16 11:03:32.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 4.1.0 +Version: 4.1.3 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0-or-later @@ -82,7 +82,7 @@ %ghost /etc/cron.d/suse-ntp_synchronize %dir %{yast_docdir} -%license %{yast_docdir}/COPYING +%license COPYING %doc %{yast_docdir}/README.md %doc %{yast_docdir}/CONTRIBUTING.md diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-4.1.0/src/clients/ntp-client_proposal.rb new/yast2-ntp-client-4.1.3/src/clients/ntp-client_proposal.rb --- old/yast2-ntp-client-4.1.0/src/clients/ntp-client_proposal.rb 2018-08-23 09:42:03.000000000 +0200 +++ new/yast2-ntp-client-4.1.3/src/clients/ntp-client_proposal.rb 2018-10-16 11:03:32.000000000 +0200 @@ -329,57 +329,50 @@ true end - # params: - # server (taken from UI if empty) - # servers (intended to use all of opensuse.pool.ntp.org, - # but I did not have time to make it work) - # run_service (set to true if empty) - # write_only (bnc#589296) - # ntpdate_only (TODO rename to onetime) - # return: - # `success, `invalid_hostname or `ntpdate_failed - def Write(param) - log.info "ntp client proposal Write with #{param.inspect}" - ntp_servers = param["servers"] || [] - ntp_server = param["server"] || "" - run_service = param.fetch("run_service", true) - if ntp_server == "" - # get the value from UI only when it wasn't given as a parameter - ntp_server = UI.QueryWidget(Id(:ntp_address), :Value) - end - return :invalid_hostname if !ValidateSingleServer(ntp_server) + # Writes the NTP settings + # + # @param [Hash] params + # @option params [String] "server" The NTP server address, taken from the UI if empty + # @option params [Array<String>] "servers" A collection of NTP servers + # @option params [Boolean] "run_service" Whether service should be active and enable + # @option params [Boolean] "write_only" If only is needed to write the settings, (bnc#589296) + # @option params [Boolean] "ntpdate_only" ? TODO: rename to onetime + # + # @return [Symbol] :invalid_hostname, when a not valid ntp_server is given + # :ntpdate_failed, when the ntp sychronization fails + # :success, when settings (and sync if proceed) were performed successfully + def Write(params) + log.info "ntp client proposal Write with #{params.inspect}" + + # clean params + params.compact! + + ntp_server = params.fetch("server", "") + ntp_servers = params.fetch("servers", []) + run_service = params.fetch("run_service", NtpClient.run_service) + + # Get the ntp_server value from UI only if isn't present (probably wasn't given as parameter) + ntp_server = UI.QueryWidget(Id(:ntp_address), :Value) if ntp_server.strip.empty? + + return :invalid_hostname unless ValidateSingleServer(ntp_server) WriteNtpSettings(ntp_servers, ntp_server, run_service) - return :success if param["write_only"] - # In 1st stage, schedule packages for installation - if Stage.initial - Yast.import "Packages" - Packages.addAdditionalPackage(NtpClientClass::REQUIRED_PACKAGE) - # Otherwise, prompt user for confirming pkg installation - elsif !PackageSystem.CheckAndInstallPackages([NtpClientClass::REQUIRED_PACKAGE]) - Report.Error( - Builtins.sformat( - _( - "Synchronization with NTP server is not possible\nwithout package %1 installed." - ), - NtpClientClass::REQUIRED_PACKAGE - ) - ) - end + return :success if params["write_only"] + + add_or_install_required_package - ret = 0 + # Only if network is running try to synchronize the ntp server if NetworkService.isNetworkRunning - # Only if network is running try to synchronize the ntp server Popup.ShowFeedback("", _("Synchronizing with NTP server...")) - ret = NtpClient.sync_once(ntp_server) + exit_code = NtpClient.sync_once(ntp_server) Popup.ClearFeedback - end - return :ntpdate_failed if ret != 0 + return :ntpdate_failed unless exit_code.zero? + end # User wants more than running one time sync (synchronize on boot) - WriteNtpSettings(ntp_servers, ntp_server, run_service) if !param["ntpdate_only"] + WriteNtpSettings(ntp_servers, ntp_server, run_service) unless params["ntpdate_only"] :success end @@ -469,6 +462,24 @@ # success, exit true end + + private + + def add_or_install_required_package + # In 1st stage, schedule packages for installation + if Stage.initial + Yast.import "Packages" + Packages.addAdditionalPackage(NtpClientClass::REQUIRED_PACKAGE) + # Otherwise, prompt user for confirming pkg installation + elsif !PackageSystem.CheckAndInstallPackages([NtpClientClass::REQUIRED_PACKAGE]) + Report.Error( + Builtins.sformat( + _("Synchronization with NTP server is not possible\nwithout package %1 installed."), + NtpClientClass::REQUIRED_PACKAGE + ) + ) + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-4.1.0/src/lib/y2ntp_client/client/auto.rb new/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/client/auto.rb --- old/yast2-ntp-client-4.1.0/src/lib/y2ntp_client/client/auto.rb 2018-08-23 09:42:03.000000000 +0200 +++ new/yast2-ntp-client-4.1.3/src/lib/y2ntp_client/client/auto.rb 2018-10-16 11:03:32.000000000 +0200 @@ -39,9 +39,9 @@ end def write + progress_orig = Yast::Progress.set(false) # ensure to merge config to system chrony configuration to do minimal configuration Yast::NtpClient.merge_to_system - progress_orig = Yast::Progress.set(false) Yast::NtpClient.write_only = true ret = Yast::NtpClient.Write Yast::Progress.set(progress_orig) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-ntp-client-4.1.0/test/ntp_client_proposal_test.rb new/yast2-ntp-client-4.1.3/test/ntp_client_proposal_test.rb --- old/yast2-ntp-client-4.1.0/test/ntp_client_proposal_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-ntp-client-4.1.3/test/ntp_client_proposal_test.rb 2018-10-16 11:03:32.000000000 +0200 @@ -0,0 +1,169 @@ +require_relative "test_helper" + +require_relative "../src/clients/ntp-client_proposal.rb" + +Yast.import "Packages" + +describe Yast::NtpClientProposalClient do + subject do + client = described_class.new + client.main + client + end + + describe "#Write" do + let(:ntp_server) { "fake.pool.ntp.org" } + let(:write_only) { false } + let(:ntpdate_only) { true } + let(:params) do + { + "server" => ntp_server, + "write_only" => write_only, + "ntpdate_only" => ntpdate_only + } + end + let(:ntp_client) { Yast::NtpClient } + let(:initial_stage) { false } + let(:network_running) { false } + + before do + allow(subject).to receive(:WriteNtpSettings) + + allow(Yast::Stage).to receive(:initial).and_return(initial_stage) + allow(Yast::PackageSystem).to receive(:CheckAndInstallPackages) + allow(Yast::Report).to receive(:Error) + allow(Yast::NetworkService).to receive(:isNetworkRunning).and_return(network_running) + end + + context "with a not valid hostname" do + let(:ntp_server) { nil } + + it "does not write settings" do + expect(subject).to_not receive(:WriteNtpSettings) + + subject.Write(params) + end + + it "returns :invalid_hostname" do + expect(subject.Write(params)).to eq(:invalid_hostname) + end + end + + context "with valid hostname" do + before do + allow(subject).to receive(:ValidateSingleServer).and_return(true) + end + + context "but in 'write_only' mode" do + let(:write_only) { true } + + it "only writes settings" do + expect(subject).to receive(:WriteNtpSettings).once + expect(Yast::Stage).to_not receive(:initial) + expect(Yast::NetworkService).to_not receive(:isNetworkRunning) + + subject.Write(params) + end + + it "returns :success" do + expect(subject.Write(params)).to eq(:success) + end + end + + context "but 'run_service' param is not given" do + it "uses the current value of NtpClient.run_service" do + ntp_client.run_service = true + expect(subject).to receive(:WriteNtpSettings).with(anything, anything, true) + subject.Write({}) + + ntp_client.run_service = false + expect(subject).to receive(:WriteNtpSettings).with(anything, anything, false) + subject.Write({}) + end + end + + context "and is in the initial stage" do + let(:initial_stage) { true } + + it "imports Yast::Packages" do + allow(Yast).to receive(:import).and_call_original + expect(Yast).to receive(:import).with("Packages") + + subject.Write(params) + end + + it "adds the additional package" do + expect(Yast::Packages).to receive(:addAdditionalPackage) + + subject.Write(params) + end + end + + context "and is not in the initial stage" do + it "asks user to confirm the package installation" do + expect(Yast::PackageSystem).to receive(:CheckAndInstallPackages) + + subject.Write(params) + end + + context "but user rejects the package installation" do + before do + allow(Yast::PackageSystem).to receive(:CheckAndInstallPackages).and_return(false) + end + + it "reports an error" do + expect(Yast::Report).to receive(:Error).with(/Synchronization with NTP server is not/) + + subject.Write(params) + end + end + end + + context "and network is not available" do + it "does not performs the ntp syncronization" do + expect(Yast::NtpClient).to_not receive(:sync_once) + + subject.Write(params) + end + + it "returns :success" do + expect(subject.Write(params)).to eq(:success) + end + end + + context "and network is available" do + let(:network_running) { true } + + it "returns :ntpdate_failed if synchronization fails" do + allow(Yast::NtpClient).to receive(:sync_once).with(ntp_server).and_return(1) + + expect(subject.Write(params)).to eq(:ntpdate_failed) + end + + it "returns :success if syncronization was successfully" do + allow(Yast::NtpClient).to receive(:sync_once).with(ntp_server).and_return(0) + + expect(subject.Write(params)).to eq(:success) + end + end + + context "and user only wants to syncronize date" do + it "writes settings only once" do + expect(subject).to receive(:WriteNtpSettings).once + + subject.Write(params) + end + end + + context "and user wants to syncronize on boot" do + let(:ntpdate_only) { false } + + it "writes settings again?" do + expect(subject).to receive(:WriteNtpSettings).twice + + subject.Write(params) + end + end + end + end +end