File openstack-glance.spec of Package openstack-glance

# spec file for package openstack-glance
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2011 B1 Systems GmbH, Vohburg, 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.

# options to forcefully build with/without vcs
%bcond_with from_vcs
%bcond_with no_from_vcs

%if %{with from_vcs}
%define BUILD_FROM_VCS 1
%endif
%if %{with no_from_vcs}
%define BUILD_FROM_VCS 0
%endif

%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

%if 0%{?BUILD_FROM_VCS}
%define vcs_summary_warn -- Git Snapshot
%else
%define vcs_summary_warn %null
%endif

%define shortname glance
Name:           openstack-glance
Version:        2011.3
%if 0%{?BUILD_FROM_VCS}
%define _version git-master
%else
%define _version 2011.3
%endif
Release:        1
License:        Apache-2.0 and GPL-3.0+
Summary:        Discover, Register and Retrieve virtual machine images %{vcs_summary_warn}
Url:            http://glance.openstack.org/
Group:          Development/Libraries/Python
Source0:        glance-%{_version}.tar.gz
Source1:        openstack-glance.init
Patch0:         glance-2011.3.patch
Patch1:         lp_845788_glance_client_zero_length.patch
Patch2:         lp_850425_remote_swift_image_streaming.patch
BuildRequires:  fdupes
BuildRequires:  intltool
BuildRequires:  python-Sphinx
BuildRequires:  python-devel
BuildRequires:  python-distribute
BuildRequires:  python-distutils-extra
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

Requires:       openstack-swift
Requires:       python-PasteDeploy
Requires:       python-anyjson
Requires:       python-argparse
Requires:       python-boto
Requires:       python-eventlet
Requires:       python-greenlet
Requires:       python-httplib2
Requires:       python-kombu
Requires:       python-routes
Requires:       python-sqlalchemy
Requires:       python-sqlalchemy-migrate
Requires:       python-webob
Requires:       python-wsgiref
Requires:       python-xattr

%if 0%{?suse_version} > 1110
Requires(pre):    pwdutils
%else
Requires(pre):    shadow-utils
%endif

%define sharedstatedir %{_localstatedir}/lib

%description
The Glance project provides services for discovering, registering, and retrieving virtual machine images. Glance has a RESTful API that allows querying of VM image metadata as well as retrieval of the actual image.

%package -n python-glance
Summary:        OpenStack glance python files %{vcs_summary_warn}
Group:          Development/Languages/Python

%description -n python-glance
This package contains the python files for glance.

%prep
%setup -q -n %{shortname}-%{_version}
%if !(0%{?BUILD_FROM_VCS})
%patch0
%patch1 -p1
%patch2 -p1
%endif

%build
mkdir etc/glance
mv etc/*.conf etc/glance/
mv etc/*.sample etc/glance/
python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
mkdir -p %{buildroot}%{_initrddir}
mkdir -p %{buildroot}%{_sbindir}
install -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/openstack-glance
ln -s ../..%{_initrddir}/openstack-glance %{buildroot}%{_sbindir}/rcopenstack-glance
install -d -m 755 %{buildroot}%{sharedstatedir}/glance
install -d -m 755 %{buildroot}%{_localstatedir}/lib/glance
install -d -m 755 %{buildroot}%{_localstatedir}/lib/glance/images
install -d -m 755 %{buildroot}%{_localstatedir}/log/glance
install -d -m 755 %{buildroot}%{_localstatedir}/run/glance
rm -rf %{buildroot}%{_datadir}/doc/glance

%pre
getent group glance >/dev/null || groupadd -r glance
getent passwd glance >/dev/null || useradd -r -g glance -d %{sharedstatedir}/glance -s /sbin/nologin -c "OpenStack glance Daemons" glance
exit 0

%post
%fillup_and_insserv openstack-glance
%restart_on_update openstack-glance

%preun
%stop_on_removal openstack-glance

%postun
%insserv_cleanup

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc README
%{_initrddir}/openstack-glance
%{_sbindir}/rcopenstack-glance
%dir %{_sysconfdir}/glance
%config(noreplace) %{_sysconfdir}/glance/glance-api.conf
%if 0%{?BUILD_FROM_VCS}
%config(noreplace) %{_sysconfdir}/glance/glance-cache.conf
%else
%config(noreplace) %{_sysconfdir}/glance/glance-prefetcher.conf
%config(noreplace) %{_sysconfdir}/glance/glance-pruner.conf
%config(noreplace) %{_sysconfdir}/glance/glance-reaper.conf
%endif
%config(noreplace) %{_sysconfdir}/glance/glance-registry.conf
%config(noreplace) %{_sysconfdir}/glance/glance-scrubber.conf
%config(noreplace) %{_sysconfdir}/glance/logging.cnf.sample
%dir %attr(0755, glance, root) %{_localstatedir}/lib/glance
%dir %attr(0755, glance, root) %{_localstatedir}/lib/glance/images
%dir %attr(0755, glance, root) %{_localstatedir}/log/glance
%ghost %dir %attr(0755, glance, root) %{_localstatedir}/run/glance
%{_bindir}/glance
%{_bindir}/glance-api
%{_bindir}/glance-cache-prefetcher
%{_bindir}/glance-cache-pruner
%if 0%{?BUILD_FROM_VCS}
%{_bindir}/glance-cache-cleaner
%{_bindir}/glance-cache-manage
%{_bindir}/glance-cache-queue-image
%else
%{_bindir}/glance-cache-reaper
%endif
%{_bindir}/glance-control
%{_bindir}/glance-manage
%{_bindir}/glance-registry
%{_bindir}/glance-scrubber
%if !(0%{?BUILD_FROM_VCS})
%{_bindir}/glance-upload
%endif

%files -n python-glance
%defattr(-,root,root,-)
%{python_sitelib}

%changelog
openSUSE Build Service is sponsored by