LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File ntp.spec of Package ntp (Project network:time)

# spec file for package ntp
# Copyright (c) 2015 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 http://bugs.opensuse.org/

%define ntpfaqversion 3.4
%if %{undefined _ntpunitsdir}
%global _ntpunitsdir %{_libexecdir}/systemd/ntp-units.d
Name:           ntp
Version:        4.2.8p3
Release:        0
Summary:        Network Time Protocol daemon (version 4)
License:        (MIT and BSD-3-Clause and BSD-4-Clause) and GPL-2.0
Group:          Productivity/Networking/Other
Url:            http://www.ntp.org/
# main source
Source0:        http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-%{version}.tar.gz
# configuration
Source1:        conf.logrotate.ntp
Source2:        conf.ntp.conf
Source3:        conf.ntpd.service
Source4:        conf.sysconfig.ntp
Source5:        conf.sysconfig.syslog-ntp
Source6:        conf.ntp.reg
Source7:        %{name}.firewall
Source8:        conf.start-ntpd
Source9:        conf.ntp-wait.service
# documentation
Source10:       NTP-FAQ-%{ntpfaqversion}.tar.bz2
Source11:       ntp.1.gz
Source12:       README.SUSE
Source13:       ntp-4.2.7-rh-manpages.tar.gz
Source14:       ntp.xml
Source16:       ntp.NetworkManager
Patch1:         ntp-segfault_on_invalid_device.patch
Patch10:        ntp-strcat.patch
Patch11:        ntp-4.2.6p2-seed_file.patch
Patch15:        bnc#506908.diff
Patch16:        MOD_NANO.diff
Patch18:        bnc#574885.diff
Patch19:        ntp-4.2.6p2-ntpq-speedup-782060.patch
BuildRequires:  autoconf
BuildRequires:  avahi-compat-mDNSResponder-devel
BuildRequires:  fdupes
BuildRequires:  libcap-devel
BuildRequires:  libtool
BuildRequires:  openssl-devel
BuildRequires:  readline-devel
BuildRequires:  pkgconfig(systemd)
Requires:       /bin/logger
Requires:       timezone
Requires(pre):  %fillup_prereq
Requires(pre):  %{_bindir}/chkconfig
Requires(pre):  %{_bindir}/diff
Requires(pre):  %{_bindir}/grep
Requires(pre):  pwdutils
Suggests:       logrotate
Provides:       ntp-daemon
Provides:       xntp = %{version}
Provides:       xntp3 = %{version}
Obsoletes:      xntp < %{version}
Obsoletes:      xntp3 < %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Conflicts:      openntpd

The Network Time Protocol (NTP) is used to synchronize the time of a
computer client or server to another server or reference time source,
such as a radio, satellite receiver, or modem.

Ntpd is an operating system daemon that sets and maintains the system
time-of-day synchronized with Internet standard time servers.

%package doc
Summary:        Additional Package Documentation for ntp
Group:          Documentation/Other
Provides:       ntpdoc = %{version}
Provides:       xntp-doc = %{version}
Provides:       xntpdoc = %{version}
Obsoletes:      ntpdoc < %{version}
Obsoletes:      xntp-doc < %{version}
Obsoletes:      xntpdoc < %{version}

%description doc
The complete set of documentation for building and configuring an NTP
server or client. The documentation is in the form of HTML files
suitable for browsing and contains links to additional documentation at
various web sites.

What about NTP? Understanding and using the Network Time Protocol (A
first try on a non-technical Mini-HOWTO and FAQ on NTP). Edited by
Ulrich Windl and David Dalton.

%setup -q -n ntp-%{version}
# unpack ntp-faq
tar -x -C html -j -f %{SOURCE10}
cp %{SOURCE12} .
tar xzf %{SOURCE13}
%patch10 -p1

# fix DOS line breaks
sed -i 's/\r//g' html/scripts/{footer.txt,style.css}
# new automake 1.13 has removed old macro
sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/' configure.ac

