Blob Blame History Raw
%if 0%{?fedora}
%global with_python3 1
%endif

%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%{!?pyver: %global pyver %(%{__python} -c "import sys ; print sys.version[:3]")}
%global debug_package %{nil}

Name:       odcs
Version:    0.2.1
Release:    2%{?dist}
Summary:    The On Demand Compose Service


Group:      Development/Tools
License:    MIT
URL:        https://pagure.io/odcs
Source0:    https://files.pythonhosted.org/packages/source/o/%{name}/%{name}-%{version}.tar.gz
Source1:    odcs-backend.service
# In Fedora, "pyldap" is only for python3, not for python2. Therefore we
# have to patch the requirements.txt to use python-ldap instead of pyldap.
# Both ldap bindings are compatible on Python code level.
Patch0:     odcs-pythonldap.patch
# Fedora related configuration for ODCS.
Patch1:     odcs-fedora-conf.patch

%if 0%{?rhel} && 0%{?rhel} <= 7
# In EL7 we need flask which needs python-itsdangerous which comes from
# rhel7-extras which is only available on x86_64 for now.
ExclusiveArch: %{ix86} x86_64
%else
BuildArch:    noarch
%endif

BuildRequires:    help2man

BuildRequires:    libmodulemd
BuildRequires:    gobject-introspection

BuildRequires:    systemd

BuildRequires:    python2-devel
BuildRequires:    python2-pdc-client
BuildRequires:    python2-fedora
BuildRequires:    python2-productmd
BuildRequires:    python2-funcsigs
BuildRequires:    python2-modulemd >= 1.1.0
BuildRequires:    python2-openidc-client

%if 0%{?with_python3}
BuildRequires:    python3-devel
BuildRequires:    python3-pdc-client
BuildRequires:    python3-fedora
BuildRequires:    python3-productmd
BuildRequires:    python3-funcsigs
BuildRequires:    python3-modulemd >= 1.1.0
BuildRequires:    python3-openidc-client
%endif


%if 0%{?rhel} && 0%{?rhel} <= 7
BuildRequires:    python-setuptools
BuildRequires:    python-flask-sqlalchemy
BuildRequires:    python-flask-migrate
BuildRequires:    python-nose
BuildRequires:    python-mock
BuildRequires:    python-six
BuildRequires:    pyOpenSSL
BuildRequires:    python-sqlalchemy
BuildRequires:    python-futures
BuildRequires:    python-flask
BuildRequires:    systemd-python
BuildRequires:    python-defusedxml
BuildRequires:    koji
BuildRequires:    python-httplib2
BuildRequires:    python-qpid
BuildRequires:    pyOpenSSL
BuildRequires:    python-sqlalchemy
BuildRequires:    python-ldap
BuildRequires:    python-gobject-base
%else
BuildRequires:    python2-setuptools
BuildRequires:    python2-flask-sqlalchemy
BuildRequires:    python2-flask-migrate
BuildRequires:    python2-nose
BuildRequires:    python2-mock
BuildRequires:    python2-tabulate
BuildRequires:    python2-six
BuildRequires:    python2-futures
BuildRequires:    python2-flask
BuildRequires:    python2-systemd
BuildRequires:    python2-defusedxml
BuildRequires:    python2-koji
BuildRequires:    python2-httplib2
BuildRequires:    python2-qpid
BuildRequires:    python2-pyOpenSSL
BuildRequires:    python2-sqlalchemy
BuildRequires:    python2-ldap
BuildRequires:    python2-gobject-base
%if 0%{?with_python3}
BuildRequires:    python3-setuptools
BuildRequires:    python3-flask-sqlalchemy
BuildRequires:    python3-flask-migrate
BuildRequires:    python3-nose
BuildRequires:    python3-mock
BuildRequires:    python3-tabulate
BuildRequires:    python3-six
BuildRequires:    python3-flask
BuildRequires:    python3-systemd
BuildRequires:    python3-defusedxml
BuildRequires:    python3-koji
BuildRequires:    python3-httplib2
BuildRequires:    python3-pyOpenSSL
BuildRequires:    python3-sqlalchemy
BuildRequires:    python3-ldap
BuildRequires:    python3-gobject-base
%endif
%endif

