ayaports/user/gitaly/APKBUILD

193 lines
5.2 KiB
Text

# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=gitaly
pkgver=15.3.3
pkgrel=1
pkgdesc="A Git RPC service for handling all the git calls made by GitLab"
url="https://gitlab.com/gitlab-org/gitaly/"
arch="all"
# GPL-2.0-only WITH GCC-exception-2.0: bundled libgit2
license="MIT AND GPL-2.0-only WITH GCC-exception-2.0"
depends="
git>=2.33
ruby
ruby-bigdecimal
ruby-bundler
ruby-io-console
ruby-json
"
makedepends="
bash
cmake
go
icu-dev
libffi-dev
libgit2-dev
libssh2-dev
libxml2-dev
libxslt-dev
ruby-dev
ruby-grpc=~1.42.0
zlib-dev
"
subpackages="
$pkgname-backup
$pkgname-blackbox
$pkgname-praefect
"
# FIXME: Makefile clones libgit2 and git repositories.
source="https://gitlab.com/gitlab-org/gitaly/-/archive/v$pkgver/gitaly-v$pkgver.tar.gz
gemfile-use-local-grpc.patch
config.patch
libgit-1.5-compat.patch
$pkgname.initd
"
builddir="$srcdir/$pkgname-v$pkgver"
options="!check"
export BUNDLE_DEPLOYMENT=true
export BUNDLE_FORCE_RUBY_PLATFORM=true
export BUNDLE_FROZEN=true
export BUNDLE_JOBS=${JOBS:-2}
export BUNDLE_WITHOUT="development test"
prepare() {
local sysgemdir=$(ruby -e 'puts Gem.default_dir')
default_prepare
# This Google gem is totally messed, so we copy our fixed version
# instead of installing it from RubyGems using Bundler.
mkdir -p ruby/vendor/grpc
cp -r "$sysgemdir"/gems/grpc-*/* ruby/vendor/grpc/
cp "$sysgemdir"/specifications/grpc-*.gemspec \
ruby/vendor/grpc/grpc.gemspec
cp "$sysgemdir"/extensions/*/*/grpc-*/grpc/*.so \
ruby/vendor/grpc/src/ruby/lib/grpc/
}
build() {
cd "$builddir"/ruby
bundle config --local build.ffi --enable-system-libffi
bundle config --local build.nokogiri --use-system-libraries \
--with-xml2-include=/usr/include/libxml2 \
--with-xslt-include=/usr/include/libxslt
# can't use system-library for some reason on 1.5.0 and 1.5.1
# bundle config --local build.rugged --use-system-libraries
# https://github.com/protocolbuffers/protobuf/issues/2335#issuecomment-579913357
bundle config --local build.google-protobuf --with-cflags=-D__va_copy=va_copy
bundle install --no-cache
touch '.ruby-bundle' # prevent 'make install' below from running 'bundle install' again
cd "$builddir"
# NOTE: This builds and links statically libgit2 with bundled deps.
cat > config.mak <<-EOF
PREFIX = /usr
GITALY_VERSION = "$pkgver"
# build without tracing libs, see
# https://gitlab.com/gitlab-org/labkit/-/merge_requests/2
SERVER_BUILD_TAGS = ""
EOF
make
}
package() {
local rubydir="$pkgdir/usr/lib/bundles/gitaly-ruby"
## Go part
make install DESTDIR="$pkgdir"
# Not very useful for us.
rm "$pkgdir"/usr/bin/gitaly-debug
rm "$pkgdir"/usr/bin/gitaly-wrapper
install -m644 -D config.toml.example "$pkgdir"/etc/gitlab/gitaly.toml
install -m644 -D config.praefect.toml.example "$pkgdir"/etc/gitlab/praefect.toml
install -m644 -D cmd/gitaly-blackbox/config.toml.example "$pkgdir"/etc/gitlab/gitaly-blackbox.toml
install -m755 -D "$srcdir"/gitaly.initd "$pkgdir"/etc/init.d/gitlab.gitaly
## Ruby part
mkdir -p "${rubydir%/*}"
cp -a ruby "$rubydir"
# Remove tests.
rm -R "$rubydir"/spec
cd "$rubydir"/vendor/bundle/ruby/*/gems
# Remove tests, docs and other unnecessary files.
rm -Rf \
./*/benchmark \
./*/spec \
./*/test \
./*/tests \
./*/appveyor.yml \
./*/*.md \
./*/*.rdoc \
./*/*.txt \
./*/CHANGELOG* \
./*/CHANGES* \
./*/CONTRIBUT* \
./*/*LICENSE* \
./*/Rakefile \
./*/README*
# Remove bundled libgit2 and pg_query sources.
rm -R rugged-*/vendor/libgit2
rm -R pg_query-*/ext
# Remove assets, they are not used in gitaly-ruby.
rm -R gemojione-*/assets
# Remove sources and binaries of native extensions (they are installed
# in extensions directory).
find . -type d -name ext -maxdepth 2 -exec rm -frv '{}' +
find . -name '*.so' -delete
# Remove build logs and cache.
rm -R ../build_info/ ../cache/
find ../extensions/ \
-name gem_make.out -delete \
-o -name mkmf.log -delete
}
backup() {
pkgdesc="Utility used by the backup Rake task to create/restore repository backups from Gitaly"
depends=""
amove usr/bin/gitaly-backup
}
# TODO: Add init script.
blackbox() {
pkgdesc="Prometheus exporter that measures GitLab server performance by performing a Git HTTP clone"
depends=""
amove etc/gitlab/gitaly-blackbox.toml
amove usr/bin/gitaly-blackbox
}
# TODO: Add init script.
praefect() {
pkgdesc="A reverse-proxy for Gitaly to manage a cluster of Gitaly nodes for HA"
depends=""
amove etc/gitlab/praefect.toml
amove usr/bin/praefect
}
sha512sums="
a3d4f929014df6f3e7034f493be9b27dcc1e820e42198582171a43c7ddf1bc9087329f13878f139a7d6dc1e6a92a76dabf26214409abe839d8f9508429f91ba0 gitaly-v15.3.3.tar.gz
ebcb7296696b9c2b47b7770a37ae13663cb0343659d482ef45717ef5548ede69eedee707763c6dfd73c60ef303e03fbe5502967783c59c00475a1a6d0c5ee128 gemfile-use-local-grpc.patch
8779e34b2a468a74c590ee29155e7b197eabcd323157b1e27208fa2f3100b31e1fd1ff80d7067198e66cfb1be506caedeecbfeb4e9f32aa5b8422455e1718e1a config.patch
c0c0fb03baefae34e117750c8b27ee67b18f8202161cbc202371d2f916ca419b82e5df0d5c3db23d9e2bb12d205e03dab51f61cd9e4ede2d0abe96de47c76e3f libgit-1.5-compat.patch
c32105d921be16eaf559cf21d6840bc346cd92b5e37974cedecdb5a2d2ca1eb5e8fbb144f5fc8a1289bf9415102b313cf2d61ee510c80f08ab33a799f5ac7122 gitaly.initd
"