user/loomio: new aport #348

Merged
ayakael merged 8 commits from loomio/initial into edge 2024-01-12 05:01:08 +00:00
23 changed files with 1094 additions and 9 deletions

View file

@ -3,7 +3,7 @@
# Maintainer: wener <wenermail@gmail.com>
pkgname=grpc
pkgver=1.58.0
pkgrel=0
pkgrel=1
pkgdesc="The C based gRPC"
url="https://grpc.io/"
arch="all"
@ -22,7 +22,7 @@ _pythondepends="
"
_rubydepends="
$pkgname=$pkgver-r$pkgrel
ruby3.0-google-protobuf>=3.19
ruby3.2-google-protobuf>=3.19
"
makedepends="
abseil-cpp-dev
@ -38,7 +38,7 @@ makedepends="
openssl-dev>3
protobuf-dev
re2-dev
ruby3.0-dev
ruby3.2-dev
samurai
yaml-dev
xxhash-dev
@ -54,7 +54,7 @@ subpackages="
$pkgname-doc
py3-grpcio-pyc
py3-grpcio:grpcio
ruby3.0-grpc:_ruby
ruby3.2-grpc:_ruby
libaddress_sorting:lib
libgpr:lib
libgrpc:lib

196
user/loomio/APKBUILD Normal file
View file

