File chrony.spec of Package chrony.19115

# spec file for package chrony
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%global clknetsim_ver 71dbbc5
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir %{_localstatedir}/adm/fillup-templates
Name:           chrony
Version:        3.2
Release:        0
Summary:        System Clock Synchronization Client and Server
License:        GPL-2.0-only
Group:          Productivity/Networking/Other
Source2:        chrony.sysconfig
Source3:        chrony.dhclient
Source4:        chrony.helper
Source5:        chrony-dnssrv@.service
Source6:        chrony-dnssrv@.timer
Source7:        pool.conf.suse
Source8:        pool.conf.opensuse
# Simulator for test suite
Patch0:         chrony-config.patch
# Add NTP servers from DHCP when starting service
Patch1:         chrony-service-helper.patch
Patch2:         chrony-logrotate.patch
Patch5:         chrony-fix-open.patch
Patch6:         chrony-service-ordering.patch
Patch7:         chrony-ntp-era-split.patch
Patch8:         chrony-select-timeout.patch
Patch9:         chrony-gettimeofday.patch
Patch10:        chrony-urandom.patch
Patch11:        chrony-pidfile.patch
Patch12:        clknetsim-glibc-2.31.patch
BuildRequires:  NetworkManager-devel
BuildRequires:  bison
BuildRequires:  gcc-c++
BuildRequires:  libcap-devel
BuildRequires:  libedit-devel
BuildRequires:  mozilla-nss-devel
BuildRequires:  pkgconfig
BuildRequires:  pps-tools-devel
# The timezone package is needed for the "make check" tests. It can be
# removed if the call to make check is ever deleted.
BuildRequires:  timezone
BuildRequires:  pkgconfig(systemd)
Requires:       logrotate
Requires(post): %fillup_prereq
Requires(pre):  %{_sbindir}/groupadd
Requires(pre):  %{_sbindir}/useradd
Requires:       %name-pool
Recommends:     %name-pool-nonempty
Provides:       ntp-daemon
%ifarch s390 s390x ppc64le
BuildRequires:  libseccomp-devel >= 2.2.0
BuildRequires:  libseccomp-devel

Chrony is an implementation of the Network Time Protocol (NTP). It can
synchronize the system clock with NTP servers, reference clocks (e.g. a
GPS receiver), and manual input using wristwatch and keyboard. It can
also operate as an NTPv4 (RFC 5905) server and peer to provide a time
service to other computers in the network.

Chrony consists of two programs: chronyd and chronyc.

Chronyd is a daemon which runs in the background on the system. It
obtains measurements of the system clock’s offset relative to time
servers on other systems via the network and adjusts the system time
accordingly. For isolated systems, the user can periodically enter the
correct time by hand (using chronyc). In either case, chronyd
determines the rate at which the computer gains or loses time, and
compensates for this. Chronyd can act as either a client or a server.

Chronyc provides a user interface to chronyd for monitoring its
performance and configuring various settings. It can do so while
running on the same computer as the chronyd instance it is controlling
or a different computer.

%package pool-suse
Summary:        Chrony preconfiguration for SUSE
Group:          Productivity/Networking/Other
Provides:       %name-pool = %version
Provides:       %name-pool-nonempty
Conflicts:      otherproviders(%name-pool)
Requires:       %name = %version
BuildArch:      noarch
RemovePathPostfixes: .suse

%description pool-suse
This package configures chrony to use the SUSE NTP server pool by

%package pool-openSUSE
Summary:        Chrony preconfiguration for openSUSE
Group:          Productivity/Networking/Other
Provides:       %name-pool = %version
Provides:       %name-pool-nonempty
Conflicts:      otherproviders(%name-pool)
Requires:       %name = %version
BuildArch:      noarch
RemovePathPostfixes: .opensuse

%description pool-openSUSE
This package configures chrony to use the openSUSE NTP server pool by

%package pool-empty
Summary:        Empty pool preconfiguration for chrony
Group:          Productivity/Networking/Other
Provides:       %name-pool = %version
Conflicts:      otherproviders(%name-pool)
Requires:       %name = %version
BuildArch:      noarch
RemovePathPostfixes: .empty

