Browse Source

chrony-3.5-2

git-svn-id: http://trac.vinelinux.org/repos/projects/specs@12389 ec354946-7b23-47d6-9f5a-488ba84defc7
tomop 2 years ago
parent
commit
a6b3bd7717
1 changed files with 80 additions and 19 deletions
  1. 80 19
      c/chrony/chrony-vl.spec

+ 80 - 19
c/chrony/chrony-vl.spec

@@ -1,6 +1,8 @@
+%bcond_with systemd
+
 Name:           chrony
 Version:        3.5
-Release:        1%{?_dist_release}
+Release:        2%{?_dist_release}%{?with_systemd:.systemd}
 Summary:        An NTP client/server
 Group:          System Environment/Daemons
 Vendor:         Project Vine
@@ -15,15 +17,25 @@ Source2:        chrony.dhclient
 Source3:        chronyd.sysconfig
 Source4:        chronyd.init
 Source5:        chrony.logrotate
+Source6:        chrony.helper
+Source7:        chrony-dnssrv@.service
+Source8:        chrony-dnssrv@.timer
+
+# add NTP servers from DHCP when starting service
+Patch2:         chrony-service-helper.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  libcap-devel readline-devel ncurses-devel bison
 
 Requires(pre):  shadow-utils
+%if %{with systemd}
+%{?systemd_requires}
+%else
 Requires(post): chkconfig
 Requires(preun): chkconfig initscripts
 Requires(postun): initscripts
+%endif
 
 %if "%{?_dist_release}" == "vl7"
 Obsoletes:      ntp < 4.2.6p5
@@ -40,6 +52,7 @@ clocks, system real-time clock or manual input as time references.
 
 %prep
 %setup -q -n %{name}-%{version}%{?prerelease}
+%patch2 -p1 -b .service-helper
 
 echo '# Keys used by chronyd for command and NTP authentication' > chrony.keys
 
@@ -60,37 +73,56 @@ rm -f getdate.c
 	--docdir=%{_docdir} \
 	--with-user=chrony \
 	--with-sendmail=%{_sbindir}/sendmail \
+%if %{with systemd}
+	--chronyrundir=/run/chrony \
+	--with-pidfile=/run/chrony/chronyd.pid \
+%endif
 	--enable-forcednsretry
 make %{?_smp_mflags} all docs
 
 %install
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
 
-make install install-docs DESTDIR=$RPM_BUILD_ROOT
+make install install-docs DESTDIR=%{buildroot}
 
-rm -rf $RPM_BUILD_ROOT%{_docdir}
+rm -rf %{buildroot}%{_docdir}
 
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{sysconfig,logrotate.d}
-mkdir -p $RPM_BUILD_ROOT%{_initrddir}
-mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/{lib,log}/chrony
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/dhcp/dhclient.d
+mkdir -p %{buildroot}%{_sysconfdir}/{sysconfig,logrotate.d}
+mkdir -p %{buildroot}%{_initrddir}
+mkdir -p %{buildroot}%{_localstatedir}/{lib,log}/chrony
+mkdir -p %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d
+mkdir -p %{buildroot}%{_sysconfdir}/dhcp/dhclient.d
 
-install -m 644 -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/chrony.conf
-install -m 640 -p chrony.keys $RPM_BUILD_ROOT%{_sysconfdir}/chrony.keys
+install -m 644 -p %{SOURCE1} %{buildroot}%{_sysconfdir}/chrony.conf
+install -m 640 -p chrony.keys %{buildroot}%{_sysconfdir}/chrony.keys
 install -m 755 -p examples/chrony.nm-dispatcher \
