File gitlab-container-registry.spec of Package gitlab-container-registry

#
# spec file for package gitlab-container-registry
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%global pkg_name container-registry
%global registry_dir %{_prefix}/lib/gitlab/registry
%global gitlab_container_registry_datadir /srv/%{name}

%define pkg_version %{version}

%bcond_without use_make

Name:           gitlab-container-registry
Version:        4.32.0
Release:        0
Summary:        Gitlab Container Registry
License:        MIT
Group:          Development/Tools/Version Control
URL:            https://gitlab.com/gitlab-org/container-registry/-/tags
Source:         https://gitlab.com/gitlab-org/container-registry/-/archive/v%{version}-gitlab/container-registry-v%{version}-gitlab.tar.bz2
Source1:        vendor.tar.xz
Source2:        series
Source3:        %{name}.sysusers
Patch1:         make-it-build.patch
BuildRequires:  gitlab-common >= 14.9.0
BuildRequires:  golang(API) >= 1.17
BuildRequires:  golang-packaging
BuildRequires:  pkgconfig
BuildRequires:  rsync
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
BuildRequires:  pkgconfig(systemd)
%requires_eq    gitlab-common
Requires(pre):  gitlab-common
%{sysusers_requires}
#
%{go_nostrip}

%description
Gitlab Container Registry

%prep
%autosetup -p1 -n %{pkg_name}-v%{pkg_version}-gitlab -a 1

%build
export LC_ALL="en_US.UTF-8"
export LANG="$LC_ALL"
mkdir bin
DATE_FMT="+%%Y-%%m-%%dT%%H:%%M:%%SZ"
BUILD_DATE=$(date -u -d "@${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u "${DATE_FMT}")
%make_build VERSION=%{version} REVISION=v%{version} BUILD_TIME=${BUILD_DATE}
%sysusers_generate_pre %{SOURCE6} %{name} %{name}.conf

rm -rv docs/{.vale,.markdownlint}

%check
./bin/registry --version

%install
install -d -m 0755 %{buildroot}%{registry_dir}/bin/
install -D -m 0755 bin/* %{buildroot}%{registry_dir}/bin/
install -D -m 0750 -d                  %{buildroot}%{_sysconfdir}/gitlab-container-registry/
chmod -R u=rwX,g=rX,o=                 %{buildroot}%{_sysconfdir}/gitlab-container-registry/
install -D -d -m 0750 %{buildroot}%{gitlab_container_registry_datadir}
install -Dpm0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf

%pre -f %{name}.pre

%files
%license LICENSE
%doc *.md
%doc configuration/
%doc docs/
%config(noreplace) %attr(-,root,%{name}) %{_sysconfdir}/gitlab-container-registry/
%{registry_dir}
%dir %attr(-,%{name},%{name}) %{gitlab_container_registry_datadir}
%{_sysusersdir}/%{name}.conf

%changelog
openSUSE Build Service is sponsored by