@ -0,0 +1,196 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=loomio
pkgver=2.21.4
_gittag=v$pkgver
pkgrel=0
pkgdesc="A collaborative decision making tool"
url="https://github.com/loomio/loomio"
arch="x86_64"
license="MIT"
depends="
postgresql
postgresql-contrib
python3
redis
ruby3.2
ruby3.2-bundler
ruby3.2-grpc
vips
npm
procps-ng
"
makedepends="
cmd:chrpath
ruby3.2-dev
nodejs
openssl-dev
readline-dev
zlib-dev
libpq-dev
libffi-dev
imagemagick-dev
"
pkgusers="loomio"
pkggroups="loomio www-data"
install="$pkgname.pre-install $pkgname.post-install $pkgname.post-upgrade"
subpackages="$pkgname-openrc"
source="
$pkgname-$pkgver.tar.gz::https://github.com/loomio/loomio/archive/refs/tags/v$pkgver.tar.gz
bin-wrapper.in
loomio.confd
loomio.logrotate
loomio.sidekiq.initd
loomio.vue.initd
loomio.initd
"
_prefix="usr/lib/webapps/loomio"
export BUNDLE_DEPLOYMENT=true
export BUNDLE_FORCE_RUBY_PLATFORM=true
export BUNDLE_FROZEN=true
export BUNDLE_JOBS=${JOBS:-2}
prepare() {
local sysgemdir=$(ruby -e 'puts Gem.default_dir')
default_prepare
# Allow use of any bundler
sed -i -e '/BUNDLED/,+1d' Gemfile.lock
# Allow use of any platform
sed -i -e 's/PLATFORMS/PLATFORMS\n ruby/' Gemfile.lock
# Some gems are broken, so we copy our fixed version
# instead of installing it from RubyGems using Bundler.
mkdir -p vendor/gems/grpc/src/ruby/lib/grpc
cp -r "$sysgemdir"/gems/grpc-*/* vendor/gems/grpc/
cp "$sysgemdir"/specifications/grpc-*.gemspec \
vendor/gems/grpc/grpc.gemspec
cp "$sysgemdir"/extensions/*/*/grpc-*/grpc/*.so \
vendor/gems/grpc/src/ruby/lib/grpc/
}
build() {
local bundle_without='exclude development test'
bundle config --local build.ffi --enable-system-libffi
bundle config --local build.vips --enable-system-libraries
bundle config --local build.nokogiri --use-system-libraries \
--with-xml2-include=/usr/include/libxml2 \
--with-xslt-include=/usr/include/libxslt
bundle config --local build.google-protobuf '-- --with-cflags=-D__va_copy=va_copy'
msg "Installing Ruby gems..."
bundle config --local without "$bundle_without"
bundle config --local path "vendor/bundle"
bundle install --no-cache
msg "Precompiling static assets..."
bundle exec bootsnap precompile --gemfile app/ lib/
# Create executables in bin/*.
# See also https://github.com/bundler/bundler/issues/6149.
bundle binstubs --force bundler puma sidekiq
# Remove faulty RPATH.
chrpath -d vendor/bundle/ruby/*/gems/*/lib/nokogiri/*/nokogiri.so
# cp grpc so
cp vendor/gems/grpc/src/ruby/lib/grpc/grpc_c.so vendor/bundle/ruby/*/gems/grpc*/src/ruby/lib/grpc/.
rm -R vendor/bundle/ruby/*/gems/grpc*/src/ruby/lib/grpc/3* vendor/bundle/ruby/*/gems/grpc*/src/ruby/lib/grpc/2*
msg "Installing npm modules..."
cd vue
# force as vite-plugin-yaml hasn't updated their peerDependencies list yet
npm ci --force
npm run build
}
package() {
local destdir="$pkgdir/$_prefix"
local datadir="$pkgdir/var/lib/loomio"
local file dest
# Make directories
install -dm 755 \
"$(dirname $destdir)" \
"$datadir"
mkdir -p "$(dirname $destdir)"
cp -R "$builddir" "$destdir"
cd "$destdir"/vendor/bundle/ruby/*/
# Remove tests, documentations and other useless files.
find gems/ \( -name 'doc' \
-o -name 'spec' \
-o -name 'test' \) \
-type d -maxdepth 2 -exec rm -fr "{}" +
find gems/ \( -name 'README*' \
-o -name 'CHANGELOG*' \
-o -name 'CONTRIBUT*' \
-o -name '*LICENSE*' \
-o -name 'Rakefile' \
-o -name '.*' \) \
-type f -delete
# Remove build logs and cache.
rm -rf build_info/ cache/
find extensions/ \( -name gem_make.out -o -name mkmf.log \) -delete
cd "$destdir"
# Install and symlink config files.
for file in database.yml.postgresql puma.rb sidekiq.yml; do
dest="$(basename "${file/.postgresql/}")"
install -m640 -g loomio -D config/$file "$pkgdir"/etc/loomio/$dest
ln -sf /etc/loomio/$dest "$pkgdir"/$_prefix/config/${file/.postgrewsql/}
done
# This file will be generated by the post-install script, just prepare symlink.
ln -sf /etc/loomio/secrets.yml config/secrets.yml
# These shouldn't be necessary, they are all configurable, but OmniBus
cat > "$datadir"/.profile <<-EOF
export RAILS_ENV=production
export NODE_ENV=production
export EXECJS_RUNTIME=Disabled
EOF
# Install wrapper scripts to /usr/bin.
local name; for name in rake rails; do
sed "s/__COMMAND__/$name/g" "$srcdir"/bin-wrapper.in \
> "$builddir"/loomio-$name
install -m755 -D "$builddir"/loomio-$name "$pkgdir"/usr/bin/loomio-$name
done
for file in $pkgname $pkgname.sidekiq $pkgname.vue; do
install -m755 -D "$srcdir"/$file.initd "$pkgdir"/etc/init.d/$file
done
install -m644 -D "$srcdir"/loomio.confd \
"$pkgdir"/etc/conf.d/loomio
install -m644 -D "$srcdir"/loomio.logrotate \
"$pkgdir"/etc/logrotate.d/loomio
}
assets() {
depends=""
amove $_prefix/public/assets
}
sha512sums="
72a1238c1eaa3b963bd20a09d4fc2e52798264779bdf06d3f32891f2880d246059c77381329d1274bfa5979a35740017f0ced324f88b205369e77335b403ffba loomio-2.21.4.tar.gz
6cd4bb030660a9f4697eeb7c6de3f7509558aab3651e68218583dfeea56634f3b9f58acb50c7c9a4188a38c19434a815dd6c347e30207c4c0ae028c8dcb6ccaf bin-wrapper.in
0f1c91fbd4b8099f0a115705d5af799e4492fa2a0fd54175f3bfbfb5be1122bd7fd73a7709695c7caf2dcc667f3b8715051c24f424472e1115753e43a38fdf50 loomio.confd
1ecb0717cd5f04b894467b21d226b98d8f83b8f62afbf8da7edd57973aeabb13d121e9061cc48aec7572b1c710e82c8b44a1cedc0a924efd4bc4a124b3afe9a8 loomio.logrotate
c5dae2b6f9a23853c3c7ac068d97a7b0269b1775f6e0169c3d8999ec67c2baf3545515ea21037e882d900b15a7abf9061dd5a584bdc82c347b54d8c134f6d7a4 loomio.sidekiq.initd
f774954d8b06aacab27af9593b1b12fbe18ec2d0593dd4f82e4d3dfbc7e325fb1a423347fd974a2ec6665776a6cfe85f255f4fd7493c97eb840f34eb7fbdb329 loomio.vue.initd
645637c4112ec91ec2ea6022713e77a8ee76c0f0a81f9adf1f9210b52a578e94b5b02f0b6244b173905f580f72dc362b5434c714aae11e3619f73af223891bb8 loomio.initd
"

View file

@ -0,0 +1,15 @@
#!/bin/sh
BUNDLE_DIR='/usr/lib/webapps/loomio'
export RAILS_ENV='production'
export NODE_ENV='production'
export EXECJS_RUNTIME='Disabled'
cd $BUNDLE_DIR
install -m 700 -o loomio -g loomio -d "$(readlink ./tmp)"
if [ "$(id -un)" != 'loomio' ]; then
exec su loomio -c '"$0" "$@"' -- bin/__COMMAND__ "$@"
else
exec bin/__COMMAND__ "$@"
fi

32
user/loomio/loomio.confd Normal file
View file

@ -0,0 +1,32 @@
# Configuration file for /etc/init.d/loomio and
# /etc/init.d/loomio.{vue,sidekiq}
# Specify how many processes to create using sidekiq-cluster and which queue
# they should handle. Each whitespace-separated item equates to one additional
# Sidekiq process, and comma-separated values in each item determine the queues
# it works on. The special queue name "*" means all queues.
# Example: "* gitlab_shell process_commit,post_receive"
# See https://docs.gitlab.com/ee/administration/sidekiq/extra_sidekiq_processes.html.
#sidekiq_queue_groups="*"
# Maximum threads to use with Sidekiq (default: 50, 0 to disable).
#sidekiq_max_concurrency=
# Minimum threads to use with Sidekiq (default: 0).
#sidekiq_min_concurrency=
# The number of seconds to wait between worker checks.
#sidekiq_interval=
# Graceful timeout for all running processes.
#sidekiq_shutdown_timeout=
# Run workers for all queues in sidekiq_queues.yml except the given ones.
#sidekiq_negate=no
# Run workers based on the provided selector.
#sidekiq_queue_selector=no
# Memory limit (in MiB) for the Sidekiq process. If the RSS (Resident Set Size)
# of the Sidekiq process exceeds this limit, a delayed shutdown is triggered.
#sidekiq_memkiller_max_rss=2000

39
user/loomio/loomio.initd Normal file
View file

@ -0,0 +1,39 @@
#!/sbin/openrc-run
name="Loomio"
description="Meta script for starting/stopping all the Loomio components"
subservices="loomio.sidekiq loomio.vue"
depend() {
use net
}
start() {
local ret=0
ebegin "Starting all Loomio components"
local svc; for svc in $subservices; do
service $svc start || ret=1
done
eend $ret
}
stop() {
local ret=0
ebegin "Stopping all Loomio components"
local svc; for svc in $subservices; do
service $svc stop || ret=1
done
eend $ret
}
status() {
local ret=0
local svc; for svc in $subservices; do
echo "$svc:"
service $svc status || ret=1
done
eend $ret
}

View file

@ -0,0 +1,11 @@
/var/log/loomio/*.log {
compress
copytruncate
delaycompress
maxsize 10M
minsize 1M
missingok
sharedscripts
rotate 10
weekly
}

32
user/loomio/loomio.post-install Executable file
View file

@ -0,0 +1,32 @@
#!/bin/sh
set -eu
group=loomio
config_file='/etc/loomio/config.yml'
#if [ $(grep '@@SECRET_KEY@@' "$config_file") ]; then
# echo "* Generating random secret in $config_file" >&2
# secret_key="$(pwgen -s 50 1)"
# sed -i "s|@@SECRET_KEY@@|$secret_key|" "$config_file"
#fi
if [ "${0##*.}" = 'post-upgrade' ]; then
cat >&2 <<-EOF
*
* To finish Loomio upgrade run:
*
*
EOF
else
cat >&2 <<-EOF
*
* 1. Adjust settings in /etc/loomio/config.yml.
*
* 2. Create database for loomio:
*
* psql -c "CREATE ROLE loomio PASSWORD 'top-secret' INHERIT LOGIN;"
* psql -c "CREATE DATABASE loomio OWNER loomio ENCODING 'UTF-8';"
*
EOF
fi

View file

@ -0,0 +1 @@
loomio.post-install

View file

@ -0,0 +1,26 @@
#!/bin/sh
# It's very important to set user/group correctly.
loomio_dir='/var/lib/loomio'
if ! getent group loomio 1>/dev/null; then
echo '* Creating group loomio' 1>&2
addgroup -S loomio
fi
if ! id loomio 2>/dev/null 1>&2; then
echo '* Creating user loomio' 1>&2
adduser -DHS -G loomio -h "$loomio_dir" -s /bin/sh \
-g "added by apk for loomio" loomio
passwd -u loomio 1>/dev/null # unlock
fi
if ! id -Gn loomio | grep -Fq redis; then
echo '* Adding user loomio to group www-data' 1>&2
addgroup loomio www-data
fi
exit 0

View file

@ -0,0 +1,32 @@
#!/sbin/openrc-run
name="Loomio background workers Service"
root="/usr/share/webapps/loomio"
pidfile="/run/loomio-sidekiq.pid"
logfile="/var/log/loomio/sidekiq.log"
depend() {
use net
need redis
}
start() {
ebegin "Starting Loomio background workers"
cd $root
start-stop-daemon --start --background \
--chdir "${root}" \
--user="loomio" \
--make-pidfile --pidfile="${pidfile}" \
-1 "${logfile}" -2 "${logfile}" \
--exec /usr/bin/env -- RAILS_ENV=production bundle exec rails s
eend $?
}
stop() {
ebegin "Stopping Loomio background workers"
start-stop-daemon --stop \
--pidfile=${pidfile} \
eend $?
}

View file

@ -0,0 +1,31 @@
#!/sbin/openrc-run
name="$RC_SVCNAME"
cfgfile="/etc/conf.d/$RC_SVCNAME.conf"
pidfile="/run/$RC_SVCNAME.pid"
working_directory="/usr/share/bundles/loomio"
command="npm"
command_args="run serve"
command_user="loomio"
command_group="loomio"
start_stop_daemon_args=""
command_background="yes"
output_log="/var/log/loomio/$RC_SVCNAME.log"
error_log="/var/log/loomio/$RC_SVCNAME.err"
depend() {
need redis
need postgresql
}
start_pre() {
cd "$working_directory"
checkpath --directory --owner $command_user:$command_group --mode 0775 \
/var/log/loomio \
/var/lib/loomio
}
stop_pre() {
ebegin "Killing child processes"
kill $(ps -o pid= --ppid $(cat $pidfile)) || true
}

View file

@ -4,7 +4,7 @@ pkgname=protobuf
_gemname=google-protobuf
pkgver=23.4
_rubyver=3.23.4
pkgrel=1
pkgrel=2
pkgdesc="Library for extensible, efficient structure packing"
url="https://github.com/protocolbuffers/protobuf"
arch="all"
@ -23,14 +23,14 @@ makedepends="
$depends_dev
abseil-cpp-dev
cmake
ruby3.0
ruby3.0-dev
ruby3.0-rake
ruby3.2
ruby3.2-dev
ruby3.2-rake
samurai
"
checkdepends="gtest-dev"
subpackages="
ruby3.0-$_gemname:_ruby
ruby3.2-$_gemname:_ruby
$pkgname-dev
$pkgname-vim::noarch
protoc

View file

@ -0,0 +1,51 @@
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby3.2-bundler
_gemname=bundler
pkgver=2.3.26
pkgrel=0
pkgdesc="Manage an application's gem dependencies"
url="https://bundler.io/"
arch="noarch"
license="MIT"
depends="ruby3.2"
makedepends="ruby3.2-rake"
subpackages="$pkgname-doc"
source="https://github.com/rubygems/rubygems/archive/bundler-v$pkgver.tar.gz
manpages.patch
"
builddir="$srcdir/rubygems-bundler-v$pkgver/bundler"
options="!check" # tests require deps not available in main repo
build() {
rake build_metadata
gem build $_gemname.gemspec
}
package() {
local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
gem install \
--local \
--install-dir "$gemdir" \
--bindir "$pkgdir/usr/bin" \
--ignore-dependencies \
--no-document \
--verbose \
$_gemname
local n; for n in 1 5; do
mkdir -p "$pkgdir"/usr/share/man/man$n
mv "$gemdir"/gems/$_gemname-$pkgver/lib/bundler/man/*.$n "$pkgdir"/usr/share/man/man$n/
done
rm -rf "$gemdir"/cache \
"$gemdir"/build_info \
"$gemdir"/doc \
"$gemdir"/gems/$_gemname-$pkgver/man \
"$gemdir"/gems/$_gemname-$pkgver/*.md
}
sha512sums="
0a02d5130ecb8ca96e1850fc409a55d9f07481bbb8ec9b20554cdc6f3b3d3aada67717ab17dd30835615e4c228f39f895bd9b6f55bc22d4dbd88caef9cc105ba bundler-v2.3.26.tar.gz
77a36e61ed205aeea6114b1039dfbe29fcaf916eeae3f91785aa53b3ac534e004aa257e218534d927f39e3673eebbfb3ef9ee17f04ed81f74117799b88e53cf4 manpages.patch
"

View file

@ -0,0 +1,37 @@
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Fri, 26 Mar 2021 23:17:29 +0100
Subject: [PATCH] Fix --help when man pages are moved out
* Allow to move man pages from the gem's directory to the standard
system location (/usr/share/man) without breaking `bundler --help`.
* Fallback to the bundled ronn pages when the man command is available,
but the bundler man pages are not (i.e. ruby-bundler-doc is not
installed).
* Execute man with '-c' option to print the man page to the terminal
instead of using pager.
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -118,16 +118,17 @@
end
man_path = File.expand_path("man", __dir__)
- man_pages = Hash[Dir.glob(File.join(man_path, "**", "*")).grep(/.*\.\d*\Z/).collect do |f|
- [File.basename(f, ".*"), f]
+ man_pages = Hash[Dir.glob(File.join(man_path, "**", "*")).grep(/.*\.\d*\.ronn\Z/).collect do |f|
+ man_name = File.basename(f, ".ronn")
+ [File.basename(man_name, ".*"), man_name]
end]
if man_pages.include?(command)
man_page = man_pages[command]
- if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
- Kernel.exec "man #{man_page}"
+ if Bundler.which("man") && Kernel.system("man -w #{command} >/dev/null 2>&1") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
+ Kernel.exec "man -c #{command}"
else
- puts File.read("#{man_path}/#{File.basename(man_page)}.ronn")
+ puts File.read("#{man_path}/#{man_page}.ronn")
end
elsif command_path = Bundler.which("bundler-#{cli}")
Kernel.exec(command_path, "--help")

View file

@ -0,0 +1,66 @@
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby3.2-minitest
_gemname=minitest
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=5.15.0
pkgrel=1
pkgdesc="Suite of testing facilities supporting TDD, BDD, mocking, and benchmarking for Ruby"
url="https://github.com/minitest/minitest"
arch="noarch"
license="MIT"
depends="ruby3.2"
makedepends="ruby3.2-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/minitest/minitest/archive/v$pkgver/$_gemname-$pkgver.tar.gz
https://rubygems.org/downloads/$_gemname-$pkgver.gem
"
builddir="$srcdir/$_gemname-$pkgver"
prepare() {
default_prepare
# Generate gemspec (there's no gemspec in the source).
gem specification -l --ruby "$srcdir"/$_gemname-$pkgver.gem \
> "$builddir"/$_gemname.gemspec
}
build() {
gem build $_gemname.gemspec
}
check() {
ruby -Ilib -Itest -e "Dir.glob('./test/**/test_*.rb', &method(:require))"
}
package() {
local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
local geminstdir="$gemdir/gems/$_gemname-$pkgver"
gem install \
--local \
--install-dir "$gemdir" \
--ignore-dependencies \
--document ri \
--verbose \
$_gemname
# Remove unnessecary files
cd "$gemdir"
rm -rf build_info cache extensions plugins
cd "$geminstdir"
rm -rf History.* Manifest.* README.* Rakefile test/
}
doc() {
pkgdesc="$pkgdesc (ri docs)"
amove "$(ruby -e 'puts Gem.default_dir')"/doc
}
sha512sums="
194d074fa83a87b21f551f86d2bb682bcbac53d5a23d4e0f81fbf570427c5cdfcb27e10618bea69037f9e55bea637ed96e52a10808c586ab4020d788556bda71 minitest-5.15.0.tar.gz
5e97a7aa616966ffc60e10cdc0ba123a7e793f10283ec3b6bf36066177036788cb950ad566fbac49e613b93f08b9846534f463017cde966b4890c3a34a2286be minitest-5.15.0.gem
"

