Blob Blame History Raw
%global package_name ara

%global common_desc \
ARA Records Ansible playbook runs and makes the recorded data available and \
intuitive for users and systems.

Name:           %{package_name}
Version:        0.16.1
Release:        3%{?dist}
Summary:        ARA Records Ansible playbook runs

License:        GPLv3
URL:            https://git.openstack.org/cgit/openstack/ara
Source0:        https://pypi.io/packages/source/a/%{package_name}/%{package_name}-%{version}.tar.gz
Source1:        ara-server.service
Source2:        ara.cfg
Source3:        logging-config.yaml
Source4:        ara.logrotate
BuildArch:      noarch

%{?systemd_requires}
BuildRequires:  systemd
BuildRequires:  git

Requires:       python3-%{package_name} = %{version}-%{release}
Requires:       %{package_name}-common = %{version}-%{release}

%description
%{common_desc}

%package -n python3-%{package_name}
Summary:        %{summary}

BuildRequires:  python3-devel
BuildRequires:  python3-pbr
BuildRequires:  python3-setuptools
# Test dependencies for check macro
BuildRequires:  ansible >= 2.4.0.0
BuildRequires:  python3-cliff
BuildRequires:  python3-flask >= 0.12.4
BuildRequires:  python3-flask-migrate
BuildRequires:  python3-flask-script
BuildRequires:  python3-frozen-flask
BuildRequires:  python3-jinja2 >= 2.9
BuildRequires:  python3-junit_xml
BuildRequires:  python3-lxml
BuildRequires:  python3-mock
BuildRequires:  python3-oslo-serialization
BuildRequires:  python3-oslo-utils
BuildRequires:  python3-pyfakefs
BuildRequires:  python3-pygments >= 1.6
BuildRequires:  python3-pytest
BuildRequires:  python3-six
BuildRequires:  python3-sqlalchemy
BuildRequires:  python3-subunit
BuildRequires:  python3-XStatic
BuildRequires:  python3-XStatic-Bootstrap-SCSS
BuildRequires:  python3-XStatic-DataTables
BuildRequires:  python3-XStatic-jQuery
BuildRequires:  python3-XStatic-Patternfly
BuildRequires:  python3-XStatic-Patternfly-Bootstrap-Treeview

Requires:       ansible >= 2.4.0.0
Requires:       python3-cliff
Requires:       python3-flask >= 0.12.4
Requires:       python3-flask-migrate
Requires:       python3-flask-script
Requires:       python3-frozen-flask
Requires:       python3-jinja2 >= 2.9
Requires:       python3-junit_xml
Requires:       python3-oslo-serialization
Requires:       python3-oslo-utils
Requires:       python3-pyfakefs
Requires:       python3-pygments >= 1.6
Requires:       python3-six
Requires:       python3-sqlalchemy
Requires:       python3-subunit
Requires:       python3-XStatic
Requires:       python3-XStatic-Bootstrap-SCSS
Requires:       python3-XStatic-DataTables
Requires:       python3-XStatic-jQuery
Requires:       python3-XStatic-Patternfly
Requires:       python3-XStatic-Patternfly-Bootstrap-Treeview

%{?python_provide:%python_provide python3-%{package_name}}

%description -n python3-%{package_name}
%{common_desc}

%package -n python3-%{package_name}-tests
Summary:        Tests for %{package_name}

Requires:       python3-%{package_name} = %{version}-%{release}
Requires:       python3-lxml
Requires:       python3-mock
Requires:       python3-pytest

%description -n python3-%{package_name}-tests
%{common_desc}

This package contains the test files.

%package common
Summary:        Common files for %{package_name}

Requires(pre): shadow-utils

%description common
%{common_desc}

This package contains the common files.

%package doc
Summary:        Documentation for %{package_name}

BuildRequires:  python3-sphinx
BuildRequires:  python3-sphinx_rtd_theme

%description doc
%{common_desc}

This package contains the documentation.

%prep
%autosetup -n %{package_name}-%{version} -S git

# Let RPM handle the requirements
rm -f {,test-}requirements.txt

%build
%py3_build
# Disable warning detection as failures: https://review.openstack.org/#/c/491202/
# sphinx-build -W -b html doc/source doc/build/html
sphinx-build -b html doc/source doc/build/html

%install
%py3_install

# Setup directories
install -d -m 755 %{buildroot}%{_sysconfdir}/%{package_name}
install -d -m 755 %{buildroot}%{_sharedstatedir}/%{package_name}
install -d -m 755 %{buildroot}%{_localstatedir}/log/%{package_name}

# Setup systemd unit file
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{package_name}-server.service

# Setup default config
install -p -D -m 640 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{package_name}/%{package_name}.cfg
install -p -D -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/%{package_name}/logging-config.yaml

# Setup logrotate
install -p -D -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/logrotate.d/%{package_name}

%check
# Run unit tests
%{__python3} -m pytest -v

%pre common
getent group %{package_name} >/dev/null || groupadd -r %{package_name}
getent passwd %{package_name} >/dev/null || \
    useradd -r -g %{package_name} -d %{_sharedstatedir}/%{package_name} \
    -s /sbin/nologin -c "User for ARA" %{package_name}
exit 0

%post
%systemd_post %{package_name}-server.service

%preun
%systemd_preun %{package_name}-server.service

%postun
%systemd_postun_with_restart %{package_name}-server.service

%files
%doc README.rst
%license LICENSE
%{_bindir}/ara*
%{_unitdir}/%{package_name}-server.service

%files -n python3-%{package_name}
%doc README.rst
%license LICENSE
%{python3_sitelib}/%{package_name}
%{python3_sitelib}/%{package_name}-*.egg-info
%exclude %{python3_sitelib}/%{package_name}/tests

%files -n python3-%{package_name}-tests
%doc README.rst
%license LICENSE
%{python3_sitelib}/%{package_name}/tests

%files common
%doc README.rst
%license LICENSE
%dir %{_sysconfdir}/%{package_name}
%config(noreplace) %attr(0640, root, %{package_name}) %{_sysconfdir}/%{package_name}/%{package_name}.cfg
%config(noreplace) %attr(0644, root, %{package_name}) %{_sysconfdir}/%{package_name}/logging-config.yaml
%config(noreplace) %{_sysconfdir}/logrotate.d/%{package_name}
%dir %attr(0750, %{package_name}, %{package_name}) %{_localstatedir}/log/%{package_name}
%dir %attr(0750, %{package_name}, %{package_name}) %{_sharedstatedir}/%{package_name}

%files doc
%doc README.rst doc/build/html
%license LICENSE

%changelog
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Mon Sep 10 2018 David Moreau Simard <dmsimard@redhat.com> - 0.16.1
- Update to latest upstream release
- Default to python3

* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.14.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

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

* Sat Feb 24 2018 David Moreau Simard <dmsimard@redhat.com> - 0.14.6-1
- Update to upstream 0.14.6

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.14.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Sat Aug 5 2017 David Moreau Simard <dmsimard@redhat.com> - 0.14.0-1
- First packaged version of ARA