File exabgp.spec of Package exabgp

# spec file for package exabgp
# Copyright (c) 2015 SUSE LINUX Products 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

%if 0%{?suse_version} > 1210 || 0%{?rhel_version} > 6 || 0%{?centos_version} > 6 || 0%{?fedora_version} >= 20 || 0%{?el7}%{?fc20}%{?fc21}%{?fc22}
%bcond_without systemd
%bcond_with    systemd

Name:           exabgp
Version:        4.0.6
Release:        0
License:        BSD-3-Clause
Summary:        The BGP swiss army knife of networking
Group:          Productivity/Networking/Routing
BuildRequires:  python3-devel
BuildRequires:  python3-ipaddr
BuildRequires:  python3-setuptools
Requires:       python3-ipaddr
Requires:       python3-setuptools
Requires:       python3
Obsoletes:      python-%{name}
Provides:       python3-%{name} = %{version}-%{release}
%if %{with systemd}
BuildRequires:  pkgconfig(systemd)
%if 0%{?suse_version}
Requires(pre):  %insserv_prereq
%if 0%{?suse_version}
Requires(pre):  %fillup_prereq
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

ExaBGP allows engineers to control their network from commodity servers. Think
of it as Software Defined Networking using BGP by transforming BGP messages
into friendly plain text or JSON.

It comes with an healthcheck application to help you monitor your daemons and
withdraw dead ones from the network during failures/maintenances. A full lab
explaining how to use it is available here.

Find what other users have done with it. Current documented use cases include
DDOS mitigation, network visualisation, anycast, service high availability.

%setup -q

perl -p -i -e 's,#!/usr/bin/(env python|python),#!/usr/bin/python3,g' $(grep -E -l '#!/usr/bin/(env python|python)' -r .)
python3 build

python3 install --prefix=%{_prefix} --root=%{buildroot}

mv %{buildroot}%{_bindir} %{buildroot}%{_sbindir}

install -d %{buildroot}%{_sysconfdir}/%{name}/
#mv %{buildroot}%{_prefix}/etc/%{name}/ %{buildroot}%{_sysconfdir}/
cp -a etc/exabgp examples
chmod -R go= %{buildroot}%{_sysconfdir}/%{name}

install -D -m 0644 doc/man/exabgp.1      %{buildroot}%{_mandir}/man1/exabgp.1
install -D -m 0644 doc/man/exabgp.conf.5 %{buildroot}%{_mandir}/man5/exabgp.conf.5

%if %{with systemd}
install -D -m 0644 etc/systemd/exabgp.service %{buildroot}%{_unitdir}/exabgp.service
install -D -m 0644 etc/systemd/exabgp@.service %{buildroot}%{_unitdir}/exabgp@.service
ln -s service %{buildroot}%{_sbindir}/rc%{name}

%if %{with systemd}
%service_add_pre %{name}.service

%service_del_preun %{name}.service

%service_add_post %{name}.service

%service_del_postun %{name}.service

%config(noreplace) %{_sysconfdir}/%{name}
%if %{with systemd}