%description pool-empty
This package provides an empty /etc/chrony.d/pool.conf file for
situations when having servers preconfigured in chrony is undesirable,
e.g. because the servers will be set via DHCP.

%setup -q -a 10
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch5 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
pushd clknetsim-*

# Remove pool statements from the default /etc/chrony.conf. They will
# be provided by branding packages in /etc/chrony.d/pool.conf .

sed -e 's|^\pool|! pool|' \
        < examples/chrony.conf.example2 > chrony.conf

cat << EOF >> chrony.conf

# Also include any directives found in configuration files in /etc/chrony.d
include /etc/chrony.d/*.conf

touch -r examples/chrony.conf.example2 chrony.conf

# regenerate the file from getdate.y
rm -f getdate.c

mv clknetsim-%{clknetsim_ver}* test/simulation/clknetsim

# not autoconf:
export CFLAGS="%{optflags} -Wall -fpic -DPIC $(pkg-config --cflags libseccomp)"
export LDFLAGS="-pie -Wl,-z,relro,-z,now"
%configure                                  \
  --docdir="%{_docdir}/%{name}"             \
  %if %{with syscallfilter}
  --enable-scfilter                         \
  --with-user=chrony                        \
  --with-hwclockfile=%{_sysconfdir}/adjtime \
make %{?_smp_mflags} all docs

install -Dpm 0644 chrony.conf \
mkdir %{buildroot}%{_sysconfdir}/chrony.d
install -Dpm 0640 examples/chrony.keys.example \
install -Dpm 0755 examples/chrony.nm-dispatcher \
install -Dpm 0755 %{SOURCE3} \
install -Dpm 0644 examples/chrony.logrotate \
install -Dpm 0644 examples/chronyd.service \
install -Dpm 0644 examples/chrony-wait.service \
install -Dpm 0644 %{SOURCE5} \
install -Dpm 0644 %{SOURCE6} \

install -d %{buildroot}%{sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcchronyd
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcchrony-wait

install -d %{buildroot}%{_prefix}/lib/systemd/ntp-units.d
echo 'chronyd.service' > \

install -Dpm 0644 %{SOURCE2} \
install -Dpm 755 %{SOURCE4} \

install -d %{buildroot}%{_localstatedir}/log/chrony
touch %{buildroot}%{_localstatedir}/lib/chrony/{drift,rtc}

# Install the NTP pool files
install -Dpm 644 %{SOURCE7} %{SOURCE8} %{buildroot}/etc/chrony.d
touch %{buildroot}/etc/chrony.d/pool.conf.empty

# Set random seed to get deterministic results
make %{?_smp_mflags} -C test/simulation/clknetsim
make %{?_smp_mflags} check

getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || useradd -r -g %{name} -d "%{_localstatedir}/lib/chrony" -s /bin/false -c "Chrony Daemon" %{name}
%service_add_pre chronyd.service chrony-wait.service

%service_del_preun chronyd.service chrony-wait.service

%fillup_only -n chronyd
%service_add_post chronyd.service chrony-wait.service

%service_del_postun chronyd.service chrony-wait.service

%license COPYING
%doc examples
%config(noreplace) %attr(0640,root,%{name}) %{_sysconfdir}/chrony.conf
%config(noreplace) %attr(0640,root,%{name}) %verify(not md5 size mtime) %{_sysconfdir}/chrony.keys
%config(noreplace) %{_sysconfdir}/logrotate.d/chrony
%dir %{_sysconfdir}/chrony.d/
%dir %{_sysconfdir}/dhcp/
%dir %{_sysconfdir}/dhcp/dhclient.d/
%dir %attr(750,chrony,chrony) %{_localstatedir}/lib/chrony
%ghost %attr(640,chrony,chrony) %{_localstatedir}/lib/chrony/drift
%ghost %attr(640,chrony,chrony) %{_localstatedir}/lib/chrony/rtc
%dir %attr(750,chrony,chrony) %{_localstatedir}/log/chrony

%files pool-empty
%config (noreplace) /etc/chrony.d/pool.conf.empty

%files pool-suse
%config (noreplace) /etc/chrony.d/pool.conf.suse

%files pool-openSUSE
%config (noreplace) /etc/chrony.d/pool.conf.opensuse

openSUSE Build Service is sponsored by