%if (0%{?fedora} && 0%{?fedora} <= 27) || (0%{?rhel} && 0%{?rhel} <= 7)
BuildRequires:    python-flask-script
BuildRequires:    python-flask-login
BuildRequires:    python-munch
%else
BuildRequires:    python2-flask-script
BuildRequires:    python2-flask-login
BuildRequires:    python2-munch
%if 0%{?with_python3}
BuildRequires:    python3-flask-script
BuildRequires:    python3-flask-login
BuildRequires:    python3-munch
%endif
%endif


%{?systemd_requires}

Requires(pre): shadow-utils
Requires:    systemd
Requires:    pungi
Requires:    python2-pdc-client
Requires:    python2-fedora
Requires:    python2-funcsigs
Requires:    python2-modulemd >= 1.1.0
Requires:    python2-openidc-client
Requires:    python2-productmd
Requires:    hardlink
Requires:    libmodulemd
Requires:    gobject-introspection
Requires:    python-gobject-base

%if 0%{?rhel} && 0%{?rhel} <= 7
Requires:    python-flask-sqlalchemy
Requires:    python-flask-migrate
Requires:    python-mock
Requires:    python-six
Requires:    pyOpenSSL
Requires:    python-sqlalchemy
Requires:    python-futures
Requires:    python-flask
Requires:    python-defusedxml
Requires:    koji
Requires:    python-httplib2
Requires:    python-qpid
Requires:    pyOpenSSL
Requires:    python-sqlalchemy

Requires:    systemd-python
%else
Requires:    python2-flask-sqlalchemy
Requires:    python2-flask-migrate
Requires:    python2-mock
Requires:    python2-systemd
Requires:    python2-six
Requires:    python2-futures
Requires:    python2-flask
Requires:    python2-defusedxml
Requires:    python2-koji
Requires:    python2-httplib2
Requires:    python2-qpid
Requires:    python2-pyOpenSSL
Requires:    python2-sqlalchemy
%endif

%if (0%{?fedora} && 0%{?fedora} <= 27) || (0%{?rhel} && 0%{?rhel} <= 7)
Requires:    python-flask-script
Requires:    python-flask-login
Requires:    python-ldap
Requires:    python-m2ext
Requires:    python-munch
%else
Requires:    python2-flask-script
Requires:    python2-flask-login
Requires:    python2-ldap
Requires:    python2-m2ext
Requires:    python2-munch
%endif

Requires:    python2-odcs-common = %{version}-%{release}


%description
The On Demand Compose Service (ODCS) creates temporary composes using Pungi
tool and manages their lifetime. The composes can be requested by external
services or users using the REST API provided by Flask frontend.

%package -n python2-odcs-common
Summary:        ODCS subpackage providing code shared between server and client.
%{?python_provide:%python_provide python2-odcs-client}

Requires:       python2-six

%description -n python2-odcs-common
ODCS subpackage providing code shared between server and client.

%package -n python2-odcs-client
Summary:        ODCS client module
%{?python_provide:%python_provide python2-odcs-client}

Requires:       python2-six
Requires:       m2crypto

%if (0%{?fedora} && 0%{?fedora} <= 27) || (0%{?rhel} && 0%{?rhel} <= 7)
Requires:       python-requests
Requires:       python-m2ext
%else
Requires:       python2-requests
Requires:       python2-m2ext
%endif

Requires:       python2-odcs-common = %{version}-%{release}

%description -n python2-odcs-client
Client library for sending requests to On Demand Compose Service (ODCS).

%if 0%{?with_python3}
%package -n python3-odcs-common
Summary:        ODCS subpackage providing code shared between server and client.
%{?python_provide:%python_provide python3-odcs-client}

Requires:       python3-six

%description -n python3-odcs-common
ODCS subpackage providing code shared between server and client.

