File gitlab-shell.spec of Package gitlab-shell

#
# Copyright (c) 2021 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 gitlab_shell_dir %{_prefix}/lib/gitlab/shell

Name:           gitlab-shell
Version:        14.41.0
Release:        0
License:        MIT
Summary:        GitLab Shell handles git commands for GitLab
Url:            https://gitlab.com/gitlab-org/gitlab-shell/-/tags
Group:          Development/Tools/Version Control
Source:         https://gitlab.com/gitlab-org/gitlab-shell/-/archive/v%{version}/gitlab-shell-v%{version}.tar.bz2
Source1:        vendor.tar.xz
Source99:       series
Patch1:         gitlab-shell-2.6.0_default_config.patch
Patch2:         pie.patch
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.19
BuildRequires:  pkgconfig(krb5)
%define rb_suffix         %{gitlab_rb_suffix}
BuildRequires:  %{rb_suffix}
%requires_ge    %{rb_suffix}
BuildRequires:  gitlab-common
%requires_eq    gitlab-common
BuildRequires:  rsync
%go_nostrip

%description
GitLab Shell handles git commands for GitLab and modifies the list of
authorized keys. GitLab Shell is not a Unix shell nor a replacement for Bash or
Zsh.

%prep
%autosetup -p1 -n %{name}-v%{version} -a 1

%build
ruby.%{rb_suffix} -r rubygems -p -i -e '$_.gsub!(/\A#!.*ruby/, "#!#{Gem.ruby}")' $(grep '#!.*ruby' -rl .)
make build VERSION_STRING=%{version} BUILD_TIME=$(date -u +%%Y%%m%%d.%%H%%M%%S -d @${SOURCE_DATE_EPOCH})

cp -av config.yml{.example,}

%install
install -d -m 0755 %{buildroot}%{gitlab_shell_dir}/
rsync -av Gemfile* VERSION bin config.yml* support  %{buildroot}%{gitlab_shell_dir}/

%post
for config in .gitlab_shell_secret config.yml ; do
if [ -e %{_datadir}/gitlab/shell/$config ] ; then
  echo "moving config from %{_datadir}/gitlab/shell/$config to %{gitlab_shell_dir}/$config"
  cp -a %{_datadir}/gitlab/shell/$config %{gitlab_shell_dir}/$configd
fi
done

for gitlab_yml in /srv/www/vhosts/gitlab-ce/config/gitlab.yml /etc/gitaly/config.toml /srv/gitlab/.ssh/authorized_keys; do
if [ -e ${gitlab_yml} ] ; then
  if grep -q %{_datadir}/gitlab/shell ${gitlab_yml} ; then
    echo "patching path to gitlab-shell in ${gitlab_yml}"
    perl -p -i.update -e 's|%{_datadir}/gitlab/shell|%{gitlab_shell_dir}|g' ${gitlab_yml}
    diff -urN ${gitlab_yml}.update ${gitlab_yml} ||:
  fi
fi
done

%files
%defattr(-,root,root)
%license LICENSE
%doc CHANGELOG *.md
%dir %{gitlab_shell_dir}/
%config(noreplace) %attr(640,root,gitlab) %{gitlab_shell_dir}/config.yml
%{gitlab_shell_dir}/config.yml.example
%{gitlab_shell_dir}/Gemfile
%{gitlab_shell_dir}/Gemfile.lock
%{gitlab_shell_dir}/VERSION
%{gitlab_shell_dir}/bin/
%{gitlab_shell_dir}/support/

%changelog
openSUSE Build Service is sponsored by