Blob Blame History Raw
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7
%bcond_without  systemd
%endif

Summary:        Registry server for Docker
Name:           docker-registry
Version:        0.6.0
Release:        3%{?dist}
License:        ASL 2.0
URL:            https://github.com/dotcloud/docker-registry
Source:         https://github.com/dotcloud/docker-registry/archive/%{version}.tar.gz
Source1:        docker-registry.service
Source2:        docker-registry.sysconfig
Source3:        docker-registry.sysvinit

# Support for older Redis Python binding in EPEL
Patch0:         Support-for-older-Redis-Python-binding.patch

BuildRequires:    python2-devel

%if %{with systemd}
BuildRequires:      systemd
Requires(post):     systemd
Requires(preun):    systemd
Requires(postun):   systemd
%else
Requires(post):     chkconfig
Requires(preun):    chkconfig
Requires(postun):   initscripts
%endif

Requires:       python-boto
Requires:       python-flask
Requires:       PyYAML
Requires:       python-simplejson
Requires:       python-requests
Requires:       python-gunicorn
Requires:       python-gevent
Requires:       python-blinker
Requires:       python-glanceclient
Requires:       python-keystoneclient
Requires:       python-redis
Requires:       redis

BuildArch:      noarch

%description
Registry server for Docker (hosting/delivering of repositories and images).

%prep
%setup -q -n docker-registry-%{version}

# Remove the golang implementation
# It's not the main one (yet?)
rm -rf contrib/golang_impl

%if !%{with systemd}
%patch0 -p1
%endif

%install
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_sysconfdir}/sysconfig
install -d %{buildroot}%{_sharedstatedir}/%{name}
install -d %{buildroot}%{python_sitelib}/%{name}

install -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}

%if %{with systemd}
install -d %{buildroot}%{_unitdir}
install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service

# Make sure we set proper WorkingDir in the systemd service file
sed -i "s|#WORKDIR#|%{python_sitelib}/%{name}|" %{buildroot}%{_unitdir}/%{name}.service
%else
install -d %{buildroot}%{_initddir}
install -p -m 755 %{SOURCE3} %{buildroot}%{_initddir}/%{name}

# Make sure we set proper wrking dir in the sysvinit file
sed -i "s|#WORKDIR#|%{python_sitelib}/%{name}|" %{buildroot}%{_initddir}/%{name}
%endif

cp -r lib registry test %{buildroot}%{python_sitelib}/%{name}
cp wsgi.py %{buildroot}%{python_sitelib}/%{name}
cp config_sample.yml %{buildroot}%{_sysconfdir}/%{name}.yml

echo "local:
    storage: local
    storage_path: %{_sharedstatedir}/%{name}" >> %{buildroot}%{_sysconfdir}/%{name}.yml

%post
%if %{with systemd}
%systemd_post %{name}.service
%else
/sbin/chkconfig --add %{name}
%endif

%preun
%if %{with systemd}
%systemd_preun %{name}.service
%else
if [ $1 -eq 0 ] ; then
    /sbin/service %{name} stop >/dev/null 2>&1
    /sbin/chkconfig --del %{name}
fi
%endif

%postun
%if %{with systemd}
%systemd_postun_with_restart %{name}.service
%else
if [ "$1" -ge "1" ] ; then
    /sbin/service %{name} condrestart >/dev/null 2>&1 || :
fi
%endif

%files
%dir %{python_sitelib}/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%config(noreplace) %{_sysconfdir}/%{name}.yml
%{python_sitelib}/%{name}/lib/*.py
%{python_sitelib}/%{name}/lib/*.pyc
%{python_sitelib}/%{name}/lib/*.pyo
%{python_sitelib}/%{name}/lib/storage/*.py
%{python_sitelib}/%{name}/lib/storage/*.pyc
%{python_sitelib}/%{name}/lib/storage/*.pyo
%{python_sitelib}/%{name}/registry/*.py
%{python_sitelib}/%{name}/registry/*.pyc
%{python_sitelib}/%{name}/registry/*.pyo
%{python_sitelib}/%{name}/test/*.py
%{python_sitelib}/%{name}/test/*.pyc
%{python_sitelib}/%{name}/test/*.pyo
%{python_sitelib}/%{name}/*.py
%{python_sitelib}/%{name}/*.pyc
%{python_sitelib}/%{name}/*.pyo
%dir %{_sharedstatedir}/%{name}
%doc LICENSE README.md
%if %{with systemd}
%{_unitdir}/%{name}.service
%else
%{_initddir}/%{name}
%endif

%changelog
* Mon Dec 02 2013 Marek Goldmann <mgoldman@redhat.com> - 0.6.0-3
- EPEL support
- Comments in the sysconfig/docker-registry file

* Wed Nov 27 2013 Marek Goldmann <mgoldman@redhat.com> - 0.6.0-2
- Added license and readme

* Wed Nov 20 2013 Marek Goldmann <mgoldman@redhat.com> - 0.6.0-1
- Initial packaging