File openbgpd.spec of Package openbgpd

#
# spec file for package openbgpd
#
# Copyright (c) 2019-2024, Martin Hauke <mardnh@gmx.de>
#
# 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 openbgpd_user openbgpd
%define openbgpd_group openbgpd
%define openbgpd_home %{_localstatedir}/lib/openbgpd
Name:           openbgpd
Version:        8.5
Release:        0
Summary:        Linux port of OpenBSD BGP daemon and client
License:        BSD-3-Clause
Group:          Productivity/Networking/System
URL:            https://www.openbgpd.org/
#Git-Clone:     https://github.com/openbgpd-portable/openbgpd-portable
Source:         https://cdn.openbsd.org/pub/OpenBSD/OpenBGPD/openbgpd-%{version}.tar.gz
Source1:        https://cdn.openbsd.org/pub/OpenBSD/OpenBGPD/openbgpd-%{version}.tar.gz.asc
Source2:        openbgpd.service
Source99:       https://ftp.openbsd.org/pub/OpenBSD/OpenBGPD/openbgpd.asc#/openbgpd.keyring
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(libevent)
Requires(pre):  shadow
%{?systemd_requires}

%description
bgpd is a Border Gateway Protocol (BGP) daemon which manages the network
routing tables. Its main purpose is to exchange information concerning “network
reachability” with other BGP systems. bgpd uses the Border Gateway Protocol,
Version 4, as described in RFC 4271.

%prep
%setup -q

%build
%configure \
  --with-privsep-user=%{openbgpd_user}
%make_build

%install
%make_install
install -d %{buildroot}/%{_localstatedir}/lib/openbgpd
install -D -m0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

%pre
%service_add_pre %{name}.service
# Create openbgpd user/group
getent group %{openbgpd_group} >/dev/null || groupadd -r %{openbgpd_group}
getent passwd %{openbgpd_user} >/dev/null || useradd -r -g %{openbgpd_group} -d %{openbgpd_home} -s /sbin/nologin -c "OpenBGPD routing daemon" %{openbgpd_user}
exit 0

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%license LICENSE
%doc AUTHORS README.md
%config(noreplace) %attr(0640,root,%{openbgpd_group}) %{_sysconfdir}/bgpd.conf
%{_sbindir}/bgpctl
%{_sbindir}/bgpd
%{_sbindir}/bgplgd
%{_sbindir}/rc%{name}
%{_mandir}/man5/bgpd.conf.5%{?ext_man}
%{_mandir}/man8/bgpctl.8%{?ext_man}
%{_mandir}/man8/bgpd.8%{?ext_man}
%{_mandir}/man8/bgplgd.8%{?ext_man}
%{_localstatedir}/lib/openbgpd
%{_unitdir}/%{name}.service

%changelog
openSUSE Build Service is sponsored by