A new user interface for you! Read more...

File gitaly.spec of Package gitaly

#
# spec file for package gitlab-git-http-server
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#

%if 0%{?suse_version} > 1230 || 0%{?rhel_version} > 6 || 0%{?centos_version} > 6 || 0%{?fedora_version} >= 20 || 0%{?el7}%{?fc20}%{?fc21}%{?fc22}%{?fc23}
%bcond_without systemd
%else
%bcond_with    systemd
%endif

%define gitaly_dir /usr/lib/gitlab/gitaly

Name:           gitaly
Version:        1.47.0
Release:        0
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%{version}/gitaly-v%{version}.tar.bz2
Source1:        vendor.tar.xz
Source2:        %{name}.service
Patch:          config.patch
Patch1:         better_socket_path.patch
Patch2:         use_correct_ruby.patch
Patch3:         fixdeps.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  git-core >= 2.21.0
Requires:       git-core >= 2.21.0
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.11
BuildRequires:  rsync
BuildRequires:  gitlab-common
Requires(pre):  gitlab-common
BuildRequires:  ruby-common-rails
%if %{with systemd}
BuildRequires:  pkgconfig(systemd)
%endif
%define rb_build_versions ruby26
%define rb_build_abi      ruby:2.6.0
%define rb_suffix    ruby2.6
#
BuildRequires:  %{rubygem bundler >= 2}
BuildRequires:  %{rubygem rugged:0 >= 0.28}
BuildRequires:  %{rubygem github-linguist:6 >= 6.1}
BuildRequires:  %{rubygem gitlab-markup:1.7 >= 1.7.0}
BuildRequires:  %{rubygem activesupport:5.1 >= 5.1.7}
BuildRequires:  %{rubygem gitaly-proto:1.32 >= 1.32.0}
BuildRequires:  %{rubygem rdoc:6 >= 6.1}
BuildRequires:  %{rubygem gitlab-gollum-lib:4.2.7 >= 4.2.7.7}
BuildRequires:  %{rubygem gitlab-gollum-rugged_adapter:0.4.4 >= 0.4.4.2}
BuildRequires:  %{rubygem grpc:1.19 >= 1.19.0}
BuildRequires:  %{rubygem sentry-raven:2.9 >= 2.9.0}
BuildRequires:  %{rubygem faraday:0 >= 0.12}
BuildRequires:  %{rubygem rbtrace}
BuildRequires:  %{rubygem gitlab-labkit:0.3 >= 0.3.0}
BuildRequires:  %{rubygem licensee:8.9 >= 8.9.0}
BuildRequires:  %{rubygem google-protobuf:3.7 >= 3.7.1}
#
%go_nostrip

%description
Gitaly is a Git RPC service for handling all the git calls made by GitLab.

%prep
%setup -q -n %{name}-v%{version} -a 1
%patch -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

%build
export LC_ALL="en_US.UTF-8"
export LANG="$LC_ALL"
ruby.%{rb_suffix} -r rubygems -p -i -e \
  '$_.gsub!(/\A#!.*ruby/, "#!#{Gem.ruby}")' \
  $(grep '#!.*ruby' -rl .)

ruby.%{rb_suffix}             -p -i -e \
  '$_.gsub!(/RUBY_SUFFIX/, "%{rb_suffix}")' \
  internal/linguist/linguist.go internal/rubyserver/rubyserver.go

PKG=gitlab.com/gitlab-org/gitaly
mkdir -p _build/src/${PKG}
tar -cf - --exclude _build --exclude .git . | (cd _build/src/${PKG} && tar -xf -)
pushd _build
export GO15VENDOREXPERIMENT=1
export GOPATH="$PWD"
export BUILDDATE="$(date -u +%%Y%%m%%d.%%H%%M%%S -r ../CHANGELOG.md )"
go install -mod=vendor -buildmode=pie -ldflags "-X ${PKG}/internal/version.version=%{version} -X ${PKG}/internal/version.buildtime=${BUILDDATE}" ${PKG}/cmd/{gitaly,gitaly-ssh}
popd
pushd ruby
mv Gemfile.lock{,.upstream}
%rails_write_appinfo
bundle.%{rb_suffix} exec bin/gitaly-ruby 0 /tmp/gitaly-ruby-test.socket ||:
diff -urN Gemfile.lock{.upstream,} || :
popd
cp ruby/README.md README.ruby.md

%install
install -d -m 0755 %{buildroot}%{gitaly_dir}/bin/ %{buildroot}%{_sbindir}
install -D -m 0755 _build/bin/%{name}                               %{buildroot}%{gitaly_dir}/bin/%{name}
install -D -m 0755 _build/bin/%{name}-ssh                           %{buildroot}%{gitaly_dir}/bin/%{name}-ssh
pushd ruby/
rsync -av ../VERSION .appinfo.yml bin Gemfile Gemfile.lock git-hooks lib gitlab-shell %{buildroot}%{gitaly_dir}/
popd
%if %{with systemd}
install -D -m 0644 %{S:2} %{buildroot}%{_unitdir}/%{name}.service
%if 0%{?suse_version}
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif
%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

# START BIG SYSTEMD
%if %{with 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
%endif
# /END BIG SYSTEMD

%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}