autoreconf -fvi
export RPM_OPT_FLAGS="$RPM_OPT_FLAGS -W -DOPENSSL_LOAD_CONF -Wall -Wstrict-prototypes -Wpointer-arith -Wno-unused-parameter -fno-strict-aliasing -fstack-protector"
%ifarch alpha s390x
%ifarch ia64
CFLAGS="$RPM_OPT_FLAGS -fPIE" LDFLAGS="-pie" ./configure \
	--with-binsubdir=bin \
	--bindir=%{_sbindir} \
	--mandir=%{_mandir} \
	--infodir=%{_infodir} \
    --datadir=%{_datadir} \
    --htmldir=%{_docdir}/ntp-doc \
	--enable-parse-clocks \
	--enable-all-clocks \
	--enable-linuxcaps \
	--enable-ipv6 \
	--with-sntp \
	--enable-ntp-signd \
	--disable-listen-read-drop \
	--with-lineeditlibs=readline \
	--with-crypto=openssl \
	--with-openssl-libdir=%{_libdir} \

make %{?_smp_mflags}

make DESTDIR=%{buildroot} install %{?_smp_mflags}
# Change permissions
chmod 644 html/pic/neoclock4x.gif
%fdupes -s html
# default configuration
install -d %{buildroot}%{_localstatedir}/lib/ntp/{drift,etc,var/{lib,run/ntp},dev}
install -d %{buildroot}%{_localstatedir}/run
ln -s ../.. %{buildroot}%{_localstatedir}/lib/ntp%{_localstatedir}/lib/ntp
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcntpd
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcntp-wait
install -m 644 -D %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/ntp
install -m 600 -D %{SOURCE2} %{buildroot}%{_sysconfdir}/ntp.conf
install -m 600 -D %{SOURCE2} %{buildroot}%{_localstatedir}/lib/ntp%{_sysconfdir}/ntp.conf.iburst
# boot scripts
install -m 0644 -D %{SOURCE3} %{buildroot}/%{_unitdir}/ntpd.service
install -m 0644 -D %{SOURCE9} %{buildroot}/%{_unitdir}/ntp-wait.service
install -d %{buildroot}%{_prefix}/sbin
install -m 755 -D %{SOURCE8} %{buildroot}%{_sbindir}/start-ntpd
%__install -d %{buildroot}/usr/lib/initscripts/legacy-actions/ntpd
for f in ntptimeset addserver; do
	cat >$F <<-EOF
		exec /usr/sbin/start-ntpd $f
	chmod 755 $F
# fillup sysconfig.ntp
install -m 644 -D %{SOURCE4} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.ntp
install -m 644 -D %{SOURCE5} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.syslog-ntp
# install SLP reg file
install -m 644 -D %{SOURCE6} %{buildroot}%{_sysconfdir}/slp.reg.d/ntp.reg
# Install NetworkManager hook
install -m 755 -D %{SOURCE16} %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d/ntp
# man pages
install -d %{buildroot}/%{_mandir}/{man5,man8}
install -m 644 man/man5/* %{buildroot}/%{_mandir}/man5
install -m 644 man/man8/* %{buildroot}/%{_mandir}/man8
# firewall
install -d %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/
install -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/%{name}
# Logfile
install -d %{buildroot}%{_localstatedir}/log/
touch %{buildroot}%{_localstatedir}/log/ntp
# service xml
install -d %{buildroot}%{_datadir}/omc/svcinfo.d/
install -m 644 %{SOURCE14} %{buildroot}%{_datadir}/omc/svcinfo.d/
install -m 755 scripts/ntp-wait/ntp-wait %{buildroot}%{_sbindir}/

%if %{defined _ntpunitsdir}
install -d %{buildroot}%{_ntpunitsdir}
echo ntpd.service > %{buildroot}%{_ntpunitsdir}/50-ntp.list

%{_sbindir}/groupadd -r ntp 2> /dev/null || :
%{_sbindir}/useradd -r -o -g ntp -u 74 -s /bin/false -c "NTP daemon" -d %{_localstatedir}/lib/ntp ntp 2> /dev/null || :
%{_sbindir}/usermod -g ntp ntp 2>/dev/null || :
test -L %{_localstatedir}/run/ntp  || rm -rf %{_localstatedir}/run/ntp && :
%service_add_pre ntp.service ntpd.service
%service_add_pre ntp-wait.service
if [ $FIRST_ARG -ne 1 -a ! -e "%{_localstatedir}/lib/systemd/migrated/ntpd" -a -e %{_localstatedir}/lib/systemd/sysv-convert/database ]; then
  sed -i -e 's,ntp\t,ntpd\t,g' %{_localstatedir}/lib/systemd/sysv-convert/database

%service_del_preun ntpd.service
%service_del_preun ntp-wait.service

# no update? Then remove these files that aren't owned by the package
if [ ${FIRST_ARG:-0} -eq 0 ]; then
     test -e %{_localstatedir}/lib/ntp/drift/ntp.drift  && rm -f %{_localstatedir}/lib/ntp/drift/ntp.drift
     rm -f %{_localstatedir}/lib/ntp%{_sysconfdir}/* 2>/dev/null
     test -e %{_localstatedir}/log/ntp  && rm -f %{_localstatedir}/log/ntp

# Create ntp.keys file
if [ ! -f %{_sysconfdir}/ntp.keys ]; then
  tmp=$(dd if=/dev/urandom count=1 2>/dev/null | md5sum)
  tmp=${tmp:0:7} > %{_sysconfdir}/ntp.keys
  echo "1 M $tmp" > %{_sysconfdir}/ntp.keys
  chown root:ntp %{_sysconfdir}/ntp.keys
  chmod 0640 %{_sysconfdir}/ntp.keys
# Are we in update mode?
if [ -f %{_sysconfdir}/sysconfig/ntp ]; then
	grep -q '^keys %{_sysconfdir}/ntp.keys' %{_sysconfdir}/ntp.conf || {
        echo "#
# Authentication stuff
keys %{_sysconfdir}/ntp.keys              # path for keys file
trustedkey 1                    # define trusted keys
requestkey 1                    # key (7) for accessing server variables
# controlkey 15                 # key (6) for accessing server variables
" >> %{_sysconfdir}/ntp.conf
# update from previous permissions
if [ -f %{_sysconfdir}/ntp.conf ]; then
  chown root:ntp %{_sysconfdir}/ntp.conf
if [ -f %{_sysconfdir}/ntp.keys ]; then
  chown root:ntp %{_sysconfdir}/ntp.keys
if [ -f %{_localstatedir}/lib/ntp%{_sysconfdir}/ntp.conf.iburst ]; then
  chown --from=ntp:root root:ntp %{_localstatedir}/lib/ntp%{_sysconfdir}/ntp.conf.iburst
%{fillup_only -n ntp }
%{fillup_only -n syslog }
if [ ! -f %{_localstatedir}/log/ntp ]; then
	touch %{_localstatedir}/log/ntp
	chmod 644 %{_localstatedir}/log/ntp
%service_add_post ntpd.service
%service_add_post ntp-wait.service
if [ ! -e "%{_localstatedir}/lib/systemd/migrated/ntpd" ]; then
  touch %{_localstatedir}/lib/systemd/migrated/ntpd

%service_del_postun ntpd.service
%service_del_postun ntp-wait.service

%attr(0640,root,ntp) %config(noreplace) %{_sysconfdir}/ntp.conf
%dir %{_sysconfdir}/slp.reg.d
%if %{defined _ntpunitsdir}
%config(noreplace) %{_sysconfdir}/slp.reg.d/ntp.reg
%config %{_sysconfdir}/logrotate.d/ntp
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/ntp
# own /etc/NetworkManager so we don't have to BuildDepend on NM
%dir %{_sysconfdir}/NetworkManager
%dir %{_sysconfdir}/NetworkManager/dispatcher.d
%config %{_sysconfdir}/NetworkManager/dispatcher.d/ntp
%if 0%{?suse_version} > 1310
%attr(0640,root,ntp) %config(noreplace) %{_localstatedir}/lib/ntp%{_sysconfdir}/ntp.conf.iburst
%attr(0755,ntp,ntp) %dir %{_localstatedir}/lib/ntp/drift
%attr(0755,ntp,root) %{_localstatedir}/lib/ntp%{_localstatedir}/run/ntp
%ghost %config(noreplace) %{_localstatedir}/log/ntp

%files doc
%doc %{_docdir}/ntp-doc