%package -n python3-odcs-client
Summary:        ODCS client module
%{?python_provide:%python_provide python3-odcs-client}

Requires:       python3-six
Requires:       python3-requests
Requires:       python3-m2crypto
Requires:       python3-m2ext
Requires:       python3-odcs-common = %{version}-%{release}

%description -n python3-odcs-client
Client library for sending requests to On Demand Compose Service (ODCS).
%endif

%package -n odcs-client
Summary:        ODCS command line client
%if 0%{?with_python3}
Requires:       python3-openidc-client
Requires:       python3-odcs-client = %{version}-%{release}
%else
Requires:       python2-openidc-client
Requires:       python2-odcs-client = %{version}-%{release}
%endif

%description -n odcs-client
Command line client for sending requests to ODCS.


%prep
%setup -q

%if 0%{?with_python3}
sed -i '/futures/d' common/requirements.txt
sed -i '/futures/d' client/requirements.txt
sed -i '/futures/d' server/requirements.txt
%endif

%patch0 -p1 -b .pyldap
%patch1 -p1


%build
%py2_build
%if 0%{?with_python3}
%py3_build
%endif


%install
%py2_install

export PYTHONPATH=%{buildroot}%{python2_sitelib}
mkdir -p %{buildroot}%{_mandir}/man1
for command in odcs-manager odcs-frontend odcs-gencert odcs-upgradedb ; do
export ODCS_CONFIG_FILE=server/conf/config.py
help2man -N \
    --version-string=%{version} %{buildroot}%{_bindir}/$command  > \
    %{buildroot}%{_mandir}/man1/$command.1 || \
    %{buildroot}%{_bindir}/$command --help

done

install -d -m 0755 %{buildroot}%{_unitdir}
install -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/

install -d -m 0755 %{buildroot}%{_datadir}/odcs
install -p -m 0644 server/contrib/odcs.wsgi %{buildroot}%{_datadir}/odcs

%if 0%{?with_python3}
# Prepare the python3 bits, but remove the server portion.  We're just shipping
# the client as py3 for now.
%py3_install
rm -rf %{buildroot}%{python3_sitelib}/odcs/server/
%endif

%pre
getent group odcs >/dev/null || groupadd -r odcs
getent passwd odcs >/dev/null || \
    useradd -r -g odcs -s /sbin/nologin \
    -c "On Demand Compose Service user" odcs
exit 0

%post
%systemd_post odcs-backend.service

%preun
%systemd_preun odcs-backend.service

%postun
%systemd_postun_with_restart odcs-backend.service

%check
nosetests-2.7 -v

%if 0%{?with_python3}
nosetests-%{python3_version} -v
%endif

%files -n odcs-client
%doc README.md
%license LICENSE
%{_bindir}/odcs

%files -n python2-odcs-common
%doc README.md
%license LICENSE
%dir %{python2_sitelib}/odcs/
%{python2_sitelib}/odcs/__init__.py*
%{python2_sitelib}/odcs/common/
%{python2_sitelib}/odcs-%{version}-py%{pyver}.egg-info/
%exclude %{python2_sitelib}/odcs/__pycache__

%files -n python2-odcs-client
%doc README.md
%license LICENSE
%dir %{python2_sitelib}/odcs/
%{python2_sitelib}/odcs/client/
%exclude %{python2_sitelib}/odcs/__pycache__

%if 0%{?with_python3}
%files -n python3-odcs-common
%doc README.md
%license LICENSE
%dir %{python3_sitelib}/odcs/
%{python3_sitelib}/odcs/__init__.py*
%{python3_sitelib}/odcs/common/
%{python3_sitelib}/odcs-%{version}-py%{python3_version}.egg-info/
%exclude %{python3_sitelib}/odcs/__pycache__

%files -n python3-odcs-client
%doc README.md
%license LICENSE
%dir %{python3_sitelib}/odcs/
%{python3_sitelib}/odcs/client/
%exclude %{python3_sitelib}/odcs/__pycache__
%endif

