File venv-openstack-octavia.spec of Package venv-openstack-octavia

#
# spec file for package venv-openstack-octavia
#
# 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/
#

# OBS directives (do not remove)
# needsbinariesforbuild

%global ardana_version 9
%global ardana_packager /opt/ardana_packager/
# Place where we will store the tarball
%global ardana_packager_tgz %{ardana_packager}ardana-%{ardana_version}/sles_venv/%{_arch}/
# Ardana will execute the venv from this place
%global ardana_venv /opt/stack/venv

%global timestamp %(date --utc +%%Y%%m%%dT%%H%%M%%SZ)
%global component octavia
%global venv %{component}-%{timestamp}


Name:           venv-openstack-%{component}
Version:        %(rpm -q --qf "%{version}" openstack-%{component})
Release:        0
Summary:        Python virtualenv for OpenStack Octavia
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/%{component}
Source10:       exclude-rpm
Source11:       include-rpm
BuildRequires:  python-venvjail
BuildRequires:  python-python-logstash
# --- [venvjail - BuildRequires] START ---
BuildRequires:  openstack-octavia
BuildRequires:  openstack-octavia-amphora-agent
BuildRequires:  openstack-octavia-api
BuildRequires:  openstack-octavia-health-manager
BuildRequires:  openstack-octavia-housekeeping
BuildRequires:  openstack-octavia-worker
BuildRequires:  python-octavia
# --- [venvjail - BuildRequires] END ---
# --- [venvjail - Requires] START ---
# Requires:       logrotate
# Requires:       python-netifaces >= 0.10.4
# --- [venvjail - Requires] END ---
BuildArch:      noarch

%description
Virtual environment jail for all Octavia services.

%package %{_arch}
Summary:        Python virtualenv for OpenStack Octavia
Group:          System/Management

%description %{_arch}
Virtual environment jail for all Octavia services.

%prep
cp -a %{SOURCE10} .
cp -a %{SOURCE11} .

%build
venvjail create %{venv} \
	 --relocate %{ardana_venv} \
	 --version %{version} \
	 --track ../OTHER/%{name}-%{_arch}-%{version}-%{release}.noarch.rpm.packages

%install
mkdir -p %{buildroot}%{ardana_packager_tgz}
tar -C %{venv} \
    -czf %{buildroot}%{ardana_packager_tgz}%{venv}.tgz \
    --owner=0 --group=0 .
%if %{_arch} == x86_64
ln -s %{ardana_packager_tgz}%{venv}.tgz %{buildroot}%{ardana_packager_tgz}..
%endif

%post %{_arch}
mkdir -p /var/run/venv-openstack
> /var/run/venv-openstack/run-update

%postun %{_arch}
if [ "$1" = "0" -a -e /usr/bin/create_index ]; then
    /usr/bin/create_index --dir %{ardana_packager_tgz}
fi
if [ "$1" = "1" ]; then
    mkdir -p /var/run/venv-openstack
    > /var/run/venv-openstack/run-update
fi

%posttrans %{_arch}
if [ ! -e /var/run/venv-openstack/run-update ]; then
    exit 0
fi
%if %{with zypper_posttrans}
if [ ! -z "$ZYPP_IS_RUNNING" ]; then
    exit 0
fi
%endif
if [ -e /usr/bin/create_index ]; then
    /usr/bin/create_index --dir %{ardana_packager_tgz}
fi
rm -f /var/run/venv-openstack/run-update

%files %{_arch}
%defattr(-,root,root)
%{ardana_packager}

%changelog
openSUSE Build Service is sponsored by