Blob Blame Raw
%if 0%{?fedora} || 0%{?rhel} >= 7
%bcond_without systemd
%endif

%if 0%{?fedora} || 0%{?rhel} >= 8
%bcond_without python3
%endif

%bcond_without tests


Name:           nova-agent
Version:        2.1.20
Release:        2%{?dist}
Summary:        Agent for setting up clean servers on Xen
License:        ASL 2.0
URL:            https://github.com/Rackspace-DOT/nova-agent
Source0:        %{url}/archive/%{version}/nova-agent-%{version}.tar.gz
BuildArch:      noarch

%{?with_systemd:BuildRequires: systemd}

%if %{with python3}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
%else
BuildRequires:  python-devel
BuildRequires:  python-setuptools
%endif

%if %{with tests}
%if %{with python3}
BuildRequires:  python3-nose
BuildRequires:  python3-crypto
BuildRequires:  python3-netifaces
BuildRequires:  python3-pyxs
BuildRequires:  python3-yaml
BuildRequires:  python3-distro
%else
BuildRequires:  python-nose
BuildRequires:  python-crypto
BuildRequires:  python-netifaces
BuildRequires:  python-pyxs
BuildRequires:  python-mock
BuildRequires:  python-yaml
BuildRequires:  python-distro
%if 0%{?python2_version_nodots} < 27
BuildRequires:  python-unittest2
BuildRequires:  python-argparse
%endif
%endif
%endif

%if %{with python3}
Requires:       python3-setuptools
Requires:       python3-crypto
Requires:       python3-netifaces
Requires:       python3-pyxs
Requires:       python3-yaml
Requires:       python3-distro
%else
Requires:       python-setuptools
Requires:       python-crypto
Requires:       python-netifaces
Requires:       python-pyxs
Requires:       python-yaml
Requires:       python-distro
%if 0%{?python2_version_nodots} < 27
Requires:       python-argparse
%endif
%endif

%if %{with systemd}
%{?systemd_requires}
%else
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(preun): initscripts
Requires(postun): initscripts
%endif


%description
Python agent for setting up clean servers on Xen using xenstore data.


%prep
%autosetup


%build
%if %{with python3}
%py3_build
%else
%py2_build
%endif


%install
%if %{with python3}
%py3_install
%else
%py2_install
%endif

%if %{with systemd}
install -Dm644 etc/nova-agent.service %{buildroot}/%{_unitdir}/nova-agent.service
%else
install -Dm755 etc/nova-agent.redhat %{buildroot}/%{_initddir}/nova-agent
%endif


%if %{with tests}
%check
%if %{with python3}
nosetests-%{python3_version} -v
%else
nosetests -v
%endif
%endif


%post
%if %{with systemd}
%systemd_post nova-agent.service
%else
chkconfig --add nova-agent &> /dev/null || :
%endif


%preun
%if %{with systemd}
%systemd_preun nova-agent.service
%else
if [ $1 -eq 0 ]; then
    service nova-agent stop &> /dev/null || :
    chkconfig --del nova-agent &> /dev/null || :
fi
%endif


%postun
%if %{with systemd}
%systemd_postun_with_restart nova-agent.service
%else
if [ $1 -ge 1 ]; then
    service nova-agent condrestart &> /dev/null || :
fi
%endif


%files
%license LICENSE
%doc README.md
%if %{with python3}
%{python3_sitelib}/novaagent
%{python3_sitelib}/novaagent-%{version}-py%{python3_version}.egg-info
%else
%{python2_sitelib}/novaagent
%{python2_sitelib}/novaagent-%{version}-py%{python2_version}.egg-info
%endif
%{_bindir}/nova-agent
%if %{with systemd}
%{_unitdir}/nova-agent.service
%else
%{_initddir}/nova-agent
%endif


%changelog
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.20-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Mon Dec 17 2018 Carl George <carl@george.computer> - 2.1.20-1
- Latest upstream
- Requires setuptools because the entrypoint script imports pkg_resources
- Use python3 on RHEL 8+

* Thu Sep 13 2018 Dave Kludt <david.kludt@rackspace.com> - 2.1.18-1
- Latest Upstream

* Wed Sep 05 2018 Dave Kludt <david.kludt@rackspace.com> - 2.1.17-1
- Latest Upstream

* Fri Aug 31 2018 Dave Kludt <david.kludt@rackspace.com> - 2.1.16-1
- Latest Upstream

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.14-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Mon Jul 02 2018 Miro Hrončok <mhroncok@redhat.com> - 2.1.14-2
- Rebuilt for Python 3.7

* Mon Jun 25 2018 Dave Kludt <david.kludt@rackspace.com> - 2.1.14-1
- Latest upstream

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 2.1.12-2
- Rebuilt for Python 3.7

* Wed Feb 21 2018 Carl George <carl@george.computer> - 2.1.12-1
- Latest upstream

* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.11-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Fri Jan 05 2018 Carl George <carl@george.computer> - 2.1.11-1
- Latest upstream

* Tue Dec 19 2017 Carl George <carl@george.computer> - 2.1.10-1
- Latest upstream

* Sat Oct 21 2017 Carl George <carl@george.computer> - 2.1.8-1
- Latest upstream

* Tue Sep 05 2017 Carl George <carl@george.computer> - 2.1.6-1
- Latest upstream
- Add patch for pull request #22

* Thu Aug 31 2017 Carl George <carl@george.computer> - 2.1.5-1
- Latest upstream

* Thu Aug 10 2017 Carl George <carl@george.computer> - 2.1.1-1
- Latest upstream

* Wed Aug 09 2017 Carl George <carl@george.computer> - 2.1.0-1
- Latest upstream

* Wed Aug 02 2017 Carl George <carl@george.computer> - 2.0.3-1
- Latest upstream
- Run test suite

* Mon Jun 26 2017 Dave Kludt <david.kludt@rackspace.com> 2.0.0-1
- Refactor code and bump to higher version so upgrade can be done

* Mon Feb 15 2016 Daniel Wallace <danielwallace@gtmanfred.com> 0.2.1-1
- Always write a string to xenstore on returns

* Mon Feb 01 2016 Carl George <carl.george@rackspace.com> - 0.2.0-1
- Disable debug packages
- Build with Python 3 on Fedora and openSUSE
- openSUSE macros fixes

* Fri Jan 29 2016 Carl George <carl.george@rackspace.com> - 0.1.0-1
- Initial build of package