File openstack-swift.spec of Package openstack-swift

#
# spec file for package openstack-swift
#
# Copyright (c) 2014 SUSE LINUX Products 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/
#


%define component swift
%define groupname %{component}
%define username %{component}

%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run
%endif

%define version_unconverted 2.1.0

Name:           openstack-%{component}
Version:        2.1.0
Release:        0
Summary:        OpenStack Storage (Swift)
License:        Apache-2.0
Group:          Development/Languages/Python
Url:            http://launchpad.net/swift
Source:         http://tarballs.openstack.org/swift/swift-%{version}.tar.gz
Source1:        %{name}-functions
Source2:        %{name}-account.init
Source3:        %{name}-account-auditor.init
Source4:        %{name}-account-reaper.init
Source5:        %{name}-account-replicator.init
Source6:        %{name}-container.init
Source7:        %{name}-container-auditor.init
Source8:        %{name}-container-replicator.init
Source9:        %{name}-container-updater.init
Source10:       %{name}-container-sync.init
Source11:       %{name}-object.init
Source12:       %{name}-object-replicator.init
Source13:       %{name}-object-expirer.init
Source14:       %{name}-object-updater.init
Source15:       %{name}-object-auditor.init
Source16:       %{name}-proxy.init
Source21:       test-configs-1.10.1.tar.bz2
Source22:       %{name}.logrotate
Patch0:         temp-hack-raise-header-size.diff
Patch1:         0001-Disallow-unsafe-tempurl-operations-to-point-to-unaut.patch
Patch2:         0001-Fix-metadata-overall-limits-bug.patch
Patch3:         0001-Fix-delete-versioning-objects-when-previous-is-expir.patch
Patch4:         0002-Prevent-unauthorized-delete-in-versioned-container.patch
%if 0%{?suse_version} > 1230
Source30:       %name.conf
BuildRequires:  systemd
Source99:       systemd-override.conf
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  crudini
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  python-devel
BuildRequires:  python-pbr >= 0.5.21
Requires:       logrotate
Requires:       python >= 2.6.8
Requires:       python-swift = %{version}
Requires:       rsync
Requires(post): %insserv_prereq
%if 0%{?suse_version} > 1110
Requires(pre):  pwdutils
%else
Requires(pre):  shadow-utils
%endif
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch:      noarch
%endif

%description
OpenStack Object Storage (swift) aggregates commodity servers to work
together in clusters for reliable, redundant, and large-scale storage
of static objects. Objects are written to multiple hardware devices in
the data center, with the OpenStack software responsible for ensuring
data replication and integrity across the cluster. Storage clusters can
scale horizontally by adding new nodes, which are automatically
configured. Should a node fail, OpenStack works to replicate its
content from other active nodes. Because OpenStack uses software logic
to ensure data replication and distribution across different devices,
inexpensive commodity hard drives and servers can be used in lieu of
more expensive equipment.

%package -n python-swift
Summary:        OpenStack Storage (Swift) - Python module
Group:          Development/Languages/Python
Requires:       python >= 2.6.8
Requires:       python-PasteDeploy >= 1.3.3
Requires:       python-dnspython >= 1.9.4
Requires:       python-eventlet >= 0.9.15
Requires:       python-greenlet >= 0.3.1
Requires:       python-netifaces >= 0.5
Requires:       python-pbr >= 0.5.21
Requires:       python-simplejson >= 2.0.9
Requires:       python-swiftclient
Requires:       python-xattr >= 0.4

%description -n python-swift
This package contains the core Python module of OpenStack Swift.

%package account
Summary:        OpenStack Storage (Swift) - Account Server
Group:          Productivity/Clustering/Computing
Requires:       %{name} = %{version}
Requires:       sqlite3 >= 3.6.23

%description account
OpenStack Object Storage (swift) aggregates commodity servers to work
together in clusters for reliable, redundant, and large-scale storage
of static objects.

This package contains the openstack-swift account server.

