Blob Blame History Raw
# Generated by go2rpm 1.5.0
%bcond_without check

# Results in:
# ERROR: Source RPM is not installable:
# error: Missing rpmlib features for reg-0.16.1-7.el7.x86_64:
# error:  rpmlib(DynamicBuildRequires) <= 4.15.0-1
# when `0%%{?epel}` is used.
%if 0%{?rhel}
%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
%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
checks.}

%global golicenses      LICENSE
%global godocs          VERSION.txt README.md

Name:       reg
Release:    9%{?dist}
Summary:    Docker registry v2 command line client

License:    MIT
URL:        %{gourl}
Source0:    %{gosource}

# Upstream advertises this as something that's meant to be run in a container
# and doesn't provide a systemd unit or sysV init script or sysconfig files
# so I'm providing them here.
Source1:    reg-server.service
Source2:    sysconfig.reg-server

# https://github.com/genuinetools/reg/pull/200
Patch0: fix-row-cell-index-for-server-searching-feature.patch

%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

Obsoletes: reg-server < %{version}

%description
%{common_description}

%prep
%if 0%{?epel}
%setup -q -n %{name}-%{version}
%endif
%goprep %{?with_bundled:-k}
%patch0 -p1
%if %{without bundled}
# Use new docker/distribution import path
sed \
    -e 's|github.com/docker/distribution|github.com/distribution/distribution/v3|' \
    -i $(find . -name '*.go')
%endif

%if %{without bundled}
%generate_buildrequires
%go_generate_buildrequires
%endif

%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
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/

# Install templates and static content
mkdir -p %{buildroot}%{_sharedstatedir}/%{name}-server
install -d server/templates/ %{buildroot}/%{_sharedstatedir}/%{name}-server/templates/
install -d server/static/ %{buildroot}%{_sharedstatedir}/%{name}-server/static/
cp -p -r server/templates/* %{buildroot}%{_sharedstatedir}/%{name}-server/templates/
cp -p -r server/static/* %{buildroot}%{_sharedstatedir}/%{name}-server/static/

# Install the systemd unit
mkdir -p %{buildroot}%{_unitdir}
install -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}-server.service

# Install the sysconfig file
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
install -p -m 0640 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}-server

%post
%systemd_post %{name}-server.service

%preun
%systemd_preun %{name}-server.service

%postun
%systemd_postun %{name}-server.service

%files
%doc README.md Dockerfile Makefile
%license LICENSE
%{_bindir}/%{name}
%{_unitdir}/%{name}-server.service
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-server
%config(noreplace) %{_sharedstatedir}/%{name}-server/static/
%config(noreplace) %{_sharedstatedir}/%{name}-server/templates/

%changelog
* Tue Jul 19 2022 Maxwell G <gotmax@e.email> - 0.16.1-9
- Rebuild for CVE-2022-{1705,32148,30631,30633,28131,30635,30632,30630,1962} in
  golang

* Mon Jul 04 2022 Maxwell G <gotmax@e.email> - 0.16.1-8
- Fix FTBFS

* Sat Jun 18 2022 Robert-André Mauchin <zebob.m@gmail.com> - 0.16.1-7
- Rebuilt for CVE-2022-1996, CVE-2022-24675, CVE-2022-28327, CVE-2022-27191,
  CVE-2022-29526, CVE-2022-30629

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Sun Sep 19 2021 Robert-André Mauchin <zebob.m@gmail.com> - 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 <releng@fedoraproject.org> - 0.16.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue Feb 23 2021 Mattia Verga <mattia.verga@protonmail.com> - 0.16.1-3
- Use bundled modules for EPEL8

* Sun Feb 21 2021 Mattia Verga <mattia.verga@protonmail.com> - 0.16.1-2
- Use modules from Fedora repository where possible

* Sat Feb 20 2021 Mattia Verga <mattia.verga@protonmail.com> - 0.16.1-1
- Update to 0.16.1
- Fix FTB in F34
- Make use of some Golang macros

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.5-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.5-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Sun Jun 14 2020 Athos Ribeiro <athoscr@fedoraproject.org> - 0.15.5-6
- Fix image search

* Thu Apr 23 2020 Mattia Verga <mattia.verga@protonmail.com> - 0.15.5-5
- Fix %%postun directive

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Tue Oct 16 2018 Kevin Fenzi <kevin@scrye.com> - 0.15.5-1
- Update to 0.15.5

* Thu Jul 26 2018 Kevin Fenzi <kevin@scrye.com> - 0.15.4-1
- Update to 0.15.4.

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Thu Jun 29 2017 Adam Miller <maxamillion@fedoraproject.org> - 0.4.1-5
- Actually apply the patch for single-run execution

* Thu Jun 29 2017 Adam Miller <maxamillion@fedoraproject.org> - 0.4.1-4
- Fix epel7 build

* Tue Jun 27 2017 Adam Miller <maxamillion@fedoraproject.org> - 0.4.1-3
- Add patch to allow single-run execution of reg-server for static html
  generation

* Mon Jun 19 2017 Adam Miller <maxamillion@fedoraproject.org> - 0.4.1-2
- Add ghost file entry for statically generated index.html

* Mon Jun 12 2017 Adam Miller <maxamillion@fedoraproject.org> - 0.4.1-1
- Update to latest upstream
- Switch to using upstream versioning, they are tagging versions now.

* Tue Mar 21 2017 Adam Miller <maxamillion@fedoraproject.org> - 0.2.0-2.git.0.94d0af5
- Move static/templates and systemd workingdir to /var/lib/reg-server
- Change Source0 to point to github archive url instead of local git-archive
- Fix tabs vs spaces in the spec file

* Tue Mar 14 2017 Adam Miller <maxamillion@fedoraproject.org> - 0.2.0-1.git.0.94d0af5
- First package for Fedora