File python-ardana-packager.spec of Package python-ardana-packager

#
# spec file for package python-ardana-packager
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without test
Name:           python-ardana-packager
Version:        0.0.3
Release:        0
License:        Apache-2.0
Summary:        Prepackaged virtualenv deployment tool
Url:            https://github.com/ArdanaCLM/ardana-dev-tools/tree/master/ansible/library_python/packager
Group:          Development/Languages/Python
Source0:        https://files.pythonhosted.org/packages/source/a/ardana-packager/ardana-packager-%{version}.tar.gz
# Some ansible modules needed - from https://raw.githubusercontent.com/ArdanaCLM/ardana-dev-tools/master/ansible/deployer_modules/
# slightly modified the exec path with: sed -i 's!/opt/stack/service/packager/venv/bin/!/usr/bin/!g' install_package setup_systemd ...
Source1:        install_package
Source2:        setup_systemd
Source3:        config_symlinks
Source4:        nova_host_aggregate
Source5:        venv_edit
Patch0:         0001-SCRD-724-make-full-path-to-service-binary-configurab.patch
# https://gerrit.suse.provo.cloud/#/c/3071/
Patch1:         0001-SCRD-2696-Install-systemd-service-files-into-etc-sys.patch
# https://gerrit.suse.provo.cloud/#/c/3320/
Patch2:         0001-SCRD-2694-Synchronize-the-index-with-current-venvs.patch
BuildRequires:  python-rpm-macros
BuildRequires:  ardana-ansible
BuildRequires:  ardana-devel
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
%if %{with test}
BuildRequires:  %{python_module PyYAML >= 3.11}
BuildRequires:  %{python_module requests >= 2.4.3}
BuildRequires:  %{python_module six}
%endif
BuildRequires:  fdupes
Requires:       python-PyYAML >= 3.11
Requires:       python-requests >= 2.4.3
Requires:       python-setuptools
Requires:       python-six
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch:      noarch

%python_subpackages

%description
install_package application in support of Ardana

%prep
%setup -q -n ardana-packager-%{version}
%patch0 -p4
%patch1 -p4
%patch2 -p4

%build
%python_build
cp %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} .

%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/install_package
%python_clone -a %{buildroot}%{_bindir}/create_index
%python_clone -a %{buildroot}%{_bindir}/setup_systemd
%python_clone -a %{buildroot}%{_bindir}/venv_edit
%python_clone -a %{buildroot}%{_bindir}/config_symlinks
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%ifpython2
install -m 0755 -D %{SOURCE1} %{buildroot}/%{ardana_base_dir}/ansible/library/install_package
install -m 0755 -D %{SOURCE2} %{buildroot}/%{ardana_base_dir}/ansible/library/setup_systemd
install -m 0755 -D %{SOURCE3} %{buildroot}/%{ardana_base_dir}/ansible/library/config_symlinks
install -m 0755 -D %{SOURCE4} %{buildroot}/%{ardana_base_dir}/ansible/library/nova_host_aggregate
install -m 0755 -D %{SOURCE5} %{buildroot}/%{ardana_base_dir}/ansible/library/venv_edit
install -m 0755 -d %{buildroot}/opt/stack/venv
install -m 0755 -d %{buildroot}/opt/stack/service
%endif

%post
%python_install_alternative install_package
%python_install_alternative create_index
%python_install_alternative setup_systemd
%python_install_alternative venv_edit
%python_install_alternative config_symlinks

%postun
%python_uninstall_alternative install_package
%python_uninstall_alternative create_index
%python_uninstall_alternative setup_systemd
%python_uninstall_alternative venv_edit
%python_uninstall_alternative config_symlinks

%files %{python_files}
%defattr(-,root,root,-)
%doc README.md
%python_alternative %{_bindir}/install_package
%python_alternative %{_bindir}/create_index
%python_alternative %{_bindir}/setup_systemd
%python_alternative %{_bindir}/venv_edit
%python_alternative %{_bindir}/config_symlinks
%{python_sitelib}/*
%ifpython2
%{ardana_base_dir}/ansible/library
%dir /opt/stack
%dir /opt/stack/venv
%dir /opt/stack/service
%endif

%changelog
openSUSE Build Service is sponsored by