%files
%doc README.md
%license LICENSE
%{_unitdir}/odcs-backend.service
%{python2_sitelib}/odcs/server
%{_bindir}/odcs-*
%{_mandir}/man1/odcs-*.1*
%{_datadir}/odcs
%dir %{_sysconfdir}/odcs
%config(noreplace) %{_sysconfdir}/odcs/config.py
%config(noreplace) %{_sysconfdir}/odcs/pungi.conf
%config(noreplace) %{_sysconfdir}/odcs/raw_config_wrapper.conf
%config(noreplace) %{_sysconfdir}/odcs/runroot_koji.conf
%exclude %{_sysconfdir}/odcs/*.py[co]
%exclude %{python2_sitelib}/odcs/__pycache__


%changelog
* Mon Mar 12 2018 Ralph Bean <rbean@redhat.com> - 0.2.1-2
- Python3 subpackages.

* Mon Mar 12 2018 Jan Kaluza <jkaluza@redhat.com> - 0.2.1-1
- updated to new version 0.2.1.

* Thu Mar 01 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.2.0-2
- Update Python 2 dependency declarations to new packaging standards
  (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

* Mon Feb 26 2018 Jan Kaluza <jkaluza@redhat.com> - 0.2.0-1
- updated to new version 0.2.0.

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

* Mon Feb 05 2018 Jan Kaluza <jkaluza@redhat.com> - 0.1.7-2
- restart odcs-backend.service on failure.

* Mon Feb 05 2018 Jan Kaluza <jkaluza@redhat.com> - 0.1.7-1
- updated to new version 0.1.7.

* Thu Jan 11 2018 Jan Kaluza <jkaluza@redhat.com> - 0.1.6-1
- updated to new version 0.1.6.

* Tue Dec 12 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.5-5
- do not remove pungi ODCS composes

* Mon Dec 11 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.5-4
- fix Koji kerberos login with keytab

* Mon Dec 11 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.5-3
- fix Koji kerberos login with keytab

* Mon Dec 11 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.5-2
- fix traceback in unique_path.

* Fri Dec 08 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.5-1
- updated to new version 0.1.5

* Fri Nov 24 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.4-1
- updated to new version 0.1.4.

* Fri Nov 24 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.3-1
- updated to new version 0.1.3.

* Wed Nov 01 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.2-1
- updated to new version 0.1.2.

* Mon Oct 30 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.1-3
- Require:hardlink

* Mon Oct 30 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.1-1
- updated to new version 0.1.1.

* Thu Oct 12 2017 Jan Kaluza <jkaluza@redhat.com> - 0.1.0-2
- use http instead of https for pulp .repo file

* Fri Oct 06 2017 Ralph Bean <rbean@redhat.com> - 0.1.0-1
- new version

* Thu Oct 05 2017 Ralph Bean <rbean@redhat.com> - 0.0.8-1
- new version

* Fri Sep 29 2017 Ralph Bean <rbean@redhat.com> - 0.0.7-1
- new version

* Tue Sep 26 2017 Ralph Bean <rbean@redhat.com> - 0.0.6-1
- new version

* Thu Sep 21 2017 Jan Kaluza <jkaluza@redhat.com> - 0.0.5-1
- new version

* Thu Aug 10 2017 Jan Kaluza <jkaluza@redhat.com> - 0.0.4-1
- new version

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Tue Jul 18 2017 Jan Kaluza <jkaluza@redhat.com> - 0.0.3-4
- fix reversed condition for python2-* dependencies

* Mon Jul 17 2017 Jan Kaluza <jkaluza@redhat.com> - 0.0.3-3
- Add python2- prefix to requirements when it makes sense
- Add -p to install command to preserve timestamp
- Fix macros formatting, use _datadir instead of /usr/share

* Tue Jul 11 2017 Jan Kaluza <jkaluza@redhat.com> - 0.0.3-2
- fix dependencies

* Thu Jun 29 2017 Jan Kaluza <jkaluza@redhat.com> - 0.0.3-1
- Initial version of spec file