From 021f321f3d59157282edb67aba668f4a0ce52c12 Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Sep 19 2021 16:30:08 +0000 Subject: Fix vendoring for devel package Make compatible with EPEL8 Close: rhbz#1941017, rhbz#1933618 --- diff --git a/reg.spec b/reg.spec index b8206cc..901654e 100644 --- a/reg.spec +++ b/reg.spec @@ -1,9 +1,43 @@ +# Generated by go2rpm 1.5.0 +%bcond_without check + +%if 0%{?epel} +%bcond_without bundled +%endif + +# Redefine macros for EPEL +%if 0%{?epel} + %global gobuilddir %{_builddir}/%{name}-%{version}/_build + %global gourl https://%{goipath} + %global gosource %{gourl}/archive/v%{version}/%{name}-%{version}.tar.gz + %define gobuild(o:) %{expand: + # https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12 + %global _dwz_low_mem_die_limit 0 + %ifnarch ppc64 + go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false" -a -v -x %{?**}; + %else + go build -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}' -compressdwarf=false" -a -v -x %{?**}; + %endif + } + %define goprep(:k) %{expand: + if [[ ! -e "%{gobuilddir}/bin" ]] ; then + install -m 0755 -vd "%{gobuilddir}/bin" + export GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}/usr/share/gocode" + fi + if [[ ! -e "%{gobuilddir}/src/%{goipath}" ]] ; then + install -m 0755 -vd "$(dirname %{gobuilddir}/src/%{goipath})" + ln -fs "%{_builddir}/%{name}-%{version}" "%{gobuilddir}/src/%{goipath}" + fi + } +%endif + # https://github.com/genuinetools/reg -# EPEL build is curently broken due to golang macros not working %global goipath github.com/genuinetools/reg Version: 0.16.1 +%if !0%{?epel} %gometa +%endif %global common_description %{expand: Docker registry v2 command line client and repo listing generator with security @@ -13,10 +47,9 @@ checks.} %global godocs VERSION.txt README.md Name: reg -Release: 4%{?dist} +Release: 5%{?dist} Summary: Docker registry v2 command line client - License: MIT URL: %{gourl} Source0: %{gosource} @@ -30,90 +63,44 @@ Source2: sysconfig.reg-server # https://github.com/genuinetools/reg/pull/200 Patch0: fix-row-cell-index-for-server-searching-feature.patch -BuildRequires: golang -BuildRequires: systemd-rpm-macros -BuildRequires: golang-ipath(golang.org/x/net) -BuildRequires: golang-ipath(golang.org/x/sys) -BuildRequires: golang-ipath(golang.org/x/text) - -# These are not packaged in EPEL -%if 0%{!?epel} -BuildRequires: golang-ipath(github.com/Azure/go-ansiterm) -BuildRequires: golang-ipath(github.com/containerd/containerd) -BuildRequires: golang-ipath(github.com/davecgh/go-spew) -BuildRequires: golang-ipath(github.com/deckarep/golang-set) -BuildRequires: golang-ipath(github.com/docker/cli) -BuildRequires: golang-ipath(github.com/docker/distribution) -BuildRequires: golang-ipath(github.com/docker/docker) -BuildRequires: golang-ipath(github.com/docker/docker-credential-helpers) -BuildRequires: golang-ipath(github.com/docker/go-connections) -BuildRequires: golang-ipath(github.com/docker/go-units) -BuildRequires: golang-ipath(github.com/docker/libtrust) -BuildRequires: golang-ipath(github.com/fernet/fernet-go) -BuildRequires: golang-ipath(github.com/gogo/protobuf) -BuildRequires: golang-ipath(github.com/golang/protobuf) -BuildRequires: golang-ipath(github.com/google/go-cmp) -BuildRequires: golang-ipath(github.com/gorilla/mux) -BuildRequires: golang-ipath(github.com/grpc-ecosystem/grpc-gateway) -BuildRequires: golang-ipath(github.com/mitchellh/go-wordwrap) -BuildRequires: golang-ipath(github.com/morikuni/aec) -BuildRequires: golang-ipath(github.com/opencontainers/go-digest) -BuildRequires: golang-ipath(github.com/opencontainers/image-spec) -BuildRequires: golang-ipath(github.com/opencontainers/runc) -BuildRequires: golang-ipath(github.com/pkg/errors) -BuildRequires: golang-ipath(github.com/pmezard/go-difflib) -BuildRequires: golang-ipath(github.com/shurcooL/httpfs) -BuildRequires: golang-ipath(github.com/sirupsen/logrus) -BuildRequires: golang-ipath(github.com/stretchr/testify) -BuildRequires: golang-ipath(google.golang.org/genproto) -BuildRequires: golang-ipath(google.golang.org/grpc) +%if 0%{?epel} +ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}} +BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} +%endif + +%if 0%{?epel} && 0%{?epel} < 8 +BuildRequires: systemd +%else +BuildRequires: systemd-rpm-macros %endif -# The following section is populated by parsing the modules.txt file -# in the vendor dir of the source code. -# -# Bundled Provides are defined as per Fedora Guidelines: -# https://fedoraproject.org/wiki/Packaging:Guidelines#Bundling_and_Duplication_of_system_libraries -# -Provides: bundled(golang(github.com/coreos/clair)) = 2.0.1-0.20190910143208 -Provides: bundled(golang(github.com/genuinetools/pkg)) = 0.0.0-20181022210355 -Provides: bundled(golang(github.com/konsorten/go-windows-terminal-sequences)) = 1.0.1 -Provides: bundled(golang(github.com/Microsoft/go-winio)) = 0.4.14 -Provides: bundled(golang(github.com/Microsoft/hcsshim)) = 0.8.6 -Provides: bundled(golang(github.com/peterhellberg/link)) = 1.0.0 - -# These are not packaged in EPEL -# We will use the bundled modules -%if 0%{?epel} -Provides: bundled(golang(github.com/Azure/go-ansiterm)) = 0.0.0-20170929234023 -Provides: bundled(golang(github.com/containerd/containerd)) = 1.2.9 -Provides: bundled(golang(github.com/davecgh/go-spew)) = 1.1.1 -Provides: bundled(golang(github.com/deckarep/golang-set)) = 1.7.1 -Provides: bundled(golang(github.com/docker/cli)) = 0.0.0-20190913211141 -Provides: bundled(golang(github.com/docker/distribution)) = 2.7.1 -Provides: bundled(golang(github.com/docker/docker)) = 1.4.2-0.20190916154449 -Provides: bundled(golang(github.com/docker/docker-credential-helpers)) = 0.6.3 -Provides: bundled(golang(github.com/docker/go-connections)) = 0.4.0 -Provides: bundled(golang(github.com/docker/go-units)) = 0.4.0 -Provides: bundled(golang(github.com/docker/libtrust)) = 0.0.0-20160708172513 -Provides: bundled(golang(github.com/fernet/fernet-go)) = 0.0.0-20180830025343 -Provides: bundled(golang(github.com/gogo/protobuf)) = 1.3.0 -Provides: bundled(golang(github.com/golang/protobuf)) = 1.2.0 -Provides: bundled(golang(github.com/google/go-cmp)) = 0.3.1 -Provides: bundled(golang(github.com/gorilla/mux)) = 1.7.3 -Provides: bundled(golang(github.com/grpc-ecosystem/grpc-gateway)) = 1.11.1 -Provides: bundled(golang(github.com/mitchellh/go-wordwrap)) = 1.0.0 -Provides: bundled(golang(github.com/morikuni/aec)) = 0.0.0-20170113033406 -Provides: bundled(golang(github.com/opencontainers/go-digest)) = 1.0.0-rc1 -Provides: bundled(golang(github.com/opencontainers/image-spec)) = 1.0.1 -Provides: bundled(golang(github.com/opencontainers/runc)) = 0.1.1 -Provides: bundled(golang(github.com/pkg/errors)) = 0.8.1 -Provides: bundled(golang(github.com/pmezard/go-difflib)) = 1.0.0 -Provides: bundled(golang(github.com/shurcooL/httpfs)) = 0.0.0-20190707220628 -Provides: bundled(golang(github.com/sirupsen/logrus)) = 1.4.2 -Provides: bundled(golang(github.com/stretchr/testify)) = 1.2.2 -Provides: bundled(golang(google.golang.org/genproto)) = 0.0.0-20180817151627 -Provides: bundled(golang(google.golang.org/grpc)) = 1.23.1 +%if %{without bundled} +BuildRequires: golang(github.com/coreos/clair/api/v3/clairpb) +BuildRequires: golang(github.com/docker/cli/cli/config) +BuildRequires: golang(github.com/docker/cli/cli/config/types) +BuildRequires: golang(github.com/docker/distribution) +BuildRequires: golang(github.com/docker/distribution/manifest/manifestlist) +BuildRequires: golang(github.com/docker/distribution/manifest/schema1) +BuildRequires: golang(github.com/docker/distribution/manifest/schema2) +BuildRequires: golang(github.com/docker/distribution/reference) +BuildRequires: golang(github.com/docker/docker/api/types) +BuildRequires: golang(github.com/docker/docker/api/types/container) +BuildRequires: golang(github.com/docker/docker/client) +BuildRequires: golang(github.com/docker/docker/pkg/jsonmessage) +BuildRequires: golang(github.com/docker/docker/pkg/term) +BuildRequires: golang(github.com/genuinetools/pkg/cli) +BuildRequires: golang(github.com/gorilla/mux) +BuildRequires: golang(github.com/mitchellh/go-wordwrap) +BuildRequires: golang(github.com/opencontainers/go-digest) +BuildRequires: golang(github.com/peterhellberg/link) +BuildRequires: golang(github.com/shurcooL/httpfs/html/vfstemplate) +BuildRequires: golang(github.com/sirupsen/logrus) +BuildRequires: golang(google.golang.org/grpc) + +%if %{with check} +# Tests +BuildRequires: golang(github.com/google/go-cmp/cmp) +%endif %endif Obsoletes: reg-server < %{version} @@ -121,49 +108,24 @@ Obsoletes: reg-server < %{version} %description %{common_description} -%gopkg - %prep +%if 0%{?epel} %setup -q -n %{name}-%{version} -%patch0 -p1 - -# Do not remove 'vendor' dir entirely -%goprep -ke - -# Remove bundled modules packaged in Fedora -rm -rf vendor/golang.org - -%if 0%{!?epel} -rm -rf vendor/github.com/Azure -rm -rf vendor/github.com/containerd -rm -rf vendor/github.com/davecgh -rm -rf vendor/github.com/deckarep -rm -rf vendor/github.com/docker -rm -rf vendor/github.com/fernet -rm -rf vendor/github.com/gogo -rm -rf vendor/github.com/golang -rm -rf vendor/github.com/google -rm -rf vendor/github.com/gorilla -rm -rf vendor/github.com/grpc-ecosystem -rm -rf vendor/github.com/mitchellh -rm -rf vendor/github.com/morikuni -rm -rf vendor/github.com/opencontainers -rm -rf vendor/github.com/pkg -rm -rf vendor/github.com/pmezard -rm -rf vendor/github.com/shurcooL -rm -rf vendor/github.com/sirupsen -rm -rf vendor/github.com/stretchr -rm -rf vendor/google.golang.org %endif +%goprep %{?with_bundled:-k} +%patch0 -p1 %build +# When vendoring, use Go modules +%if %{with bundled} +%global gomodulesmode GO111MODULE=on +export GO111MODULE=on +export GOFLAGS=-mod=vendor +%endif %gobuild -o %{gobuilddir}/bin/reg %{goipath} - %install - # Install the binaries -%gopkginstall install -m 0755 -vd %{buildroot}%{_bindir} install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ @@ -182,7 +144,6 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}-server.service mkdir -p %{buildroot}%{_sysconfdir}/sysconfig install -p -m 0640 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-server - %post %systemd_post %{name}-server.service @@ -192,7 +153,6 @@ install -p -m 0640 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-serve %postun %systemd_postun %{name}-server.service - %files %doc README.md Dockerfile Makefile %license LICENSE @@ -202,9 +162,12 @@ install -p -m 0640 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-serve %config(noreplace) %{_sharedstatedir}/%{name}-server/static/ %config(noreplace) %{_sharedstatedir}/%{name}-server/templates/ -%gopkgfiles - %changelog +* Sun Sep 19 2021 Robert-André Mauchin - 0.16.1-5 +- Fix vendoring for devel package +- Make compatible with EPEL8 +- Close: rhbz#1941017, rhbz#1933618 + * Fri Jul 23 2021 Fedora Release Engineering - 0.16.1-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild