File openntpd.spec of Package openntpd

#
# spec file for package openntpd
#
# 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/
#


Name:           openntpd
Version:        6.2p3
Release:        0
Summary:        Network Time Protocol server
License:        ISC
Group:          Productivity/Networking/Other
Url:            http://openntpd.org/

#Git-Clone:	git://github.com/openntpd-portable/openntpd-portable
#DL-URL:	http://ftp.openbsd.org/pub/OpenBSD/OpenNTPD/
Source:         http://ftp.openbsd.org/pub/OpenBSD/OpenNTPD/%name-%version.tar.gz
Source2:        http://ftp.openbsd.org/pub/OpenBSD/OpenNTPD/%name-%version.tar.gz.asc
Source3:        %name.keyring
Patch0:         openntpd.patch
Patch1:         pun.diff
BuildRequires:  bison
BuildRequires:  libtool
Requires(pre):  user(ntp)
Conflicts:      ntp

%description
OpenNTPD is a Unix system daemon implementing the Network Time
Protocol to synchronize the local clock of a computer system with
remote NTP servers. It is also able to act as an NTP server to
NTP-compatible clients.

%prep
%autosetup -p1

%build
[ -f src/ntpd.h ]
perl -i -pe 's{(#define\s*NTPD_USER\s).*}{$1\t"ntp"}g' src/ntpd.h
grep NTPD_USER src/ntpd.h

# replace shipped libtool with new one knowing PIE
autoreconf -fi
%configure
%make_build LDFLAGS="-pie -fPIC" USER_CFLAGS="-pie -fPIC"

%install
b="%buildroot"
%make_install
mkdir -p "$b/%_unitdir"
cat >"$b/%_unitdir/ntpd.service" <<-EOF
	[Unit]
	Description=NTP server daemon
	Documentation=man:ntpd(8)
	After=nss-lookup.target
	Conflicts=systemd-timesyncd.service
	Wants=network.target
	After=network.target
	[Service]
	Type=simple
	ExecStart=/usr/sbin/ntpd -d
	[Install]
	WantedBy=multi-user.target
EOF

%pre
%service_add_pre ntpd.service

%post
%service_add_post ntpd.service

%preun
%service_del_preun ntpd.service

%postun
%service_del_postun ntpd.service

%files
%config(noreplace) %_sysconfdir/ntpd.conf
%_sbindir/ntpctl
%_sbindir/ntpd
%_mandir/man5/ntpd.conf.5*
%_mandir/man8/ntp*.8*
%_unitdir/ntpd.service
%license COPYING

%changelog
openSUSE Build Service is sponsored by