-	$RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony
+	%{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony
 install -m 755 -p %{SOURCE2} \
-	$RPM_BUILD_ROOT%{_sysconfdir}/dhcp/dhclient.d/chrony.sh
-
-install -m 644 -p %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/chronyd
-install -m 755 -p %{SOURCE4} $RPM_BUILD_ROOT%{_initrddir}/chronyd
-install -m 644 -p %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/chrony
+	%{buildroot}%{_sysconfdir}/dhcp/dhclient.d/chrony.sh
+
+install -m 644 -p %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/chronyd
+install -m 644 -p %{SOURCE5} %{buildroot}%{_sysconfdir}/logrotate.d/chrony
+
+%if %{with systemd}
+mkdir -p %{buildroot}{%{_unitdir},/lib/systemd/ntp-units.d}
+install -m 644 -p examples/chronyd.service \
+	%{buildroot}%{_unitdir}/chronyd.service
+install -m 644 -p examples/chrony-wait.service \
+	%{buildroot}%{_unitdir}/chrony-wait.service
+install -m 644 -p %{SOURCE7} %{buildroot}%{_unitdir}/chrony-dnssrv@.service
+install -m 644 -p %{SOURCE8} %{buildroot}%{_unitdir}/chrony-dnssrv@.timer
+mkdir -p %{buildroot}%{_libexecdir}
+install -m 755 -p %{SOURCE6} %{buildroot}%{_libexecdir}/chrony-helper
+echo 'chronyd.service' > \
+        %{buildroot}/lib/systemd/ntp-units.d/50-chronyd.list
+%else
+install -m 755 -p %{SOURCE4} %{buildroot}%{_initrddir}/chronyd
+%endif
 
-touch $RPM_BUILD_ROOT%{_localstatedir}/lib/chrony/{drift,rtc}
+touch %{buildroot}%{_localstatedir}/lib/chrony/{drift,rtc}
 
 %clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
 
 %pre
 getent group chrony > /dev/null || /usr/sbin/groupadd -r chrony
@@ -99,21 +131,35 @@ getent passwd chrony > /dev/null || /usr/sbin/useradd -r -g chrony \
 :
 
 %post
+%if %{with systemd}
+# workaround for late reload of unit file (#1614751)
+%{_bindir}/systemctl daemon-reload
+%systemd_post chronyd.service chrony-wait.service
+%else
 /sbin/chkconfig --add chronyd
 :
+%endif
 
 %preun
+%if %{with systemd}
+%systemd_preun chronyd.service chrony-wait.service
+%else
 if [ "$1" -eq 0 ]; then
         /sbin/service chronyd stop &> /dev/null
         /sbin/chkconfig --del chronyd
 fi
 :
+%endif
 
 %postun
+%if %{with systemd}
+%systemd_postun_with_restart chronyd.service
+%else
 if [ "$1" -ge 1 ]; then
         /sbin/service chronyd condrestart &> /dev/null
 fi
 :
+%endif
 
 %files
 %defattr(-,root,root,-)
@@ -123,8 +169,19 @@ fi
 %config(noreplace) %verify(not md5 size mtime) %attr(640,root,chrony) %{_sysconfdir}/chrony.keys
 %config(noreplace) %{_sysconfdir}/sysconfig/chronyd
 %config(noreplace) %{_sysconfdir}/logrotate.d/chrony
+%if %{with systemd}
+%{_libexecdir}/chrony-helper
+/lib/systemd/ntp-units.d/*.list
+%{_unitdir}/chrony*.service
+%{_unitdir}/chrony*.timer
+%else
 %{_initrddir}/chronyd
+%endif
+%dir %{_sysconfdir}/NetworkManager
+%dir %{_sysconfdir}/NetworkManager/dispatcher.d
 %{_sysconfdir}/NetworkManager/dispatcher.d/20-chrony
+%dir %{_sysconfdir}/dhcp
+%dir %{_sysconfdir}/dhcp/dhclient.d
 %{_sysconfdir}/dhcp/dhclient.d/chrony.sh
 %{_bindir}/chronyc
 %{_sbindir}/chronyd
@@ -135,6 +192,10 @@ fi
 %dir %attr(-,chrony,chrony) %{_localstatedir}/log/chrony
 
 %changelog
+* Mon Apr 06 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.5-2
+- added systemd stuff (disabled as default).
+- updated Source2.
+
 * Wed Mar 25 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.5-1
 - new upstream release.
 - dropped Patch102: fixed in upstream.