%if 0%{?fedora} || 0%{?rhel} == 6
%global with_devel 1
%global with_bundled 0
%global with_debug 1
%global with_check 1
%global with_unit_test 1
%else
%global with_devel 0
%global with_bundled 1
%global with_debug 0
%global with_check 0
%global with_unit_test 0
%endif
%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package %{nil}
%endif
%if ! 0%{?gobuild:1}
%define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
%endif
%if ! 0%{?gotest:1}
%define gotest() go test -ldflags "${LDFLAGS:-}" %{?**}
%endif
%global provider github
%global provider_tld com
%global project docker
%global repo distribution
# https://github.com/docker/distribution
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
%global commit a25b9ef0c9fe242ac04bb20d3a028442b7d266b6
%global shortcommit %(c=%{commit}; echo ${c:0:7})
Name: %{project}-%{repo}
Version: 2.6.1
Release: 1%{?dist}
Summary: Docker toolset to pack, ship, store, and deliver content
License: ASL 2.0
URL: https://%{provider_prefix}
Source0: https://%{provider_prefix}/archive/%{commit}.tar.gz
Source1: %{name}.service
Source2: config.yml
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} >= 1.6.2
BuildRequires: systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Obsoletes: docker-registry < 0.9.1-8
Provides: docker-registry = %{version}-%{release}
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}}
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
%if ! 0%{?with_bundled}
BuildRequires: golang(github.com/AdRoll/goamz/aws)
BuildRequires: golang(github.com/AdRoll/goamz/cloudfront)
BuildRequires: golang(github.com/AdRoll/goamz/s3)
BuildRequires: golang(github.com/Azure/azure-sdk-for-go/storage)
BuildRequires: golang(github.com/Sirupsen/logrus)
BuildRequires: golang(github.com/Sirupsen/logrus/formatters/logstash)
BuildRequires: golang(github.com/bugsnag/bugsnag-go)
BuildRequires: golang(github.com/denverdino/aliyungo/oss)
BuildRequires: golang(github.com/docker/docker/pkg/tarsum)
BuildRequires: golang(github.com/docker/libtrust)
BuildRequires: golang(github.com/garyburd/redigo/redis)
BuildRequires: golang(github.com/gorilla/handlers)
BuildRequires: golang(github.com/gorilla/mux)
BuildRequires: golang(github.com/mitchellh/mapstructure)
BuildRequires: golang(github.com/ncw/swift)
BuildRequires: golang(github.com/ncw/swift/swifttest)
BuildRequires: golang(github.com/noahdesu/go-ceph/rados)
BuildRequires: golang(github.com/stevvooe/resumable)
BuildRequires: golang(github.com/stevvooe/resumable/sha256)
BuildRequires: golang(github.com/stevvooe/resumable/sha512)
BuildRequires: golang(github.com/yvasiyarov/gorelic)
BuildRequires: golang(golang.org/x/crypto/bcrypt)
BuildRequires: golang(golang.org/x/net/context)
BuildRequires: golang(gopkg.in/check.v1)
BuildRequires: golang(gopkg.in/yaml.v2)
%endif
%description
%{summary}
%if 0%{?with_devel}
%package devel
Summary: %{summary}
BuildArch: noarch
%if 0%{?with_check}
BuildRequires: golang(github.com/AdRoll/goamz/aws)
BuildRequires: golang(github.com/AdRoll/goamz/cloudfront)
BuildRequires: golang(github.com/AdRoll/goamz/s3)
BuildRequires: golang(github.com/Azure/azure-sdk-for-go/storage)
BuildRequires: golang(github.com/Sirupsen/logrus)
BuildRequires: golang(github.com/denverdino/aliyungo/oss)
BuildRequires: golang(github.com/docker/docker/pkg/tarsum)
BuildRequires: golang(github.com/docker/libtrust)
BuildRequires: golang(github.com/garyburd/redigo/redis)
BuildRequires: golang(github.com/gorilla/handlers)
BuildRequires: golang(github.com/gorilla/mux)
BuildRequires: golang(github.com/mitchellh/mapstructure)
BuildRequires: golang(github.com/ncw/swift)
BuildRequires: golang(github.com/ncw/swift/swifttest)
BuildRequires: golang(github.com/noahdesu/go-ceph/rados)
BuildRequires: golang(github.com/stevvooe/resumable)
BuildRequires: golang(github.com/stevvooe/resumable/sha256)
BuildRequires: golang(github.com/stevvooe/resumable/sha512)
BuildRequires: golang(golang.org/x/crypto/bcrypt)
BuildRequires: golang(golang.org/x/net/context)
BuildRequires: golang(gopkg.in/check.v1)
BuildRequires: golang(gopkg.in/yaml.v2)
%endif
Requires: golang(github.com/AdRoll/goamz/aws)
Requires: golang(github.com/AdRoll/goamz/cloudfront)
Requires: golang(github.com/AdRoll/goamz/s3)
Requires: golang(github.com/Azure/azure-sdk-for-go/storage)
Requires: golang(github.com/Sirupsen/logrus)
Requires: golang(github.com/denverdino/aliyungo/oss)
Requires: golang(github.com/docker/docker/pkg/tarsum)
Requires: golang(github.com/docker/libtrust)
Requires: golang(github.com/garyburd/redigo/redis)
Requires: golang(github.com/gorilla/handlers)
Requires: golang(github.com/gorilla/mux)
Requires: golang(github.com/mitchellh/mapstructure)
Requires: golang(github.com/ncw/swift)
Requires: golang(github.com/ncw/swift/swifttest)
Requires: golang(github.com/noahdesu/go-ceph/rados)
Requires: golang(github.com/stevvooe/resumable)
Requires: golang(github.com/stevvooe/resumable/sha256)
Requires: golang(github.com/stevvooe/resumable/sha512)
Requires: golang(golang.org/x/crypto/bcrypt)
Requires: golang(golang.org/x/net/context)
Requires: golang(gopkg.in/check.v1)
Requires: golang(gopkg.in/yaml.v2)
Provides: golang-%{provider}-%{project}-%{repo}-devel = %{version}-%{release}
Provides: golang(%{import_path}) = %{version}-%{release}
Provides: golang(%{import_path}/configuration) = %{version}-%{release}
Provides: golang(%{import_path}/context) = %{version}-%{release}
Provides: golang(%{import_path}/digest) = %{version}-%{release}
Provides: golang(%{import_path}/health) = %{version}-%{release}
Provides: golang(%{import_path}/health/api) = %{version}-%{release}
Provides: golang(%{import_path}/health/checks) = %{version}-%{release}
Provides: golang(%{import_path}/manifest) = %{version}-%{release}
Provides: golang(%{import_path}/notifications) = %{version}-%{release}
Provides: golang(%{import_path}/registry) = %{version}-%{release}
Provides: golang(%{import_path}/registry/api/errcode) = %{version}-%{release}
Provides: golang(%{import_path}/registry/api/v2) = %{version}-%{release}
Provides: golang(%{import_path}/registry/auth) = %{version}-%{release}
Provides: golang(%{import_path}/registry/auth/htpasswd) = %{version}-%{release}
Provides: golang(%{import_path}/registry/auth/silly) = %{version}-%{release}
Provides: golang(%{import_path}/registry/auth/token) = %{version}-%{release}
Provides: golang(%{import_path}/registry/client) = %{version}-%{release}
Provides: golang(%{import_path}/registry/client/auth) = %{version}-%{release}
Provides: golang(%{import_path}/registry/client/transport) = %{version}-%{release}
Provides: golang(%{import_path}/registry/handlers) = %{version}-%{release}
Provides: golang(%{import_path}/registry/listener) = %{version}-%{release}
Provides: golang(%{import_path}/registry/middleware/registry) = %{version}-%{release}
Provides: golang(%{import_path}/registry/middleware/repository) = %{version}-%{release}
Provides: golang(%{import_path}/registry/proxy) = %{version}-%{release}
Provides: golang(%{import_path}/registry/proxy/scheduler) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/cache) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/cache/memory) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/cache/redis) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/azure) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/base) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/factory) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/filesystem) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/inmemory) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/middleware) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/middleware/cloudfront) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/oss) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/rados) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/s3) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/swift) = %{version}-%{release}
Provides: golang(%{import_path}/registry/storage/driver/testsuites) = %{version}-%{release}
Provides: golang(%{import_path}/testutil) = %{version}-%{release}
Provides: golang(%{import_path}/uuid) = %{version}-%{release}
Provides: golang(%{import_path}/version) = %{version}-%{release}
%description devel
%{summary}
This package contains library source intended for
building other packages which use import path with
%{import_path} prefix.
%endif
%if 0%{?with_unit_test} && 0%{?with_devel}
%package unit-test
Summary: Unit tests for %{name} package
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} >= 1.6.2
%if 0%{?with_check}
#Here comes all BuildRequires: PACKAGE the unit tests
#in %%check section need for running
%endif
# test subpackage tests code from devel subpackage
Requires: %{name}-devel = %{version}-%{release}
%description unit-test
%{summary}
This package contains unit tests for project
providing packages with %{import_path} prefix.
%endif
%prep
%setup -q -n %{repo}-%{commit}
pushd vendor
sed -i 's/elliptic.P224(), //' golang.org/x/crypto/ocsp/ocsp.go
mkdir src
mv g* src/.
popd
%build
mkdir _build
pushd _build
mkdir -p src/github.com/%{project}
ln -s $(dirs +1 -l) src/%{import_path}
popd
%if ! 0%{?with_bundled}
export GOPATH=$(pwd)/_build:%{gopath}
%else
export GOPATH=$(pwd)/_build:$(pwd)/vendor:%{gopath}
%endif
pushd _build/src/%{import_path}/cmd/registry
go build .
popd
%install
install -d -p %{buildroot}%{_bindir}
install -p -m 0755 cmd/registry/registry %{buildroot}%{_bindir}
# install systemd/init scripts
install -d %{buildroot}%{_unitdir}
install -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}
# install config file
install -dp %{buildroot}%{_sysconfdir}/%{name}/registry
install -p -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{name}/registry
# install root dir
install -d %{buildroot}%{_sharedstatedir}/registry
# source code for building projects
%if 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
# find all *.go but no *_test.go files and generate devel.file-list
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
echo "%dir %{gopath}/src/%{import_path}/$(dirname $file)" >> devel.file-list
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%{gopath}/src/%{import_path}/$file" >> devel.file-list
done
%endif
# testing files for this project
%if 0%{?with_unit_test} && 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
# find all *_test.go files and generate unit-test.file-list
for file in $(find . -iname "*_test.go"); do
echo "%dir %{gopath}/src/%{import_path}/$(dirname $file)" >> devel.file-list
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%{gopath}/src/%{import_path}/$file" >> unit-test.file-list
done
%endif
%if 0%{?with_devel}
sort -u -o devel.file-list devel.file-list
%endif
%check
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
%if ! 0%{?with_bundled}
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
%else
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
%endif
make test
%endif
%pre
%post
%systemd_post %{name}.service
%preun
%systemd_preun %{name}.service
%postun
%systemd_postun_with_restart %{name}.service
#define license tag if not already defined
%{!?_licensedir:%global license %doc}
%files
%if 0%{?fedora} >= 23
%license LICENSE
%else
%doc LICENSE
%endif
%doc AUTHORS CONTRIBUTING.md MAINTAINERS README.md
%{_bindir}/registry
%{_unitdir}/%{name}.service
%dir %{_sharedstatedir}/registry
%config(noreplace) %{_sysconfdir}/%{name}/registry/config.yml
%if 0%{?with_devel}
%files devel -f devel.file-list
%license LICENSE
%doc CONTRIBUTING.md README.md ROADMAP.md AUTHORS
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
%dir %{gopath}/src/%{import_path}
%endif
%if 0%{?with_unit_test} && 0%{?with_devel}
%files unit-test -f unit-test.file-list
%license LICENSE
%doc CONTRIBUTING.md README.md ROADMAP.md AUTHORS
%endif
%changelog
* Thu Apr 27 2017 Frantisek Kluknavsky <fkluknav@redhat.com> - 2.6.1-1
- rebase to v2.6.1
* Mon Jan 23 2017 Frantisek Kluknavsky <fkluknav@redhat.com> - 2.6.0-1
- rebase to v2.6.0
* Mon Jan 09 2017 Frantisek Kluknavsky <fkluknav@redhat.com> - 2.5.1-2
- fix wrong obsoleting of docker-registry
* Mon Oct 24 2016 Frantisek Kluknavsky <fkluknav@redhat.com> - 2.5.1-1
- rebase to v2.5.1
* Wed Sep 07 2016 Lokesh Mandvekar <lsm5@redhat.com> - 2.5.0-1
- Resolves: #1367157 - rebase to v2.5.0
- golang 1.6.2 doesn't support elliptic.P224()
* Sat Jun 25 2016 Lokesh Mandvekar <lsm5@redhat.com> - 2.4.1-2
- built with golang >= 1.6.2
* Thu Apr 28 2016 Lokesh Mandvekar <lsm5@redhat.com> - 2.4.1-1
- Resolves: #1338871 - rebase to v2.4.1
- Resolves: #1338824 - s3 driver: Sorting completed parts by part number for
a better accordance with S3 spec (upstream PR# 1670)
* Thu Apr 28 2016 Lokesh Mandvekar <lsm5@redhat.com> - 2.4.0-2
- Resolves: #1330393 - update unitfile ExecStart
- From: Luwen Su <lsu@redhat.com>
* Tue Apr 19 2016 Lokesh Mandvekar <lsm5@redhat.com> - 2.4.0-1
- Resolves: rhbz#1328475 - rebase to v2.4.0
- Resolves: rhbz#1328526 - obsoletes docker-registry <= 0.9.1-7
* Tue Mar 08 2016 Lokesh Mandvekar <lsm5@redhat.com> - 2.3.1-1
- Resolves: rhbz#1315881 - rebase to v2.3.1
* Tue Jan 19 2016 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2.2.1-1
- Resolves: rhbz#1299915 - rebase to v2.2.1
* Wed Oct 07 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2.1.1-3
- do not install sysconfig file
- Install root dir /var/lib/registry
* Tue Sep 22 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2.1.1-2
- systemd is a dep
* Tue Sep 22 2015 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2.1.1-1
- Resolves: rhbz#1261613 (rhel 7.2) - initial package