Hello community,
here is the log from the commit of package yast2-ntp-client for
openSUSE:Factory checked in at 2019-10-16 09:11:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-ntp-client (Old)
and /work/SRC/openSUSE:Factory/.yast2-ntp-client.new.2352 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-ntp-client"
Wed Oct 16 09:11:45 2019 rev:115 rq:738617 version:4.2.5
Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-ntp-client/yast2-ntp-client.changes
2019-10-03 14:07:01.200476816 +0200
+++
/work/SRC/openSUSE:Factory/.yast2-ntp-client.new.2352/yast2-ntp-client.changes
2019-10-16 09:11:46.588010162 +0200
@@ -1,0 +2,6 @@
+Mon Oct 14 18:20:17 UTC 2019 - Josef Reidinger <[email protected]>
+
+- switch from cron to systemd timers (jsc#SLE-9113)
+- 4.2.5
+
+-------------------------------------------------------------------
Old:
----
yast2-ntp-client-4.2.4.tar.bz2
New:
----
yast2-ntp-client-4.2.5.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-ntp-client.spec ++++++
--- /var/tmp/diff_new_pack.8xJAvA/_old 2019-10-16 09:11:47.016009059 +0200
+++ /var/tmp/diff_new_pack.8xJAvA/_new 2019-10-16 09:11:47.020009049 +0200
@@ -17,7 +17,7 @@
Name: yast2-ntp-client
-Version: 4.2.4
+Version: 4.2.5
Release: 0
Summary: YaST2 - NTP Client Configuration
License: GPL-2.0-or-later
@@ -28,10 +28,11 @@
BuildRequires: augeas-lenses
BuildRequires: autoyast2-installation
-# Needed for /etc/cron.* ownership; those directories have special permission
handling
-BuildRequires: cron
BuildRequires: perl-XML-Writer
BuildRequires: update-desktop-files
+# need as it own /usr/lib/systemd and for systemd macros
+BuildRequires: systemd-rpm-macros
+%{?systemd_requires}
# cwm/popup
BuildRequires: yast2 >= 4.1.15
BuildRequires: yast2-country-data
@@ -71,12 +72,32 @@
%yast_metainfo
%post
+%service_add_post yast-timesync.service
+
# upgrade old name and convert it to chrony (bsc#1079122)
if [ -f /etc/cron.d/novell.ntp-synchronize ]; then
mv /etc/cron.d/novell.ntp-synchronize /etc/cron.d/suse-ntp_synchronize
sed -i 's:\* \* \* \* root .*:* * * * root /usr/sbin/chronyd -q
\&>/dev/null:' /etc/cron.d/suse-ntp_synchronize
fi
+# and now update cron to systemd timer. We need to support upgrade from SLE12
and also SLE15 SP1.
+# jsc#SLE-9113
+if [ -f /etc/cron.d/suse-ntp_synchronize ]; then
+ /usr/bin/erb timeout=$(grep -o '[[:digit:]]\+'
/etc/cron.d/suse-ntp_synchronize) /usr/share/YaST2/data/yast-timesync.timer.erb
> /etc/systemd/system/yast-timesync.timer
+ /bin/systemctl enable yast-timesync.timer
+ /bin/systemctl start yast-timesync.timer
+ rm /etc/cron.d/suse-ntp_synchronize
+fi
+
+%pre
+%service_add_pre yast-timesync.service
+
+%postun
+%service_del_postun yast-timesync.service
+
+%preun
+%service_del_preun yast-timesync.service
+
%files
%{yast_clientdir}
%{yast_libdir}
@@ -86,8 +107,8 @@
%{yast_metainfodir}
%{yast_ydatadir}
%{yast_schemadir}
-%ghost %{_sysconfdir}/cron.d/suse-ntp_synchronize
%{yast_icondir}
+%{_unitdir}/yast-timesync.service
%license COPYING
%doc %{yast_docdir}
++++++ yast2-ntp-client-4.2.4.tar.bz2 -> yast2-ntp-client-4.2.5.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/.rubocop.yml
new/yast2-ntp-client-4.2.5/.rubocop.yml
--- old/yast2-ntp-client-4.2.4/.rubocop.yml 2019-10-02 14:34:59.000000000
+0200
+++ new/yast2-ntp-client-4.2.5/.rubocop.yml 2019-10-15 15:02:57.000000000
+0200
@@ -1,6 +1,6 @@
# use the shared Yast defaults
inherit_from:
- /usr/share/YaST2/data/devtools/data/rubocop_yast_style.yml
+ /usr/share/YaST2/data/devtools/data/rubocop-0.71.0_yast_style.yml
Metrics/AbcSize:
Max: 129
@@ -73,7 +73,7 @@
Include:
- 'src/lib/**/*.rb' # force well documented code only for new code
-Style/FileName:
+Naming/FileName:
Include:
- 'src/lib/**/*.rb' # force correct names on new code
@@ -81,14 +81,22 @@
Style/Lambda:
Enabled: false
-Style/MethodName:
+Naming/MethodName:
Include:
- 'src/lib/**/*.rb' # force correct names on new code
-Style/VariableName:
+Naming/VariableName:
Include:
- 'src/lib/**/*.rb' # force known variables only for new code
# method_alias is safer and more predictable
Style/Alias:
EnforcedStyle: prefer_alias_method
+
+# this needs more testing if we can have frozen string literals
+Style/FrozenStringLiteralComment:
+ Enabled: false
+
+Metrics/BlockLength:
+ Exclude:
+ - "test/**/*"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/Rakefile
new/yast2-ntp-client-4.2.5/Rakefile
--- old/yast2-ntp-client-4.2.4/Rakefile 2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/Rakefile 2019-10-15 15:02:57.000000000 +0200
@@ -3,4 +3,6 @@
Yast::Tasks.configuration do |conf|
# lets ignore license check for now
conf.skip_license_check << /.*/
+ conf.install_locations["src/systemd/*"] =
+ Packaging::Configuration::DESTDIR + "/usr/lib/systemd/system/"
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/package/yast2-ntp-client.changes
new/yast2-ntp-client-4.2.5/package/yast2-ntp-client.changes
--- old/yast2-ntp-client-4.2.4/package/yast2-ntp-client.changes 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/package/yast2-ntp-client.changes 2019-10-15
15:02:57.000000000 +0200
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Mon Oct 14 18:20:17 UTC 2019 - Josef Reidinger <[email protected]>
+
+- switch from cron to systemd timers (jsc#SLE-9113)
+- 4.2.5
+
+-------------------------------------------------------------------
Wed Oct 2 11:42:34 UTC 2019 - Josef Reidinger <[email protected]>
- implement starting chrony-wait only if product require it
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/package/yast2-ntp-client.spec
new/yast2-ntp-client-4.2.5/package/yast2-ntp-client.spec
--- old/yast2-ntp-client-4.2.4/package/yast2-ntp-client.spec 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/package/yast2-ntp-client.spec 2019-10-15
15:02:57.000000000 +0200
@@ -17,7 +17,7 @@
Name: yast2-ntp-client
-Version: 4.2.4
+Version: 4.2.5
Release: 0
Summary: YaST2 - NTP Client Configuration
License: GPL-2.0-or-later
@@ -28,10 +28,11 @@
BuildRequires: augeas-lenses
BuildRequires: autoyast2-installation
-# Needed for /etc/cron.* ownership; those directories have special permission
handling
-BuildRequires: cron
BuildRequires: perl-XML-Writer
BuildRequires: update-desktop-files
+# need as it own /usr/lib/systemd and for systemd macros
+BuildRequires: systemd-rpm-macros
+%{?systemd_requires}
# cwm/popup
BuildRequires: yast2 >= 4.1.15
BuildRequires: yast2-country-data
@@ -71,12 +72,32 @@
%yast_metainfo
%post
+%service_add_post yast-timesync.service
+
# upgrade old name and convert it to chrony (bsc#1079122)
if [ -f /etc/cron.d/novell.ntp-synchronize ]; then
mv /etc/cron.d/novell.ntp-synchronize /etc/cron.d/suse-ntp_synchronize
sed -i 's:\* \* \* \* root .*:* * * * root /usr/sbin/chronyd -q
\&>/dev/null:' /etc/cron.d/suse-ntp_synchronize
fi
+# and now update cron to systemd timer. We need to support upgrade from SLE12
and also SLE15 SP1.
+# jsc#SLE-9113
+if [ -f /etc/cron.d/suse-ntp_synchronize ]; then
+ /usr/bin/erb timeout=$(grep -o '[[:digit:]]\+'
/etc/cron.d/suse-ntp_synchronize) /usr/share/YaST2/data/yast-timesync.timer.erb
> /etc/systemd/system/yast-timesync.timer
+ /bin/systemctl enable yast-timesync.timer
+ /bin/systemctl start yast-timesync.timer
+ rm /etc/cron.d/suse-ntp_synchronize
+fi
+
+%pre
+%service_add_pre yast-timesync.service
+
+%postun
+%service_del_postun yast-timesync.service
+
+%preun
+%service_del_preun yast-timesync.service
+
%files
%{yast_clientdir}
%{yast_libdir}
@@ -86,8 +107,8 @@
%{yast_metainfodir}
%{yast_ydatadir}
%{yast_schemadir}
-%ghost %{_sysconfdir}/cron.d/suse-ntp_synchronize
%{yast_icondir}
+%{_unitdir}/yast-timesync.service
%license COPYING
%doc %{yast_docdir}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/src/clients/ntp-client.rb
new/yast2-ntp-client-4.2.5/src/clients/ntp-client.rb
--- old/yast2-ntp-client-4.2.4/src/clients/ntp-client.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/clients/ntp-client.rb 2019-10-15
15:02:57.000000000 +0200
@@ -1,9 +1,7 @@
-# encoding: utf-8
-
-# File: clients/ntp-client.ycp
-# Package: Configuration of ntp-client
-# Summary: Main file
-# Authors: Jiri Srain <[email protected]>
+# File: clients/ntp-client.ycp
+# Package: Configuration of ntp-client
+# Summary: Main file
+# Authors: Jiri Srain <[email protected]>
#
# $Id$
#
@@ -52,6 +50,7 @@
ret = NtpClientSequence()
return ret if Yast::Stage.firstboot
return false if ret == :abort || ret == :back || ret.nil?
+
true
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/clients/ntp-client_auto.rb
new/yast2-ntp-client-4.2.5/src/clients/ntp-client_auto.rb
--- old/yast2-ntp-client-4.2.4/src/clients/ntp-client_auto.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/clients/ntp-client_auto.rb 2019-10-15
15:02:57.000000000 +0200
@@ -1,5 +1,3 @@
-# encoding: utf-8
-
require "yast"
require "y2ntp_client/client/auto"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/clients/ntp-client_finish.rb
new/yast2-ntp-client-4.2.5/src/clients/ntp-client_finish.rb
--- old/yast2-ntp-client-4.2.4/src/clients/ntp-client_finish.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/clients/ntp-client_finish.rb 2019-10-15
15:02:57.000000000 +0200
@@ -1,5 +1,3 @@
-# encoding: utf-8
-
require "y2ntp_client/client/finish"
Y2NtpClient::Client::Finish.run
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/clients/ntp-client_proposal.rb
new/yast2-ntp-client-4.2.5/src/clients/ntp-client_proposal.rb
--- old/yast2-ntp-client-4.2.4/src/clients/ntp-client_proposal.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/clients/ntp-client_proposal.rb
2019-10-15 15:02:57.000000000 +0200
@@ -1,5 +1,3 @@
-# encoding: utf-8
-
require "yast"
module Yast
@@ -139,9 +137,8 @@
UI.ChangeWidget(Id(:ntp_now), :Enabled, enabled)
end
UI.ChangeWidget(Id(:ntp_save), :Enabled, enabled)
- if UI.WidgetExists(Id(:ntp_configure)) # bnc#483787
- UI.ChangeWidget(Id(:ntp_configure), :Enabled, enabled)
- end
+ # bnc#483787
+ UI.ChangeWidget(Id(:ntp_configure), :Enabled, enabled) if
UI.WidgetExists(Id(:ntp_configure))
nil
end
@@ -204,10 +201,10 @@
nil
end
+ # @param [Yast::Term] replace_point id of replace point which should be
used
# @param [Boolean] first_time when asking for first time, we check if
service is running
# @return should our radio button be selected
- def ui_init(rp, first_time)
- rp = deep_copy(rp)
+ def ui_init(replace_point, first_time)
cont = VBox(
VSpacing(0.5),
HBox(
@@ -272,14 +269,14 @@
)
)
- UI.ReplaceWidget(rp, cont)
+ UI.ReplaceWidget(replace_point, cont)
UI.ChangeWidget(Id(:ntp_now), :Enabled, false) if
!NetworkService.isNetworkRunning
# ^ createui0
# FIXME: is it correct? move out?
- ntp_used = first_time && !Stage.initial ? GetNTPEnabled() :
NtpClient.ntp_selected
+ ntp_used = (first_time && !Stage.initial) ? GetNTPEnabled() :
NtpClient.ntp_selected
UI.ChangeWidget(Id(:ntp_save), :Value, ntp_used)
@@ -305,7 +302,7 @@
# Writes configuration for ntp client.
# @param ntp_servers [Array<String>] list of servers to configure as ntp
sync sources
# @param ntp_server [String] fallback server that is used if `ntp_servers`
param is empty.
- # @param run_service [Boolean] define if synchronize with systemd services
or via cron sync
+ # @param run_service [Boolean] define if synchronize with systemd services
or via systemd timer
# @return true
def WriteNtpSettings(ntp_servers, ntp_server, run_service)
ntp_servers = deep_copy(ntp_servers)
@@ -383,9 +380,10 @@
end
# ui = UI::UserInput
- def ui_handle(ui)
+ def ui_handle(input)
redraw = false
- if ui == :ntp_configure
+ case input
+ when :ntp_configure
rv = AskUser()
if rv == :invalid_hostname
handle_invalid_hostname(
@@ -395,8 +393,7 @@
# show the 'save' status after configuration
UI.ChangeWidget(Id(:ntp_save), :Value, GetNTPEnabled())
end
- end
- if ui == :ntp_now
+ when :ntp_now
rv = Write("ntpdate_only" => true)
if rv == :invalid_hostname
handle_invalid_hostname(UI.QueryWidget(Id(:ntp_address), :Value))
@@ -405,10 +402,9 @@
else
Report.Error(_("Connection to selected NTP server failed."))
end
- end
- if ui == :accept && Stage.initial
+ when :accept
# checking if chrony is available for installation.
- if UI.QueryWidget(Id(:ntp_save), :Value) == true &&
+ if Stage.initial && UI.QueryWidget(Id(:ntp_save), :Value) == true &&
!Pkg.IsAvailable(NtpClientClass::REQUIRED_PACKAGE)
Report.Error(Builtins.sformat(
# TRANSLATORS: Popup message. %1 is the missing package name.
@@ -427,12 +423,8 @@
argmap = {}
Ops.set(argmap, "ntpdate_only", false)
Ops.set(argmap, "run_service", false)
- if UI.QueryWidget(Id(:ntp_save), :Value) == false
- Ops.set(argmap, "ntpdate_only", true)
- end
- if UI.QueryWidget(Id(:run_service), :Value) == true
- Ops.set(argmap, "run_service", true)
- end
+ Ops.set(argmap, "ntpdate_only", true) if UI.QueryWidget(Id(:ntp_save),
:Value) == false
+ Ops.set(argmap, "run_service", true) if UI.QueryWidget(Id(:run_service),
:Value) == true
rv = Write(argmap)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/data/yast-timesync.timer.erb
new/yast2-ntp-client-4.2.5/src/data/yast-timesync.timer.erb
--- old/yast2-ntp-client-4.2.4/src/data/yast-timesync.timer.erb 1970-01-01
01:00:00.000000000 +0100
+++ new/yast2-ntp-client-4.2.5/src/data/yast-timesync.timer.erb 2019-10-15
15:02:57.000000000 +0200
@@ -0,0 +1,7 @@
+[Timer]
+# first sync after boot
+OnBootSec=1min
+OnUnitActiveSec=<%= timeout %>min
+
+[Install]
+WantedBy=timers.target
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/include/ntp-client/commandline.rb
new/yast2-ntp-client-4.2.5/src/include/ntp-client/commandline.rb
--- old/yast2-ntp-client-4.2.4/src/include/ntp-client/commandline.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/include/ntp-client/commandline.rb
2019-10-15 15:02:57.000000000 +0200
@@ -1,9 +1,7 @@
-# encoding: utf-8
-
-# File: clients/ntp-client.ycp
-# Package: Configuration of ntp-client
-# Summary: Main file
-# Authors: Jiri Srain <[email protected]>
+# File: clients/ntp-client.ycp
+# Package: Configuration of ntp-client
+# Summary: Main file
+# Authors: Jiri Srain <[email protected]>
#
# $Id$
#
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/include/ntp-client/dialogs.rb
new/yast2-ntp-client-4.2.5/src/include/ntp-client/dialogs.rb
--- old/yast2-ntp-client-4.2.4/src/include/ntp-client/dialogs.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/include/ntp-client/dialogs.rb
2019-10-15 15:02:57.000000000 +0200
@@ -1,9 +1,7 @@
-# encoding: utf-8
-
-# File: clients/ntp-client.ycp
-# Package: Configuration of ntp-client
-# Summary: Main file
-# Authors: Jiri Srain <[email protected]>
+# File: clients/ntp-client.ycp
+# Package: Configuration of ntp-client
+# Summary: Main file
+# Authors: Jiri Srain <[email protected]>
#
# $Id$
#
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/include/ntp-client/helps.rb
new/yast2-ntp-client-4.2.5/src/include/ntp-client/helps.rb
--- old/yast2-ntp-client-4.2.4/src/include/ntp-client/helps.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/include/ntp-client/helps.rb 2019-10-15
15:02:57.000000000 +0200
@@ -1,9 +1,7 @@
-# encoding: utf-8
-
-# File: include/ntp-client/helps.ycp
-# Package: Configuration of ntp-client
-# Summary: Help texts of all the dialogs
-# Authors: Jiri Srain <[email protected]>
+# File: include/ntp-client/helps.ycp
+# Package: Configuration of ntp-client
+# Summary: Help texts of all the dialogs
+# Authors: Jiri Srain <[email protected]>
#
# $Id$
module Yast
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/include/ntp-client/misc.rb
new/yast2-ntp-client-4.2.5/src/include/ntp-client/misc.rb
--- old/yast2-ntp-client-4.2.4/src/include/ntp-client/misc.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/include/ntp-client/misc.rb 2019-10-15
15:02:57.000000000 +0200
@@ -1,9 +1,7 @@
-# encoding: utf-8
-
-# File: include/ntp-client/misc.ycp
-# Package: Configuration of ntp-client
-# Summary: Miscelanous functions for configuration of ntp-client.
-# Authors: Jiri Srain <[email protected]>
+# File: include/ntp-client/misc.ycp
+# Package: Configuration of ntp-client
+# Summary: Miscelanous functions for configuration of ntp-client.
+# Authors: Jiri Srain <[email protected]>
#
# $Id$
module Yast
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/include/ntp-client/wizards.rb
new/yast2-ntp-client-4.2.5/src/include/ntp-client/wizards.rb
--- old/yast2-ntp-client-4.2.4/src/include/ntp-client/wizards.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/include/ntp-client/wizards.rb
2019-10-15 15:02:57.000000000 +0200
@@ -1,9 +1,7 @@
-# encoding: utf-8
-
-# File: include/ntp-client/wizards.ycp
-# Package: Configuration of ntp-client
-# Summary: Wizards definitions
-# Authors: Jiri Srain <[email protected]>
+# File: include/ntp-client/wizards.ycp
+# Package: Configuration of ntp-client
+# Summary: Wizards definitions
+# Authors: Jiri Srain <[email protected]>
#
# $Id$
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/src/lib/cfa/chrony_conf.rb
new/yast2-ntp-client-4.2.5/src/lib/cfa/chrony_conf.rb
--- old/yast2-ntp-client-4.2.4/src/lib/cfa/chrony_conf.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/lib/cfa/chrony_conf.rb 2019-10-15
15:02:57.000000000 +0200
@@ -39,14 +39,14 @@
options = default_pool_options if options == :default
# if there is already pool entry, place it after, if not, try use comment
existing_pools = pure_pools
- if existing_pools.empty?
+ matcher = if existing_pools.empty?
# for now first chrony have pools under comment mentioning pool.ntp.org
# so try to place it below
- matcher = Matcher.new { |k, v| k.start_with?("#comment") && v =~
/www\.pool\.ntp\.org/ }
+ Matcher.new { |k, v| k.start_with?("#comment") && v =~
/www\.pool\.ntp\.org/ }
else
# place after the last pool available
- matcher = Matcher.new(key: existing_pools.last[:key],
- value_matcher: existing_pools.last[:value])
+ Matcher.new(key: existing_pools.last[:key],
+ value_matcher: existing_pools.last[:value])
end
placer = AfterPlacer.new(matcher)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/client/auto.rb
new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/client/auto.rb
--- old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/client/auto.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/client/auto.rb
2019-10-15 15:02:57.000000000 +0200
@@ -1,5 +1,3 @@
-# encoding: utf-8
-
require "yast"
require "installation/auto_client"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/client/finish.rb
new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/client/finish.rb
--- old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/client/finish.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/client/finish.rb
2019-10-15 15:02:57.000000000 +0200
@@ -1,5 +1,3 @@
-# encoding: utf-8
-
require "yast"
require "installation/finish_client"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/dialog/add_pool.rb
new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/dialog/add_pool.rb
--- old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/dialog/add_pool.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/dialog/add_pool.rb
2019-10-15 15:02:57.000000000 +0200
@@ -51,6 +51,7 @@
def next_handler
return :cancel if @pool_chooser.value.to_s.empty?
+
@address = @pool_chooser.value
:next
@@ -77,7 +78,7 @@
end
def available_pools
- { local: Widgets::LocalList, public: Widgets::PublicList }
+ { local: Widgets::LocalList, public: Widgets::PublicList }
end
def pool_for(type)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/dialog/main.rb
new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/dialog/main.rb
--- old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/dialog/main.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/dialog/main.rb
2019-10-15 15:02:57.000000000 +0200
@@ -56,6 +56,7 @@
def abort_button
return Yast::Label.CancelButton unless installation?
+
nil
end
@@ -72,11 +73,13 @@
def back_button
return "" unless installation?
+
nil
end
def next_button
return Yast::Label.OKButton unless installation?
+
nil
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/widgets/main_widgets.rb
new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/widgets/main_widgets.rb
--- old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/widgets/main_widgets.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/widgets/main_widgets.rb
2019-10-15 15:02:57.000000000 +0200
@@ -26,10 +26,10 @@
def help
# TRANSLATORS: configuration source combo box help, %{manual} is a
# manual page reference, e.g. "man 8 netconfig"
- _("<p>The NTP configuration may be provided by the local network over
DHCP. " \
+ format(_("<p>The NTP configuration may be provided by the local
network over DHCP. " \
"<b>Configuration Source</b> can simply enable or disable using that
configuration. " \
"In cases where there may be multiple DHCP sources, it can
prioritize them: " \
- "see '%{manual}'.</p>") % { manual: "man 8 netconfig" }
+ "see '%{manual}'.</p>"), manual: "man 8 netconfig")
end
def opt
@@ -44,9 +44,7 @@
["auto", _("Dynamic")]
]
current_policy = Yast::NtpClient.ntp_policy
- if !["", "auto"].include?(current_policy)
- items << [current_policy, current_policy]
- end
+ items << [current_policy, current_policy] if !["",
"auto"].include?(current_policy)
items
end
@@ -114,7 +112,7 @@
end
def handle
- widget = value == "sync" ? SyncInterval.new :
CWM::Empty.new("empty_interval")
+ widget = (value == "sync") ? SyncInterval.new :
CWM::Empty.new("empty_interval")
@replace_point.replace(widget)
nil
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/widgets/pool_widgets.rb
new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/widgets/pool_widgets.rb
--- old/yast2-ntp-client-4.2.4/src/lib/y2ntp_client/widgets/pool_widgets.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/lib/y2ntp_client/widgets/pool_widgets.rb
2019-10-15 15:02:57.000000000 +0200
@@ -395,6 +395,7 @@
def ntp_servers
servers = Yast::NtpClient.GetNtpServers
return servers if @country.to_s.empty?
+
servers.find_all { |_s, v| v["country"] == @country }
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/src/modules/NtpClient.rb
new/yast2-ntp-client-4.2.5/src/modules/NtpClient.rb
--- old/yast2-ntp-client-4.2.4/src/modules/NtpClient.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/src/modules/NtpClient.rb 2019-10-15
15:02:57.000000000 +0200
@@ -1,9 +1,7 @@
-# encoding: utf-8
-
-# File: modules/NtpClient.ycp
-# Package: Configuration of ntp-client
-# Summary: Data for configuration of ntp-client, input and output
functions.
-# Authors: Jiri Srain <[email protected]>
+# File: modules/NtpClient.ycp
+# Package: Configuration of ntp-client
+# Summary: Data for configuration of ntp-client, input and output functions.
+# Authors: Jiri Srain <[email protected]>
#
# $Id$
#
@@ -14,6 +12,8 @@
require "cfa/chrony_conf"
require "yast2/target_file" # required to cfa work on changed scr
require "ui/text_helpers"
+require "erb"
+require "yast2/systemctl"
module Yast
class NtpClientClass < Module
@@ -21,7 +21,7 @@
include ::UI::TextHelpers
# the default synchronization interval in minutes when running in the
manual
- # sync mode ("Synchronize without Daemon" option, ntp started from cron)
+ # sync mode ("Synchronize without Daemon" option, ntp started from systemd
timer)
# Note: the UI field currently uses maximum of 60 minutes
DEFAULT_SYNC_INTERVAL = 5
@@ -35,8 +35,9 @@
NTP_FILE = "/etc/chrony.conf".freeze
- # The cron file name for the synchronization.
- CRON_FILE = "/etc/cron.d/suse-ntp_synchronize".freeze
+ TIMER_FILE = "yast-timesync.timer".freeze
+ # The file name of systemd timer for the synchronization.
+ TIMER_PATH = "/etc/systemd/system/#{TIMER_FILE}".freeze
UNSUPPORTED_AUTOYAST_OPTIONS = [
"configure_dhcp",
@@ -137,7 +138,7 @@
# CFA instance for reading/writing /etc/chrony.conf
def ntp_conf
- @chrony_conf ||= CFA::ChronyConf.new
+ @ntp_conf ||= CFA::ChronyConf.new
end
# Abort function
@@ -148,6 +149,7 @@
def go_next
return false if Abort()
+
Progress.NextStage if progress?
true
end
@@ -282,15 +284,14 @@
# synchronize_time and sync_interval variables
# Return updated value of synchronize_time
def ReadSynchronization
- crontab = SCR.Read(path(".cron"), CRON_FILE, "")
- log.info("NTP Synchronization crontab entry: #{crontab}")
- cron_entry = (crontab || []).fetch(0, {}).fetch("events", []).fetch(0,
{})
- @synchronize_time = cron_entry["active"] == "1"
+ return false unless ::File.exist?(TIMER_PATH)
- sync_interval_entry = cron_entry.fetch("minute",
"*/#{DEFAULT_SYNC_INTERVAL}")
- log.info("MINUTE #{sync_interval_entry}")
+ timer_content = ::File.read(TIMER_PATH)
+ log.info("NTP Synchronization timer entry: #{timer_content}")
+ @synchronize_time = Yast2::Systemctl.execute("is-active
#{TIMER_FILE}").exit.zero?
- @sync_interval = sync_interval_entry.tr("^[0-9]", "").to_i
+ interval = timer_content[/^\s*OnUnitActiveSec\s*=\s*(\d+)m/, 1]
+ @sync_interval = interval.to_i if interval
log.info("SYNC_INTERVAL #{@sync_interval}")
@synchronize_time
@@ -332,9 +333,11 @@
ReadSynchronization()
return false if !go_next
+
Progress.Title(_("Finished")) if progress?
return false if Abort()
+
@modified = false
true
end
@@ -364,7 +367,7 @@
check_service
- update_cron_settings
+ update_timer_settings
return false if !go_next
@@ -838,19 +841,34 @@
end
end
- # If synchronize time has been enable it writes ntp cron entry for manual
- # sync. If not it removes current cron entry if exists.
- def update_cron_settings
+ def timer_content
+ erb_template = ::File.read(Directory.find_data_file("#{TIMER_FILE}.erb"))
+ content = ERB.new(erb_template)
+ timeout = @sync_interval
+ content.result(binding)
+ end
+
+ # If synchronize time has been enable it writes systemd timer entry for
manual
+ # sync. If not it removes current systemd timer entry if exists.
+ def update_timer_settings
if @synchronize_time
SCR.Write(
path(".target.string"),
- CRON_FILE,
- "-*/#{@sync_interval} * * * * root /usr/sbin/chronyd -q
&>/dev/null\n"
+ TIMER_PATH,
+ timer_content
)
+ res = Yast2::Systemctl.execute("enable #{TIMER_FILE}")
+ log.info "enable timer: #{res.inspect}"
+ res = Yast2::Systemctl.execute("start #{TIMER_FILE}")
+ log.info "start timer: #{res.inspect}"
else
+ res = Yast2::Systemctl.execute("disable #{TIMER_FILE}")
+ log.info "disable timer: #{res.inspect}"
+ res = Yast2::Systemctl.execute("stop #{TIMER_FILE}")
+ log.info "stop timer: #{res.inspect}"
SCR.Execute(
path(".target.bash"),
- "rm -vf #{CRON_FILE}"
+ "rm -vf #{TIMER_PATH}"
)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/src/systemd/yast-timesync.service
new/yast2-ntp-client-4.2.5/src/systemd/yast-timesync.service
--- old/yast2-ntp-client-4.2.4/src/systemd/yast-timesync.service
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-ntp-client-4.2.5/src/systemd/yast-timesync.service
2019-10-15 15:02:57.000000000 +0200
@@ -0,0 +1,13 @@
+[Unit]
+Description=One time sync configured by YaST
+DefaultDependencies=no
+# one time sync cannot be done if chrony server runs
+Conflicts=chronyd.service
+RefuseManualStart=false
+
+[Service]
+Type=oneshot
+StandardError=tty
+StandardOutput=tty
+RemainAfterExit=no
+ExecStart=/usr/bin/systemd-cat -t yast-timesync -- /usr/sbin/chronyd -q
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/test/cfa/chrony_conf_test.rb
new/yast2-ntp-client-4.2.5/test/cfa/chrony_conf_test.rb
--- old/yast2-ntp-client-4.2.4/test/cfa/chrony_conf_test.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/test/cfa/chrony_conf_test.rb 2019-10-15
15:02:57.000000000 +0200
@@ -3,7 +3,7 @@
require "cfa/chrony_conf"
def ntp_disk_content
- path = File.expand_path("../../fixtures/cfa/chrony.conf.original", __FILE__)
+ path = File.expand_path("../fixtures/cfa/chrony.conf.original", __dir__)
File.read(path)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/test/ntp_client_test.rb
new/yast2-ntp-client-4.2.5/test/ntp_client_test.rb
--- old/yast2-ntp-client-4.2.4/test/ntp_client_test.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/test/ntp_client_test.rb 2019-10-15
15:02:57.000000000 +0200
@@ -111,7 +111,7 @@
describe "#Export" do
let(:profile_name) { "autoinst.xml" }
let(:ntp_conf) do
- path = File.expand_path("../fixtures/cfa/chrony.conf", __FILE__)
+ path = File.expand_path("fixtures/cfa/chrony.conf", __dir__)
text = File.read(path)
file = CFA::MemoryFile.new(text)
CFA::ChronyConf.new(file_handler: file)
@@ -338,8 +338,8 @@
end
end
- it "updates cron settings" do
- expect(subject).to receive(:update_cron_settings)
+ it "updates systemd timer settings" do
+ expect(subject).to receive(:update_timer_settings)
subject.Write
end
@@ -437,23 +437,27 @@
end
describe "#ReadSynchronization" do
- let(:cron_job_file) { "/etc/cron.d/suse-ntp_synchronize" }
- let(:cron_entry) { [] }
+ let(:systemd_timer_file) { "/etc/systemd/system/yast-timesync.timer" }
+ let(:timer_content) { "" }
before do
- allow(Yast::SCR).to receive(:Read)
- .with(Yast::Path.new(".cron"), cron_job_file,
"").and_return(cron_entry)
+ allow(::File).to receive(:exist?).and_call_original
+ allow(::File).to
receive(:exist?).with("/etc/systemd/system/yast-timesync.timer")
+ .and_return(true)
+ allow(::File).to receive(:read).and_return(timer_content)
end
- it "reads cron file" do
- expect(Yast::SCR).to receive(:Read)
- .with(Yast::Path.new(".cron"), cron_job_file, "")
+ it "reads systemd timer" do
+ expect(::File).to receive(:read).and_return(timer_content)
subject.ReadSynchronization
end
- context "when cron file does not exist" do
- let(:cron_entry) { nil }
+ context "when systemd timer file does not exist" do
+ before do
+ allow(::File).to
receive(:exist?).with("/etc/systemd/system/yast-timesync.timer")
+ .and_return(true)
+ end
it "sets synchronize_time as false" do
subject.ReadSynchronization
@@ -468,29 +472,40 @@
end
end
- context "when cron file exists" do
- context "when there is no cron entry" do
+ context "when systemd timer file exists" do
+ let(:timer_content) do
+ subject.sync_interval = 10
+ subject.send(:timer_content)
+ end
+
+ context "when timer is not active" do
+ before do
+ allow(Yast::SCR).to receive(:Execute).and_return("exit" => 3)
+ end
+
it "sets synchronize_time as false" do
subject.ReadSynchronization
expect(subject.synchronize_time).to eql(false)
end
- it "sets sync interval with default value" do
+ it "sets sync interval with value from timer" do
subject.ReadSynchronization
- expect(subject.sync_interval).to
eql(Yast::NtpClientClass::DEFAULT_SYNC_INTERVAL)
+ expect(subject.sync_interval).to eql(10)
end
end
- context "when there is cron entry" do
- let(:cron_entry) { [{ "events" => [{ "active" => "1", "minute" =>
"*/10" }] }] }
+ context "when timer is active" do
+ before do
+ allow(Yast::SCR).to receive(:Execute).and_return("exit" => 0)
+ end
- it "sets synchronize time as true if first cron entry is valid" do
+ it "sets synchronize time as true" do
expect(subject.ReadSynchronization).to eql(true)
end
- it "sets sync_interval with cron minute interval" do
+ it "sets sync_interval with value from timer" do
subject.ReadSynchronization
expect(subject.sync_interval).to eql(10)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/yast2-ntp-client-4.2.4/test/test_helper.rb
new/yast2-ntp-client-4.2.5/test/test_helper.rb
--- old/yast2-ntp-client-4.2.4/test/test_helper.rb 2019-10-02
14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/test/test_helper.rb 2019-10-15
15:02:57.000000000 +0200
@@ -1,4 +1,5 @@
-ENV["Y2DIR"] = File.expand_path("../../src", __FILE__)
+ENV["Y2DIR"] = File.expand_path("../src", __dir__)
+ENV["LC_ALL"] = "en_US.utf8"
require "yast"
require "yast/rspec"
@@ -11,20 +12,21 @@
#
https://relishapp.com/rspec/rspec-mocks/v/3-0/docs/verifying-doubles/partial-doubles
#
# With graceful degradation for RSpec 2
- if mocks.respond_to?(:verify_partial_doubles=)
- mocks.verify_partial_doubles = true
- end
+ mocks.verify_partial_doubles = true if
mocks.respond_to?(:verify_partial_doubles=)
end
end
# stub module to prevent its Import
# Useful for modules from different yast packages, to avoid build dependencies
def stub_module(name)
- Yast.const_set name.to_sym, Class.new { def self.fake_method; end }
+ Yast.const_set(name.to_sym, Class.new { def self.fake_method; end })
end
# stub classes from other modules to speed up a build
stub_module("Lan")
+stub_module("Language")
+stub_module("Pkg")
+stub_module("PackageCallbacks")
if ENV["COVERAGE"]
require "simplecov"
@@ -32,7 +34,7 @@
add_filter "/test/"
end
- src_location = File.expand_path("../../src", __FILE__)
+ src_location = File.expand_path("../src", __dir__)
# track all ruby files under src
SimpleCov.track_files("#{src_location}/**/*.rb")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-ntp-client-4.2.4/test/y2ntp_client/widgets/main_widgets_test.rb
new/yast2-ntp-client-4.2.5/test/y2ntp_client/widgets/main_widgets_test.rb
--- old/yast2-ntp-client-4.2.4/test/y2ntp_client/widgets/main_widgets_test.rb
2019-10-02 14:34:59.000000000 +0200
+++ new/yast2-ntp-client-4.2.5/test/y2ntp_client/widgets/main_widgets_test.rb
2019-10-15 15:02:57.000000000 +0200
@@ -23,7 +23,7 @@
.and_return(double(
pools: { "ntp.org" => {}, "us.ntp.org" => {} },
modify_pool: nil
- ))
+ ))
allow(subject).to receive(:value).and_return("ntp.org")
allow(subject).to receive(:value=)
allow(Y2NtpClient::Dialog::Pool).to receive(:new)
@@ -39,7 +39,7 @@
.and_return(double(
default_pool_options: {},
add_pool: nil
- ))
+ ))
allow(Y2NtpClient::Dialog::Pool).to receive(:new)
.and_return(double(run: :next, resulting_pool: ["de.ntp.org", {}]))
end