%package container
Summary:        OpenStack Storage (Swift) - Container Server
Group:          Productivity/Clustering/Computing
Requires:       %{name} = %{version}
Requires:       sqlite3 >= 3.6.23

%description container
OpenStack Object Storage (swift) aggregates commodity servers to work
together in clusters for reliable, redundant, and large-scale storage
of static objects.

This package contains the openstack-swift container server.

%package object
Summary:        OpenStack Storage (Swift) - Object Server
Group:          Productivity/Clustering/Computing
Requires:       %{name} = %{version}
Requires:       sqlite3 >= 3.6.23

%description object
OpenStack Object Storage (swift) aggregates commodity servers to work
together in clusters for reliable, redundant, and large-scale storage
of static objects.

This package contains the openstack-swift object server.

%package proxy
Summary:        OpenStack Storage (Swift) - Proxy Server
Group:          Productivity/Clustering/Computing
Requires:       %{name} = %{version}
Requires:       memcached

%description proxy
OpenStack Object Storage (swift) aggregates commodity servers to work
together in clusters for reliable, redundant, and large-scale storage
of static objects.

This package contains the openstack-swift proxy server.

%package test
Summary:        OpenStack Storage (Swift) - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       python-mock >= 1.0
Requires:       python-nose
Requires:       python-nosehtmloutput
Requires:       python-nosexcover
Requires:       python-openstack.nose_plugin

%description test
The OpenStack Swift testsuite. It is used to verify the functionality
of OpenStack Swift.

%prep
%setup -q -n %{component}-%{version}
%patch0
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
tar xvf %{SOURCE21}
%openstack_cleanup_prep

%build
python setup.py build

%install
python setup.py install --root %{buildroot} --prefix %{_prefix}

### directories
install -d -m 750 %{buildroot}%{_localstatedir}/cache/%{component}
install -d -m 750 %{buildroot}%{_localstatedir}/log/%{component}
install -d -m 755 %{buildroot}%{_rundir}/swift
%if 0%{?suse_version} > 1230
install -D -m 644 %{SOURCE30} %{buildroot}/%_tmpfilesdir/%name.conf
%endif

# Init helper functions
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_datadir}/%{name}/functions

# Init scripts
install -p -D -m 755 %{SOURCE2} %{buildroot}%{_initddir}/%{name}-account
install -p -D -m 755 %{SOURCE3} %{buildroot}%{_initddir}/%{name}-account-auditor
install -p -D -m 755 %{SOURCE4} %{buildroot}%{_initddir}/%{name}-account-reaper
install -p -D -m 755 %{SOURCE5} %{buildroot}%{_initddir}/%{name}-account-replicator
install -p -D -m 755 %{SOURCE6} %{buildroot}%{_initddir}/%{name}-container
install -p -D -m 755 %{SOURCE7} %{buildroot}%{_initddir}/%{name}-container-auditor
install -p -D -m 755 %{SOURCE8} %{buildroot}%{_initddir}/%{name}-container-replicator
install -p -D -m 755 %{SOURCE9} %{buildroot}%{_initddir}/%{name}-container-updater
install -p -D -m 755 %{SOURCE10} %{buildroot}%{_initddir}/%{name}-container-sync
# workaround https://bugzilla.novell.com/show_bug.cgi?id=772585
for m in auditor replicator server updater sync ; do
    ln -s swift-container-$m %{buildroot}%{_bindir}/swift-cont-$m
done
# end of workaround
install -p -D -m 755 %{SOURCE11} %{buildroot}%{_initddir}/%{name}-object
install -p -D -m 755 %{SOURCE12} %{buildroot}%{_initddir}/%{name}-object-replicator
install -p -D -m 755 %{SOURCE13} %{buildroot}%{_initddir}/%{name}-object-expirer
install -p -D -m 755 %{SOURCE14} %{buildroot}%{_initddir}/%{name}-object-updater
install -p -D -m 755 %{SOURCE15} %{buildroot}%{_initddir}/%{name}-object-auditor
install -p -D -m 755 %{SOURCE16} %{buildroot}%{_initddir}/%{name}-proxy