View file

@ -0,0 +1,15 @@
--- a/webrick.gemspec
+++ b/webrick.gemspec
@@ -14,12 +14,6 @@
s.require_path = %w{lib}
s.files = [
- "Gemfile",
- "LICENSE.txt",
- "README.md",
- "Rakefile",
- "bin/console",
- "bin/setup",
"lib/webrick.rb",
"lib/webrick/accesslog.rb",
"lib/webrick/cgi.rb",

View file

@ -0,0 +1,58 @@
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby3.2-rake
_gemname=rake
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=13.0.6
pkgrel=1
pkgdesc="A Ruby task runner, inspired by make"
url="https://github.com/ruby/rake"
arch="noarch"
license="MIT"
depends="ruby3.2"
checkdepends="ruby3.2-minitest"
makedepends="ruby3.2-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/rake/archive/v$pkgver/$_gemname-$pkgver.tar.gz"
builddir="$srcdir/$_gemname-$pkgver"
build() {
gem build $_gemname.gemspec
}
check() {
# FIXME: Fix test_signal_propagation_in_tests
ruby -Ilib -Itest -e "Dir.glob('./test/**/test_*.rb', &method(:require))" -- \
--exclude=test_signal_propagation_in_tests
}
package() {
local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
gem install \
--local \
--install-dir "$gemdir" \
--bindir "$pkgdir/usr/bin" \
--ignore-dependencies \
--document ri \
--verbose \
$_gemname
# Remove unnessecary files
cd "$gemdir"
rm -rf build_info cache extensions plugins
cd gems/rake-*
rm -rf doc ./*.rdoc MIT-LICENSE
}
doc() {
pkgdesc="$pkgdesc (ri docs)"
amove "$(ruby -e 'puts Gem.default_dir')"/doc
}
sha512sums="
1b438be96d8cedaf70e961b0bbd2217692b0b5537b2e1d5f599158e7da3e300cf6ab0c5f0c52fea89be0beb675effbbf563d24e55c84fb673b4982013355e03c rake-13.0.6.tar.gz
"

253
user/ruby3.2/APKBUILD Normal file
View file

@ -0,0 +1,253 @@
# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
#
# secfixes:
# 3.1.4-r0:
# - CVE-2023-28755
# - CVE-2023-28756
# 3.1.3-r0:
# - CVE-2021-33621
# 3.1.2-r0:
# - CVE-2022-28738
# - CVE-2022-28739
# 3.0.3-r0:
# - CVE-2021-41817
# - CVE-2021-41816
# - CVE-2021-41819
# 2.7.4-r0:
# - CVE-2021-31799
# - CVE-2021-31810
# - CVE-2021-32066
# 2.7.3-r0:
# - CVE-2021-28965
# - CVE-2021-28966
# 2.7.2-r0:
# - CVE-2020-25613
# 2.6.6-r0:
# - CVE-2020-10663
# - CVE-2020-10933
# 2.6.5-r0:
# - CVE-2019-16255
# - CVE-2019-16254
# - CVE-2019-15845
# - CVE-2019-16201
# 2.5.2-r0:
# - CVE-2018-16395
# - CVE-2018-16396
# 2.5.1-r0:
# - CVE-2017-17742
# - CVE-2018-6914
# - CVE-2018-8777
# - CVE-2018-8778
# - CVE-2018-8779
# - CVE-2018-8780
# 2.4.2-r0:
# - CVE-2017-0898
# - CVE-2017-10784
# - CVE-2017-14033
# - CVE-2017-14064
# - CVE-2017-0899
# - CVE-2017-0900
# - CVE-2017-0901
# - CVE-2017-0902
# 2.4.3-r0:
# - CVE-2017-17405
#
pkgname=ruby3.2
# When upgrading, upgrade also each ruby-<name> aport listed in file
# gems/bundled_gems. If some aport is missing or not in the main repo,
# create/move it.
pkgver=3.2.2
_abiver="${pkgver%.*}.0"
pkgrel=0
pkgdesc="An object-oriented language for quick and easy programming"
url="https://www.ruby-lang.org/"
arch="all"
license="Ruby AND BSD-2-Clause AND MIT"
depends="ca-certificates"
depends_dev="
$pkgname=$pkgver-r$pkgrel
$pkgname-rdoc=$pkgver-r$pkgrel
gmp-dev
libucontext-dev
"
makedepends="$depends_dev
autoconf
gdbm-dev
libffi-dev
linux-headers
openssl-dev>3
readline-dev
yaml-dev
zlib-dev
"
install="$pkgname.post-upgrade"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-dev
$pkgname-rdoc::noarch
$pkgname-libs
$pkgname-full::noarch
"
source="https://cache.ruby-lang.org/pub/ruby/${pkgver%.*}/ruby-$pkgver.tar.gz
test_insns-lower-recursion-depth.patch
fix-get_main_stack.patch
dont-install-bundled-gems.patch
fix-riscv64-build.patch
"
replaces="ruby3.2-gems"
builddir="$srcdir"/ruby-$pkgver
# For backward compatibility (pre 3.x).
for _i in bigdecimal etc fiddle gdbm io-console irb json; do
provides="$provides ruby3.2-$_i=$pkgver-r$pkgrel"
done
_gemdir="/usr/lib/ruby/gems/$_abiver"
_rubydir="/usr/lib/ruby/$_abiver"
_chost="${CHOST/-alpine-/-}"
case "$CARCH" in
x86) _arch="i386";;
*) _arch="$CARCH";;
esac
prepare() {
default_prepare
autoconf
# v2.7.1 - Of all the bootstraptest only test_fiber fails on s390x:
# test_fiber.rb bootstraptest.tmp.rb:8: [BUG] vm_call_cfunc: cfp consistency error (0x000003ffb63fefb0, 0x000003ffb42f5f58)
case "$CARCH" in
s390x) rm bootstraptest/test_fiber.rb;;
esac
local name ver; while read -r name ver _; do
case "$name=$ver" in
[a-z]*=[0-9]*.[0-9]*)
if ! apk add -qs "ruby-$name>=$ver" >/dev/null 2>&1; then
warning "bump package ruby-$name to version $ver"
fi
echo "ruby-$name>=$ver" >> "$srcdir"/.ruby-full.depends
esac
done < "$builddir"/gems/bundled_gems
}
build() {
# -fomit-frame-pointer makes ruby segfault, see gentoo bug #150413
# In many places aliasing rules are broken; play it safe
# as it's risky with newer compilers to leave it as it is.
# -O2 - ruby is a language runtime, so performance is crucial. Moreover,
# ruby 3.1.1 fails with Bus Error when compiled with -Os on armhf/armv7.
# This makes ruby-libs 7% bigger (13.4 -> 14.4 MiB).
export CFLAGS="${CFLAGS/-Os/-O2} -fno-omit-frame-pointer -fno-strict-aliasing"
export CPPFLAGS="${CPPFLAGS/-Os/-O2} -fno-omit-frame-pointer -fno-strict-aliasing"
# Needed for coroutine stuff
export LIBS="-lucontext"
# ruby saves path to install. we want use $PATH
export INSTALL=install
# the configure script does not detect isnan/isinf as macros
export ac_cv_func_isnan=yes
export ac_cv_func_isinf=yes
./configure \
--build=$CBUILD \
--host=$CHOST \
--prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--with-sitedir=/usr/local/lib/site_ruby \
--with-search-path="/usr/lib/site_ruby/\$(ruby_ver)/$_arch-linux" \
--enable-pthread \
--disable-rpath \
--enable-shared \
--with-mantype=man
make
}
check() {
# https://bugs.ruby-lang.org/issues/18380
local disable_tests="-n !/TestAddressResolve#test_socket_getnameinfo_domain_blocking/"
case "$CARCH" in
x86 | armhf | armv7)
# TestReadline#test_interrupt_in_other_thread fails on 32 bit arches according
# to upstream, but the test is disabled just on Travis, not in test suite.
# https://bugs.ruby-lang.org/issues/18393
disable_tests="$disable_tests -n !/TestReadline#test_interrupt_in_other_thread/"
;;
esac
make test TESTS="$disable_tests"
}
package() {
make DESTDIR="$pkgdir" SUDO="" install
install -m 644 -D COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
cd "$pkgdir"
# Remove bundled gem bundler; it's provided by a separate aport/package
# ruby-bundler.
rm -rf ./$_rubydir/bundler
rm ./$_rubydir/bundler.rb
rm -rf ./$_gemdir/gems/bundler-*
rm ./$_gemdir/specifications/default/bundler-*.gemspec
rm usr/bin/bundle usr/bin/bundler
# Remove bundled CA certificates; they are provided by ca-certificates.
rm ./$_rubydir/rubygems/ssl_certs/*/*.pem
rmdir ./$_rubydir/rubygems/ssl_certs/* || true
rm -Rf ./$_gemdir/cache/*
if [ -d usr/local ]; then
local f=$(find usr/local -type f)
if [ -n "$f" ]; then
error "Found files in /usr/local:"
echo "$f"
return 1
fi
rm -r usr/local
fi
}
rdoc() {
pkgdesc="Ruby documentation tool"
license="Ruby"
depends="$pkgname"
amove $_rubydir/rdoc
amove $_gemdir/gems/rdoc-*
amove $_gemdir/specifications/default/rdoc-*
amove usr/bin/ri
amove usr/bin/rdoc
}
libs() {
pkgdesc="Libraries necessary to run Ruby"
depends=""
amove usr/lib
}
full() {
pkgdesc="Ruby with all bundled gems"
# bundler is bundled since Ruby 2.6, so include it in ruby-full despite
# that it's provided by a seprate aport/package.
depends="ruby ruby-rdoc ruby-bundler $(cat "$srcdir"/.ruby-full.depends)"
mkdir -p "$subpkgdir"
}
sha512sums="
bcc68f3f24c1c8987d9c80b57332e5791f25b935ba38daf5addf60dbfe3a05f9dcaf21909681b88e862c67c6ed103150f73259c6e35c564f13a00f432e3c1e46 ruby-3.2.2.tar.gz
16fc1f35aee327d1ecac420b091beaa53c675e0504d5a6932004f17ca68a2c38f57b053b0a3903696f2232c5add160d363e3972a962f7f7bcb52e4e998c7315d test_insns-lower-recursion-depth.patch
42cd45c1db089a1ae57834684479a502e357ddba82ead5fa34e64c13971e7ab7ad2919ddd60a104a817864dd3e2e35bdbedb679210eb41d82cab36a0687e43d4 fix-get_main_stack.patch
a77da5e5eb7d60caf3f1cabb81e09b88dc505ddd746e34efd1908c0096621156d81cc65095b846ba9bdb66028891aefce883a43ddec6b56b5beb4aac5e4ee33f dont-install-bundled-gems.patch
000530316af1fca007fe8cee694b59e2e801674bcc1a2ebea95e67745d4afc0ce66c902fdbc88ee847a4fbf55115b183cd803cbf7c98ef685938efb3e2b7c991 fix-riscv64-build.patch
"

View file

@ -0,0 +1,20 @@
Don't install bundled gems - we package them separately.
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -990,6 +990,7 @@
end
end
+=begin XXX-Patched
install?(:ext, :comm, :gem, :'bundled-gems') do
gem_dir = Gem.default_dir
install_dir = with_destdir(gem_dir)
@@ -1057,6 +1058,7 @@
puts "skipped bundled gems: #{gems.join(' ')}"
end
end
+=end
parse_args()

View file

@ -0,0 +1,68 @@
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -858,9 +858,6 @@
# define MAINSTACKADDR_AVAILABLE 0
# endif
#endif
-#if MAINSTACKADDR_AVAILABLE && !defined(get_main_stack)
-# define get_main_stack(addr, size) get_stack(addr, size)
-#endif
#ifdef STACKADDR_AVAILABLE
/*
@@ -942,6 +939,55 @@
return 0;
#undef CHECK_ERR
}
+
+#if defined(__linux__) && !defined(__GLIBC__) && defined(HAVE_GETRLIMIT)
+
+#ifndef PAGE_SIZE
+#include <unistd.h>
+#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
+#endif
+
+static int
+get_main_stack(void **addr, size_t *size)
+{
+ size_t start, end, limit, prevend = 0;
+ struct rlimit r;
+ FILE *f;
+ char buf[PATH_MAX+80], s[8];
+ int n;
+ STACK_GROW_DIR_DETECTION;
+
+ f = fopen("/proc/self/maps", "re");
+ if (!f)
+ return -1;
+ n = 0;
+ while (fgets(buf, sizeof buf, f)) {
+ n = sscanf(buf, "%zx-%zx %*s %*s %*s %*s %7s", &start, &end, s);
+ if (n >= 2) {
+ if (n == 3 && strcmp(s, "[stack]") == 0)
+ break;
+ prevend = end;
+ }
+ n = 0;
+ }
+ fclose(f);
+ if (n == 0)
+ return -1;
+
+ limit = 100 << 20; /* 100MB stack limit */
+ if (getrlimit(RLIMIT_STACK, &r)==0 && r.rlim_cur < limit)
+ limit = r.rlim_cur & -PAGE_SIZE;
+ if (limit > end) limit = end;
+ if (prevend < end - limit) prevend = end - limit;
+ if (start > prevend) start = prevend;
+ *addr = IS_STACK_DIR_UPPER() ? (void *)start : (void *)end;
+ *size = end - start;
+ return 0;
+}
+#else
+# define get_main_stack(addr, size) get_stack(addr, size)
+#endif
+
#endif
static struct {

View file

@ -0,0 +1,38 @@
Patch-Source: https://lists.openembedded.org/g/openembedded-core/message/161168
partially extracted to actually apply onto a release tarball
---
From dfb22e4d6662bf72879eda806eaa78c7b52b519e Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 25 Jan 2022 20:29:14 -0800
Subject: [PATCH] vm_dump.c: Define REG_S1 and REG_S2 for musl/riscv
These defines are missing in musl, there is a possible
patch to add them to musl, but we need a full list of
these names for mcontext that can be added once for all
Upstream-Status: Inappropriate [musl bug]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
vm_dump.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/vm_dump.c b/vm_dump.c
index a98f5aa..957b785 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -39,6 +39,11 @@
#define MAX_POSBUF 128
+#if defined(__riscv) && !defined(__GLIBC__)
+# define REG_S1 9
+# define REG_S2 18
+#endif
+
#define VM_CFP_CNT(ec, cfp) \
((rb_control_frame_t *)((ec)->vm_stack + (ec)->vm_stack_size) - \
(rb_control_frame_t *)(cfp))
--
2.35.0

View file

@ -0,0 +1,17 @@
#!/bin/sh
ver_new="$1"
ver_old="$2"
if [ "$(apk version -t "$ver_old" "2.5.0-r0")" = "<" ]; then
cat >&2 <<-EOF
*
* In Ruby 2.5 more parts of the stdlib has been splitted into standalone
* gems, yet still installed with Ruby by default. We have moved some of
* them into separate subpackages. If you don't know which subpackages you
* need, you may install meta-package "ruby-full".
*
EOF
fi
exit 0

View file

@ -0,0 +1,47 @@
The patched test is a recursion function. We have lower stack size,
so we hit SystemStackError sooner than on other platforms.
#361 test_insns.rb:389:in `block in <top (required)>':
# recursive once
def once n
return %r/#{
if n == 0
true
else
once(n-1) # here
end
}/ox
end
x = once(128); x = once(7); x = once(16);
x =~ "true" && $~
#=> "" (expected "true") once
Stderr output is not empty
bootstraptest.tmp.rb:3:in `once': stack level too deep (SystemStackError)
from bootstraptest.tmp.rb:7:in `block in once'
from bootstraptest.tmp.rb:3:in `once'
from bootstraptest.tmp.rb:7:in `block in once'
from bootstraptest.tmp.rb:3:in `once'
from bootstraptest.tmp.rb:7:in `block in once'
from bootstraptest.tmp.rb:3:in `once'
from bootstraptest.tmp.rb:7:in `block in once'
from bootstraptest.tmp.rb:3:in `once'
... 125 levels...
from bootstraptest.tmp.rb:3:in `once'
from bootstraptest.tmp.rb:7:in `block in once'
from bootstraptest.tmp.rb:3:in `once'
from bootstraptest.tmp.rb:11:in `<main>'
Test_insns.rb FAIL 1/187
FAIL 1/1197 tests failed
Make: *** [uncommon.mk:666: yes-btest-ruby] Error 1
--- a/bootstraptest/test_insns.rb
+++ b/bootstraptest/test_insns.rb
@@ -274,7 +274,7 @@
end
}/ox
end
- x = once(128); x = once(7); x = once(16);
+ x = once(32); x = once(7); x = once(16);
x =~ "true" && $~
},
[ 'once', <<-'},', ], # {