Blame python-exabgp.spec

e24e1f
%if 0%{?fedora}
e24e1f
%global with_python3 1
e24e1f
%endif
318b18
%global srcname exabgp
174563
174563
Name:           python-exabgp
e24e1f
Version:        4.0.1
16a767
Release:        2%{?dist}
174563
Summary:        The BGP swiss army knife of networking (Library)
174563
174563
License:        BSD
174563
URL:            https://github.com/Exa-Networks/
e24e1f
Source0:        https://github.com/Exa-Networks/%{srcname}/archive/%{version}.tar.gz
e24e1f
174563
BuildArch:      noarch
174563
e24e1f
%description
e24e1f
ExaBGP python module
174563
e24e1f
%package -n python2-%{srcname}
e24e1f
Summary:        The BGP swiss army knife of networking
e24e1f
Group:          Applications/Internet
e24e1f
BuildRequires:  python2-devel
318b18
BuildRequires:  python2-setuptools
318b18
Requires:       python2-six
1b8c2c
# XXX: only required for healthcheck.py on python2
1b8c2c
# healthcheck.py is in service package, but it simplifies packaging to put it here
1b8c2c
# According code, it tries to load ipaddress then ipaddr, since ipaddr is unmaintained
1b8c2c
# Let's stick to ipaddress which is backport from python3 stdlib
1b8c2c
Requires:       python-ipaddress
1b8c2c
%{?python_provide:%python_provide python2-%{srcname}}
174563
e24e1f
%description -n python2-%{srcname}
318b18
The BGP swiss army knife of networking
174563
e24e1f
%if 0%{?with_python3}
e24e1f
%package -n python3-%{srcname}
174563
Summary:        The BGP swiss army knife of networking
174563
Group:          Applications/Internet
e24e1f
BuildRequires:  python3-devel
e24e1f
BuildRequires:  python3-setuptools
e24e1f
Requires:       python3-six
1b8c2c
%{?python_provide:%python_provide python3-%{srcname}}
e24e1f
%endif
174563
e24e1f
%description -n python3-%{srcname}
e24e1f
The BGP swiss army knife of networking
174563
1b8c2c
%package -n exabgp
1b8c2c
Summary:        The BGP swiss army knife of networking
1b8c2c
Group:          Applications/Internet
1b8c2c
BuildRequires:  systemd-units
1b8c2c
Requires:       systemd
1b8c2c
# XXX: when python3 variant becomes default, change to python3 subpackage
1b8c2c
Requires:                   python2-%{srcname} = %{version}-%{release}
1b8c2c
1b8c2c
%description -n exabgp
1b8c2c
The BGP swiss army knife of networking (exabgp systemd unit)
1b8c2c
174563
%prep
e24e1f
%autosetup -n %{srcname}-%{version}
174563
174563
%build
e24e1f
%py2_build
e24e1f
%if 0%{?with_python3}
e24e1f
%py3_build
318b18
%endif
174563
174563
%install
1b8c2c
# Now, we'll ensure that our python2 binaries does not get overwritten
1b8c2c
# XXX: setup.py installs binaries in /usr/bin but systemd unit expects it to be in /usr/sbin
1b8c2c
mkdir -p %{buildroot}%{_sbindir}
e24e1f
%if 0%{?with_python3}
e24e1f
%py3_install
1b8c2c
mv %{buildroot}%{_bindir}/%{srcname} %{buildroot}%{_sbindir}/%{srcname}-%{python3_version}
1b8c2c
ln -s ./%{srcname}-%{python3_version} %{buildroot}%{_sbindir}/%{srcname}-3
318b18
%endif
174563
1b8c2c
%py2_install
1b8c2c
mv %{buildroot}%{_bindir}/%{srcname} %{buildroot}%{_sbindir}/%{srcname}-%{python2_version}
1b8c2c
ln -s ./%{srcname}-%{python2_version} %{buildroot}%{_sbindir}/%{srcname}-2
1b8c2c
# Symbolic link to default exabgp binary variant (python2)
1b8c2c
ln -s ./%{srcname}-2 %{buildroot}%{_sbindir}/%{srcname}
1b8c2c
e24e1f
%check
e24e1f
%{__python2} setup.py test
e24e1f
%if 0%{?with_python3}
e24e1f
%{__python3} setup.py test
318b18
%endif
174563
1b8c2c
# Install health check
1b8c2c
install -p -D -m 0755 bin/healthcheck %{buildroot}%{_sbindir}
1b8c2c
mv %{buildroot}%{_sbindir}/healthcheck %{buildroot}/%{_sbindir}/%{srcname}-healthcheck
174563
1b8c2c
# Configure required directories for the exabgp service
e24e1f
mkdir -p %{buildroot}/%{_sysconfdir}/exabgp
e24e1f
mkdir -p %{buildroot}/%{_libdir}/exabgp
1b8c2c
# Install exabgp systemd unit
e24e1f
mkdir -p %{buildroot}/%{_unitdir}
1b8c2c
install -p -D -m 0644 etc/systemd/%{srcname}.service %{buildroot}/%{_unitdir}/%{srcname}.service
174563
1b8c2c
# Install man pages
e24e1f
mkdir -p %{buildroot}/%{_mandir}/man1
174563
install doc/man/exabgp.1 %{buildroot}/%{_mandir}/man1
e24e1f
mkdir -p %{buildroot}/%{_mandir}/man5
174563
install doc/man/exabgp.conf.5 %{buildroot}/%{_mandir}/man5
174563
1b8c2c
%post -n exabgp
1b8c2c
%systemd_post %{srcname}.service
174563
1b8c2c
%preun -n exabgp
1b8c2c
%systemd_preun %{srcname}.service
174563
1b8c2c
%postun -n exabgp
1b8c2c
%systemd_postun_with_restart %{srcname}.service
174563
e24e1f
%files -n python2-%{srcname}
174563
%doc CHANGELOG README.md
1b8c2c
%{python2_sitelib}/*
1b8c2c
# XXX: when python3 variant becomes default, move next line to python3 subpackage
1b8c2c
%{_sbindir}/%{srcname}
1b8c2c
%{_sbindir}/%{srcname}-2*
174563
%license COPYRIGHT
174563
e24e1f
%if 0%{?with_python3}
e24e1f
%files -n python3-%{srcname}
e24e1f
%{python3_sitelib}/*
1b8c2c
%{_sbindir}/%{srcname}-3*
174563
%doc CHANGELOG README.md
174563
%license COPYRIGHT
1b8c2c
%endif
1b8c2c
1b8c2c
# Let's split out exabgp service here
1b8c2c
%files -n exabgp
1b8c2c
%attr(755, root, root) %{_sbindir}/%{srcname}-healthcheck
1b8c2c
%{_unitdir}/%{srcname}.service
1b8c2c
%dir %{_libdir}/%{srcname}
1b8c2c
%dir %{_datadir}/%{srcname}
1b8c2c
%dir %{_datadir}/%{srcname}/processes
1b8c2c
%dir %{_sysconfdir}/%{srcname}
1b8c2c
%attr(744, root, root) %{_datadir}/%{srcname}/processes/*
174563
%{_mandir}/man1/*
174563
%{_mandir}/man5/*
174563
174563
%changelog
16a767
* Fri Jul 10 2017 Luke Hinds <lhinds@redhat.com> - 4.0.1-2
16a767
- Fixed dependency issues
e24e1f
* Fri Jul 07 2017 Luke Hinds <lhinds@redhat.com> - 4.0.1
e24e1f
- 4.0.1 release, and python 3 support
174563
* Fri May 19 2017 Luke Hinds <lhinds@redhat.com> - 4.0.0
174563
- Initial release