# symlinks for init scripts
mkdir -p %{buildroot}%{_sbindir}
for server in account account-auditor account-reaper account-replicator container container-auditor container-replicator container-updater container-sync object object-replicator object-expirer object-updater object-auditor proxy; do
    ln -s ../..%{_initddir}/%{name}-$server %{buildroot}%{_sbindir}/rc%{name}-$server
    %if 0%{?suse_version} > 1230
    # systemd overrides
    install -D -m 644 %{SOURCE99} %{buildroot}%{_unitdir}/%{name}-$server.service.d/custom.conf
    %endif
done

# Install manpages
install -d %{buildroot}%{_mandir}/man{1,5}/
install -m 0644 doc/manpages/*.1 %{buildroot}%{_mandir}/man1/
install -m 0644 doc/manpages/*.5 %{buildroot}%{_mandir}/man5/

# Remove tests
rm -fr %{buildroot}/%{python_sitelib}/test

# Misc other
install -d -m 755 %{buildroot}%{_sysconfdir}/swift
for c in account-server container-server dispersion object-expirer object-server proxy-server swift; do
    install -m 644 etc/$c.conf-sample %{buildroot}%{_sysconfdir}/swift/$c.conf
done
for c in account-server container-server object-expirer object-server proxy-server ; do
    crudini --set %{buildroot}%{_sysconfdir}/swift/$c.conf DEFAULT user %{username}
done
crudini --set %{buildroot}%{_sysconfdir}/swift/dispersion.conf dispersion auth_user %{username}
# NOTE(saschpe): dispersion checks for localhost:8080/auth... by default...
crudini --set %{buildroot}%{_sysconfdir}/swift/proxy-server.conf DEFAULT bind_port 8080

install -p -D -m 644 %{SOURCE22} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

%fdupes %{buildroot}%{python_sitelib}/swift

# test sub-package
%openstack_test_package_install
pushd test-configs-*

  install -m 755 usr/bin/resetswift %{buildroot}%{_bindir}/resetswift
  install -m 755 usr/bin/remakerings %{buildroot}%{_bindir}/remakerings
popd
# those conflicts conflict with the real configs, need to find a different solution
#cp -r test-configs-*/* %{buildroot}/
# For ./.unittests:
install -m 0644 test/sample.conf %{buildroot}%{_sysconfdir}/swift/test.conf
# For ./.functests:
ln -s %{_sysconfdir}/swift/test.conf %{buildroot}%{_sysconfdir}/swift/func_test.conf

%pre
%openstack_pre_user_group_create %{username} %{groupname}

%pre account
%if 0%{?suse_version} > 1230
%service_add_pre openstack-swift-account.service
%endif

%post account
%if 0%{?suse_version} > 1230
%service_add_post openstack-swift-account.service
%endif
%fillup_and_insserv -f openstack-swift-account
# set correct ownership for the log file in advance
install -m 0640 -o %{username} -g %{groupname} /dev/null /var/log/%{component}/account-server.log

%preun account
%stop_on_removal openstack-swift-account
%if 0%{?suse_version} > 1230
%service_del_preun openstack-swift-account.service
%endif

%postun account
%restart_on_update openstack-swift-account
%insserv_cleanup
%if 0%{?suse_version} > 1230
%service_del_postun openstack-swift-account.service
%endif

%pre container
%if 0%{?suse_version} > 1230
%service_add_pre openstack-swift-container.service
%endif

%post container
%if 0%{?suse_version} > 1230
%service_add_post openstack-swift-container.service
%endif
%fillup_and_insserv -f openstack-swift-container
install -m 0640 -o %{username} -g %{groupname} /dev/null /var/log/%{component}/container-server.log

%preun container
%stop_on_removal openstack-swift-container
%if 0%{?suse_version} > 1230
%service_del_preun openstack-swift-container.service
%endif

%postun container
%restart_on_update openstack-swift-container
%insserv_cleanup
%if 0%{?suse_version} > 1230
%service_del_postun openstack-swift-container.service
%endif

