mh d91cc48
%global tarname OnionBalance
mh d91cc48
%global pkgname onionbalance
mh d91cc48
%global sum Load-balancing for Tor onion services
mh d91cc48
mh d91cc48
# EL7 has a too old sphinx version
mh d91cc48
# to support generating of docs
mh d91cc48
%if 0%{?rhel} == 7
mh d91cc48
%global for_el7 1
mh d91cc48
%global with_docs 0
mh d91cc48
%global main_pkg python2-%{pkgname}
mh d91cc48
%else
mh d91cc48
%global with_docs 1
mh d91cc48
%global for_el7 0
mh d91cc48
%global main_pkg python3-%{pkgname}
mh d91cc48
%endif
mh d91cc48
mh d91cc48
# test libs are too old for running tests on EL7 & F24
mh d91cc48
%if 0%{?fedora} >= 25
mh d91cc48
%global with_test 1
mh d91cc48
%endif
mh d91cc48
mh d91cc48
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{main_pkg}-%{version}}
mh d91cc48
mh d91cc48
%global toruser toranon
mh d91cc48
mh d91cc48
Name:           python-%{pkgname}
mh d91cc48
Version:        0.1.6
a76b9a4
Release:        2%{?dist}
mh d91cc48
Summary:        %{sum}
mh d91cc48
mh d91cc48
License:        GPLv3
mh d91cc48
URL:            http://pypi.python.org/pypi/%{tarname}
mh d91cc48
Source0:        https://github.com/DonnchaC/%{pkgname}/releases/download/%{version}/%{pkgname}-%{version}.tar.gz
mh d91cc48
Source1:        onionbalance.service
mh d91cc48
Source2:        onionbalance.tmpfiles
mh d91cc48
Source3:        onionbalance.logrotate
mh d91cc48
Source4:        docs-conf.py
mh d91cc48
Source5:        onionbalance.torrc.example
mh d91cc48
Source6:        README.fedora
mh d91cc48
mh d91cc48
BuildArch: noarch
mh d91cc48
mh d91cc48
BuildRequires: systemd-units
mh d91cc48
mh d91cc48
%if 0%{?for_el7}
mh d91cc48
BuildRequires:  python-setuptools
mh d91cc48
BuildRequires:  python2-devel
mh d91cc48
BuildRequires:  python-stem
mh d91cc48
BuildRequires:  PyYAML
mh d91cc48
BuildRequires:  python2-crypto
mh d91cc48
BuildRequires:  python2-future
mh d91cc48
BuildRequires:  python-setproctitle
mh d91cc48
%else
mh d91cc48
BuildRequires:  python3-devel
mh d91cc48
BuildRequires:  python3-setuptools
mh d91cc48
BuildRequires:  python3-stem
mh d91cc48
BuildRequires:  python3-PyYAML
mh d91cc48
BuildRequires:  python3-crypto
mh d91cc48
BuildRequires:  python3-future
mh d91cc48
BuildRequires:  python3-setproctitle
mh d91cc48
BuildRequires:  python3-sphinxcontrib-autoprogram
mh d91cc48
BuildRequires:  python3-pytest
mh d91cc48
BuildRequires:  python3-pytest-mock
mh d91cc48
BuildRequires:  python3-pexpect
mh d91cc48
%endif
mh d91cc48
mh d91cc48
BuildRequires: systemd
mh d91cc48
mh d91cc48
mh d91cc48
%description
mh d91cc48
OnionBalance provides load-balancing and redundancy for Tor
mh d91cc48
onion services by distributing requests to multiple back-end
mh d91cc48
Tor instances.
mh d91cc48
mh d91cc48
%package -n %{main_pkg}
mh d91cc48
%if 0%{?for_el7}
mh d91cc48
Summary:   %{sum}
mh d91cc48
Requires:  python-stem
mh d91cc48
Requires:  PyYAML
mh d91cc48
%if 0%{?for_el7}
mh d91cc48
Requires:  python-setuptools
mh d91cc48
%else
mh d91cc48
Requires:  python2-setuptools
mh d91cc48
%endif
mh d91cc48
Requires:  python2-crypto
mh d91cc48
Requires:  python2-future
mh d91cc48
Requires:  python-setproctitle
mh d91cc48
%{?python_provide:%python_provide python2-%{pkgname}}
mh d91cc48
%else
mh d91cc48
Summary:   %{sum}
mh d91cc48
Requires:  python3-stem
mh d91cc48
Requires:  python3-PyYAML
mh d91cc48
Requires:  python3-setuptools
mh d91cc48
Requires:  python3-crypto
mh d91cc48
Requires:  python3-future
mh d91cc48
Requires:  python3-setproctitle
mh d91cc48
%{?python_provide:%python_provide python3-%{pkgname}}
mh d91cc48
%endif
mh d91cc48
Requires: tor
mh d91cc48
Requires: logrotate
mh d91cc48
Requires(pre): shadow-utils
mh d91cc48
Requires(post): systemd
mh d91cc48
Requires(preun): systemd
mh d91cc48
Requires(postun): systemd
mh d91cc48
mh d91cc48
%description -n %{main_pkg}
mh d91cc48
OnionBalance provides load-balancing and redundancy for Tor
mh d91cc48
onion services by distributing requests to multiple back-end
mh d91cc48
Tor instances.
mh d91cc48
This package contains systemd files as well as logrotate rules.
mh d91cc48
mh d91cc48
%prep
mh d91cc48
%autosetup -n %{pkgname}-%{version}
mh d91cc48
mh d91cc48
%build
mh d91cc48
find . -name '*.pyc' -delete
mh d91cc48
%if 0%{?for_el7}
mh d91cc48
%py2_build
mh d91cc48
%else
mh d91cc48
%py3_build
mh d91cc48
%endif
mh d91cc48
%if 0%{?with_docs}
mh d91cc48
# restore conf that is missing in egg
mh d91cc48
cp %{SOURCE4} docs/conf.py
mh d91cc48
PYTHONPATH=. sphinx-build -N -v -v -v -v -E -bhtml docs/ docs/_build/html
mh d91cc48
PYTHONPATH=. sphinx-build -N -E -bman docs docs/_build/man
mh d91cc48
# Fix hidden-file-or-dir warnings
mh d91cc48
rm -rf docs/_build/html/.doctrees docs/_build/html/.buildinfo
mh d91cc48
%endif
mh d91cc48
mh d91cc48
%install
mh d91cc48
%if 0%{?for_el7}
mh d91cc48
%py2_install
mh d91cc48
%else
mh d91cc48
%py3_install
mh d91cc48
%endif
mh d91cc48
mh d91cc48
%if 0%{?for_el7}
mh d91cc48
# EL7 isn't yet that new, but given it's only a little change btw. 3.11 & 3.10
mh d91cc48
# it's fine to downgrade that requirement
mh d91cc48
sed -i 's/PyYAML>=3.11/PyYAML>=3.10/' %{buildroot}/%{python2_sitelib}/*.egg-info/requires.txt
mh d91cc48
%endif
mh d91cc48
mh d91cc48
install -d        %{buildroot}/etc/logrotate.d
mh d91cc48
install -d        %{buildroot}/%{_sysconfdir}/%{pkgname}
mh d91cc48
install -d        %{buildroot}/%{_localstatedir}/log/%{pkgname}
mh d91cc48
install -d        %{buildroot}/%{_localstatedir}/lib/%{pkgname}
mh d91cc48
install -d -m 755 %{buildroot}/%{_unitdir}
mh d91cc48
install -d -m 755 %{buildroot}/%{_tmpfilesdir}
mh d91cc48
mh d91cc48
install -p -m 644 %{SOURCE1} %{buildroot}/%{_unitdir}/%{pkgname}.service
mh d91cc48
install -p -m 644 %{SOURCE2} %{buildroot}/%{_tmpfilesdir}/%{pkgname}.conf
mh d91cc48
install -p -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/logrotate.d/%{pkgname}.conf
mh d91cc48
%if 0%{?with_docs}
mh d91cc48
install -d -m 755 %{buildroot}/%{_mandir}/man1
mh d91cc48
cp docs/_build/man/%{pkgname}* %{buildroot}/%{_mandir}/man1/
mh d91cc48
%endif
mh d91cc48
mh d91cc48
install -p -m 644 %{SOURCE5} .
mh d91cc48
install -p -m 644 %{SOURCE6} .
mh d91cc48
mh d91cc48
%check
mh d91cc48
# on some versions test libs are too old to run
mh d91cc48
%if 0%{?with_test}
mh d91cc48
py.test-3 --ignore=test/functional
mh d91cc48
%endif
mh d91cc48
mh d91cc48
%pre -n %{main_pkg}
mh d91cc48
getent passwd %{pkgname} >/dev/null || \
mh d91cc48
    useradd -r -g %{toruser} -d %{_localstatedir}/lib/%{pkgname} -s /sbin/nologin \
mh d91cc48
    -c "%{pkgname} daemon user" %{pkgname}
mh d91cc48
exit 0
mh d91cc48
mh d91cc48
%post -n %{main_pkg}
mh d91cc48
%systemd_post onionbalance.service
mh d91cc48
mh d91cc48
%preun -n %{main_pkg}
mh d91cc48
%systemd_preun onionbalance.service
mh d91cc48
mh d91cc48
%postun -n %{main_pkg}
mh d91cc48
%systemd_postun_with_restart onionbalance.service
mh d91cc48
mh d91cc48
%files -n %{main_pkg}
mh d91cc48
%doc README.rst
mh d91cc48
%doc README.fedora
mh d91cc48
%doc onionbalance.torrc.example
mh d91cc48
%license COPYING
mh d91cc48
%if 0%{?with_docs}
mh d91cc48
%doc docs/_build/html
mh d91cc48
%doc %attr(0644,root,root) %{_mandir}/man1/%{pkgname}*
mh d91cc48
%endif
mh d91cc48
%if 0%{?for_el7}
mh d91cc48
%{python2_sitelib}/*
mh d91cc48
%else
mh d91cc48
%{python3_sitelib}/*
mh d91cc48
%endif
mh d91cc48
%{_bindir}/%{pkgname}
mh d91cc48
%{_bindir}/%{pkgname}-config
mh d91cc48
%{_unitdir}/%{pkgname}.service
mh d91cc48
%{_tmpfilesdir}/%{pkgname}.conf
mh d91cc48
%dir %attr(0750,root,%{toruser}) %{_sysconfdir}/%{pkgname}
mh d91cc48
%dir %attr(0750,%{pkgname},%{toruser}) %{_localstatedir}/log/%{pkgname}
mh d91cc48
%dir %attr(0750,%{pkgname},%{toruser}) %{_localstatedir}/lib/%{pkgname}
mh d91cc48
%config(noreplace) %{_sysconfdir}/logrotate.d/%{pkgname}.conf
mh d91cc48
mh d91cc48
%changelog
a76b9a4
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.6-2
a76b9a4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
a76b9a4
mh d91cc48
* Fri Jan 20 2017 Marcel Haerry <mh+fedora@scrit.ch> - 0.1.6-1
mh d91cc48
  initial release