File gitaly.spec of Package gitaly
#
# spec file for package gitlab-git-http-server
#
# Copyright (c) 2022 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/
#
%define gitaly_dir /usr/lib/gitlab/gitaly
%define gitaly_runtime_dir /var/lib/gitaly
%define pkg gitlab.com/gitlab-org/gitaly/v15
%bcond_without use_make
%global git_version 2.47
Name: gitaly
Version: 17.5.1
Release: 0
%define pkg_version %{version}
License: MIT
Summary: A Git RPC service for handling all the git calls made by GitLab
Url: https://gitlab.com/gitlab-org/gitaly/-/tags
Group: Development/Tools/Version Control
Source: https://gitlab.com/gitlab-org/gitaly/-/archive/v%{pkg_version}/gitaly-v%{pkg_version}.tar.bz2
Source1: vendor.tar.xz
Source2: %{name}.service
Source3: series
Patch: config.patch
Patch1: better_socket_path_v2.patch
Patch2: skip-log-format-parameter.patch
Patch3: use-prebuilt-binaries.patch
BuildRequires: golang-packaging
BuildRequires: golang(API) >= 1.17
BuildRequires: rsync
BuildRequires: gitlab-common >= 14.9.0
%requires_eq gitlab-common
Requires(pre): gitlab-common
BuildRequires: pkgconfig(systemd)
BuildRequires: git-core >= %{git_version}
BuildRequires: git-filter-repo
#
%go_nostrip
%description
Gitaly is a Git RPC service for handling all the git calls made by GitLab.
%prep
%autosetup -p1 -n %{name}-v%{pkg_version} -a 1
%build
export LC_ALL="en_US.UTF-8"
export LANG="$LC_ALL"
mkdir bin
export BUILDDATE="$(date -u +%%Y%%m%%d.%%H%%M%%S -r CHANGELOG.md )"
for binary in git git-remote-http git-http-backend ; do
install -v -D -m 0755 %{_libexecdir}/git/${binary} _build/bin/gitaly-${binary}-v%{git_version}
done
%if %{with use_make}
make V=1 VERBOSE=1 GIT_VERSION="$(rpm -q --qf '%{version}' git-core)"
%else
for i in gitaly-git2go-v15 gitaly-backup gitaly-blackbox gitaly-debug gitaly-hooks gitaly-lfs-smudge gitaly-ssh gitaly-wrapper praefect gitaly ; do
go build \
-tags="tracer_static,tracer_static_jaeger,tracer_static_stackdriver,continuous_profiler_stackdriver,static,system_libgit2" \
-mod=vendor \
-buildmode=pie \
-ldflags "-X %{pkg}/internal/version.version=%{version} -X %{pkg}/internal/version.buildtime=${BUILDDATE} -X %{pkg}/internal/version.moduleVersion=%{pkg}"\
-o ./_build/bin/$i ./cmd/$i
done
%endif
./_build/bin/gitaly -version
%install
install -d -m 0755 %{buildroot}%{gitaly_dir}/bin/ %{buildroot}%{_sbindir}
install -D -m 0755 _build/bin/* %{buildroot}%{gitaly_dir}/bin/
install -D -m 0644 %{S:2} %{buildroot}%{_unitdir}/%{name}.service
%if 0%{?suse_version}
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif
install -D -m 0640 config.toml.example %{buildroot}%{_sysconfdir}/gitaly/config.toml
chmod -R u=rwX,g=rX,o= %{buildroot}%{_sysconfdir}/gitaly/
find %{buildroot} -name spec -print0 | xargs -r0 rm -rv
install -D -d -m 0750 %{buildroot}%{gitaly_runtime_dir}
# START BIG SYSTEMD
%if 0%{?suse_version}
%pre
%service_add_pre %{name}.service
%endif
%preun
%if 0%{?suse_version}
%service_del_preun %{name}.service
%else
%systemd_preun %{name}.service
%endif
%post
for gitlab_yml in /srv/www/vhosts/gitlab-ce/config/gitlab.yml /etc/gitaly/config.toml ; do
if [ -e ${gitlab_yml} ] ; then
if grep -q %{_datadir}/gitlab/gitaly ${gitlab_yml} ; then
echo "patching path to gitaly in ${gitlab_yml}"
perl -p -i.update -e 's|%{_datadir}/gitlab/gitaly|%{gitaly_dir}|g' ${gitlab_yml}
diff -urN ${gitlab_yml}.update ${gitlab_yml} ||:
rm ${gitlab_yml}.update
fi
fi
done
# also fix bin_dir which now really needs /bin/ at the end
config_toml=/etc/gitaly/config.toml
if ! grep -q '^bin_dir = "/usr/lib/gitlab/gitaly/bin/"' ${config_toml} ; then
perl -p -i.update -e 's|^bin_dir = .*|bin_dir = "/usr/lib/gitlab/gitaly/bin/"|g' ${config_toml}
diff -urN ${config_toml}.update ${config_toml} ||:
rm ${config_toml}.update
fi
%if 0%{?suse_version}
%service_add_post %{name}.service
%else
%systemd_post %{name}.service
%endif
%postun
%if 0%{?suse_version}
%service_del_postun %{name}.service
%else
%systemd_postun_with_restart %{name}.service
%endif
%files
%defattr(-,root,root)
%license LICENSE
%doc NOTICE *.md doc/
%config(noreplace) %attr(-,root,gitlab) %{_sysconfdir}/gitaly/
%if 0%{?suse_version}
%{_sbindir}/rc%{name}
%endif
%{_unitdir}/%{name}.service
%{gitaly_dir}
%dir %attr(-,gitlab,gitlab) %{gitaly_runtime_dir}