%pre object
%if 0%{?suse_version} > 1230
%service_add_pre openstack-swift-object.service
%endif

%post object
%if 0%{?suse_version} > 1230
%service_add_post openstack-swift-object.service
%endif
%fillup_and_insserv -f openstack-swift-object
install -m 0640 -o %{username} -g %{groupname} /dev/null /var/log/%{component}/object-server.log

%preun object
%stop_on_removal openstack-swift-object
%if 0%{?suse_version} > 1230
%service_del_preun openstack-swift-object.service
%endif

%postun object
%restart_on_update openstack-swift-object
%insserv_cleanup
%if 0%{?suse_version} > 1230
%service_del_postun openstack-swift-object.service
%endif

%pre proxy
%if 0%{?suse_version} > 1230
%service_add_pre openstack-swift-proxy.service
%endif

%post proxy
%if 0%{?suse_version} > 1230
%service_add_post openstack-swift-proxy.service
%endif
%fillup_and_insserv -f openstack-swift-proxy
install -m 0640 -o %{username} -g %{groupname} /dev/null /var/log/%{component}/proxy-server.log
install -m 0640 -o %{username} -g %{groupname} /dev/null /var/log/%{component}/proxy-server-startup.log

%preun proxy
%stop_on_removal openstack-swift-proxy
%if 0%{?suse_version} > 1230
%service_del_preun openstack-swift-proxy.service
%endif

%postun proxy
%restart_on_update openstack-swift-proxy
%insserv_cleanup
%if 0%{?suse_version} > 1230
%service_del_postun openstack-swift-proxy.service
%endif

%files
%defattr(-,root,root,-)
%doc README.md
%if 0%{?suse_version} > 1230
%_tmpfilesdir/%name.conf
%else
%dir %attr(0700, %{username}, %{groupname}) %{_rundir}/%{component}
%endif
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/log/%{component}
%dir %attr(0755, %{username}, %{groupname}) %{_sysconfdir}/swift
%dir %attr(0750, %{username}, %{groupname}) %{_localstatedir}/cache/swift
%dir %{_datadir}/openstack-swift
%{_datadir}/%{name}/functions
%{_bindir}/swift-account-audit
%{_bindir}/swift-dispersion-populate
%{_bindir}/swift-dispersion-report
%{_bindir}/swift-drive-audit
%{_bindir}/swift-form-signature
%{_bindir}/swift-get-nodes
%{_bindir}/swift-init
%{_bindir}/swift-config
%{_bindir}/swift-oldies
%{_bindir}/swift-orphans
%{_bindir}/swift-recon
%{_bindir}/swift-recon-cron
%{_bindir}/swift-ring-builder
%{_bindir}/swift-temp-url
%{_mandir}/man1/swift-dispersion-populate.1.gz
%{_mandir}/man1/swift-dispersion-report.1.gz
%{_mandir}/man1/swift-get-nodes.1.gz
%{_mandir}/man1/swift-init.1.gz
%{_mandir}/man1/swift-orphans.1.gz
%{_mandir}/man1/swift-recon.1.gz
%{_mandir}/man1/swift-ring-builder.1.gz
%{_mandir}/man5/dispersion.conf.5.gz
%config(noreplace) %{_sysconfdir}/swift/swift.conf
%config(noreplace) %{_sysconfdir}/swift/dispersion.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}

%files -n python-swift
%defattr(-,root,root,-)
%doc AUTHORS LICENSE
%{python_sitelib}/swift
%{python_sitelib}/swift-2.*.egg-info

%files account
%defattr(-,root,root,-)
%{_initddir}/%{name}-account*
%{_sbindir}/rc%{name}-account*
%if 0%{?suse_version} > 1230
%dir %{_unitdir}/%{name}-account*.service.d/
%{_unitdir}/%{name}-account*.service.d/custom.conf
%endif
%config(noreplace) %{_sysconfdir}/swift/account-server.conf
%{_bindir}/swift-account-auditor
%{_bindir}/swift-account-info
%{_bindir}/swift-account-reaper
%{_bindir}/swift-account-replicator
%{_bindir}/swift-account-server
%{_mandir}/man1/swift-account-auditor.1.gz
%{_mandir}/man1/swift-account-info.1.gz
%{_mandir}/man1/swift-account-reaper.1.gz
%{_mandir}/man1/swift-account-replicator.1.gz
%{_mandir}/man1/swift-account-server.1.gz
%{_mandir}/man5/account-server.conf.5.gz

%files container
%defattr(-,root,root,-)
%{_initddir}/%{name}-container*
%{_sbindir}/rc%{name}-container*
%if 0%{?suse_version} > 1230
%dir %{_unitdir}/%{name}-container*.service.d/
%{_unitdir}/%{name}-container*.service.d/custom.conf
%endif
%config(noreplace) %{_sysconfdir}/swift/container-server.conf
%{_bindir}/swift-container-auditor
%{_bindir}/swift-container-reconciler
%{_bindir}/swift-container-info
%{_bindir}/swift-container-server
%{_bindir}/swift-container-replicator
%{_bindir}/swift-container-updater
%{_bindir}/swift-container-sync
%{_bindir}/swift-reconciler-enqueue
%{_bindir}/swift-cont-*
%{_mandir}/man1/swift-container-auditor.1.gz
%{_mandir}/man1/swift-container-info.1.gz
%{_mandir}/man1/swift-container-server.1.gz
%{_mandir}/man1/swift-container-sync.1.gz
%{_mandir}/man1/swift-container-replicator.1.gz
%{_mandir}/man1/swift-container-updater.1.gz
%{_mandir}/man5/container-server.conf.5.gz

%files object
%defattr(-,root,root,-)
%doc etc/rsyncd.conf-sample
%{_initddir}/%{name}-object*
%{_sbindir}/rc%{name}-object*
%if 0%{?suse_version} > 1230
%dir %{_unitdir}/%{name}-object*.service.d/
%{_unitdir}/%{name}-object*.service.d/custom.conf
%endif
%config(noreplace) %{_sysconfdir}/swift/object-server.conf
%{_sysconfdir}/swift/object-expirer.conf
%{_bindir}/swift-object-auditor
%{_bindir}/swift-object-expirer
%{_bindir}/swift-object-info
%{_bindir}/swift-object-replicator
%{_bindir}/swift-object-server
%{_bindir}/swift-object-updater
%{_mandir}/man1/swift-object-auditor.1.gz
%{_mandir}/man1/swift-object-expirer.1.gz
%{_mandir}/man1/swift-object-info.1.gz
%{_mandir}/man1/swift-object-replicator.1.gz
%{_mandir}/man1/swift-object-server.1.gz
%{_mandir}/man1/swift-object-updater.1.gz
%{_mandir}/man5/object-expirer.conf.5.gz
%{_mandir}/man5/object-server.conf.5.gz

%files proxy
%defattr(-,root,root,-)
%{_initddir}/%{name}-proxy
%{_sbindir}/rc%{name}-proxy
%if 0%{?suse_version} > 1230
%dir %{_unitdir}/%{name}-proxy.service.d/
%{_unitdir}/%{name}-proxy.service.d/custom.conf
%endif
%config(noreplace) %{_sysconfdir}/swift/proxy-server.conf
%{_bindir}/swift-proxy-server
%{_mandir}/man1/swift-proxy-server.1.gz
%{_mandir}/man5/proxy-server.conf.5.gz

%files test
%defattr(-,root,root)
%dir %{_localstatedir}/lib/openstack-swift-test
%{_localstatedir}/lib/openstack-swift-test/*
%{_localstatedir}/lib/openstack-swift-test/.functests
%{_localstatedir}/lib/openstack-swift-test/.probetests
%{_localstatedir}/lib/openstack-swift-test/.unittests
%{_sysconfdir}/swift/test.conf
%{_sysconfdir}/swift/func_test.conf
%{_bindir}/remakerings
%{_bindir}/resetswift

%changelog