62.2. ruby-4.0.7
The Ruby programming language
| Version | 4.0.7, release 2 |
| Shelf | lang — Language implementations, plus the modules of any language that has no module shelf of its own |
| Phase | 31_compilers (Compilers), 14 of 22 in build order |
| Licence | Ruby OR BSD-2-Clause |
| Homepage | https://www.ruby-lang.org/ |
| Build time | 7.5 SBU |
| Installed size | 37.5 MiB in 2924 files |
| Recipe | ports/core/lang/ruby/kpkgbuild |
About
This port is the Ruby interpreter, ruby, with gem, irb, erb, rdoc, bundler and the standard library. In KDOS it is mostly a build tool: asciidoctor, which many ports generate their manual pages with, is a Ruby program, and mkvtoolnix builds with Ruby’s rake (its drake wrapper). weechat embeds it for Ruby scripts, and webkitgtk, webkitgtk6 and ocl-icd name it in depends. It is built in 31_compilers, after rust, which it needs for YJIT.
Sources
ruby-4.0.7.tar.xz(17.2 MiB)
sha25647ef59413f7a4587ba6a6b78b14036eb5e36eec2ec0b90964801e88d56a3d375
upstream: https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.7.tar.xz
archive copy: sources-3/lang--ruby-4.0.7.tar.xz
Dependencies
Depends on: openssl, zlib, libffi, yaml, gmp, rust.
Required by (6): asciidoctor, mkvtoolnix, ocl-icd, webkitgtk, webkitgtk6, weechat.
Patches
build.sh applies these; kpkg applies nothing by itself.
musl-main-stack.patch— on a Linux C library that is not glibc, measures the main thread’s stack from the[stack]line of/proc/self/maps, bounded byRLIMIT_STACK(at most 100 MB) and by the mapping below it, instead of askingpthread_getattr_np(). musl answers that call with the part of the stack mapped so far, a few pages at start-up, and Ruby takes it as the whole stack, so a recursion that re-enters the interpreter from C, such as a block called bymapor a nested parse, raisesSystemStackErrorshort of a thousand levels under an 8 MB limit.pc-libs-no-ldflags.patch— removes${DLDFLAGS}from theLibs:line ofruby.pc, sopkg-config --libs rubygives a program that embeds Ruby the library and its dependencies only, not the linker flags Ruby itself was built with (the tree’sLDFLAGSand--compress-debug-sections=zlib).
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/31_compilers/phase.env && kpkg install ruby'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/lang/ruby.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/lang/ruby
echo '47ef59413f7a4587ba6a6b78b14036eb5e36eec2ec0b90964801e88d56a3d375 ruby-4.0.7.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/ruby
SRC=$SRC_ROOT/ruby-4.0.7
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf ruby-4.0.7.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/musl-main-stack.patch"
patch -p1 -i "$PORT_SRC/pc-libs-no-ldflags.patch"
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/share/man \
--enable-shared \
--disable-rpath \
--disable-install-doc \
--enable-yjit \
--disable-zjit \
--with-gmp \
--with-mantype=man
make
make DESTDIR=$PKG install
strip --strip-debug "$PKG/usr/lib/libruby.so.$version"
for ext in openssl psych zlib fiddle; do
if ! find "$PKG/usr/lib/ruby" -name "$ext.so" | grep -q .; then
echo "ruby: extension '$ext' was not built" >&2
exit 1
fi
done
find "$PKG/usr/share/man" -name '*.gz' -exec gunzip {} +
for page in "$PKG"/usr/lib/ruby/*/bundler/man/*.[1-8] \
"$PKG"/usr/lib/ruby/gems/*/gems/irb-*/man/*.[1-8] \
"$PKG"/usr/lib/ruby/gems/*/gems/rdoc-*/man/*.[1-8]; do
install -Dm644 "$page" -t "$PKG/usr/share/man/man${page##*.}"
done
rm -rf "$PKG"/usr/lib/ruby/gems/*/cache
The switches, and why each is set:
--enable-shared— buildlibruby.soand linkrubyagainst it, so programs that embed Ruby,weechat’s plugin among them, share the interpreter’s library. On Linux upstream’s default is a staticlibruby, linked intorubyitself.--disable-rpath— do not embed a run path inrubyand the extension libraries; they findlibruby.soin/usr/liblike any other library.--disable-install-doc— do not generate the rdoc and ri indexes, whichmake installwould build by running rdoc over the whole standard library. The manual pages underman/still install.--enable-yjit— build YJIT, Ruby’s just-in-time compiler, written in Rust.configureturns it on by itself whenever it finds a recent enoughrustc, so naming it makes the interpreter the same whether or notrusthappens to be in the chroot;rustis independs, so it always is. YJIT is off at run time untilruby --yjitorRUBY_YJIT_ENABLE=1turns it on for a process.--disable-zjit— leave out ZJIT, Ruby’s experimental method JIT, also written in Rust.configurewould otherwise build it whenever therustcit finds compiles Rust’s 2024 edition andmakeis GNU make.--with-gmp— use GMP to speed up arithmetic on large integers (Integervalues beyond a machine word). This is the default, andconfigureuses GMP only if it findsgmp.h; without the header it builds Ruby’s own bignum code with no warning, so thegmpport is independs. The build log showschecking for library containing __gmpz_init... -lgmp.--with-mantype=man— write the manual pages asman(7)macros, converted from themdocsources by Ruby’s installer. Without it,configurechooses betweenmananddocby probing thenroffit finds.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/ruby, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf ruby-4.0.7-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/ruby, and runs the triggers its paths call for.
Contents
Installed programs: bundle, bundler, erb, gem, irb, minitest, racc, rake, rbs, rdbg, rdoc, ri, ruby, syntax_suggest, test-unit, typeprof.
Installed libraries: libruby.so.
Installed directories: /usr/include/ruby-4.0.0, /usr/lib/ruby/4.0.0, /usr/lib/ruby/gems/4.0.0/extensions/x86_64-linux-musl, /usr/lib/ruby/gems/4.0.0/gems/abbrev-0.1.2, /usr/lib/ruby/gems/4.0.0/gems/base64-0.3.0, /usr/lib/ruby/gems/4.0.0/gems/benchmark-0.5.0, /usr/lib/ruby/gems/4.0.0/gems/bigdecimal-4.0.1, /usr/lib/ruby/gems/4.0.0/gems/bundler-4.0.20, /usr/lib/ruby/gems/4.0.0/gems/csv-3.3.5, /usr/lib/ruby/gems/4.0.0/gems/date-3.5.1, /usr/lib/ruby/gems/4.0.0/gems/debug-1.11.1, /usr/lib/ruby/gems/4.0.0/gems/delegate-0.6.1, /usr/lib/ruby/gems/4.0.0/gems/did_you_mean-2.0.0, /usr/lib/ruby/gems/4.0.0/gems/digest-3.2.1, /usr/lib/ruby/gems/4.0.0/gems/drb-2.2.3, /usr/lib/ruby/gems/4.0.0/gems/english-0.8.1, /usr/lib/ruby/gems/4.0.0/gems/erb-6.0.7, /usr/lib/ruby/gems/4.0.0/gems/error_highlight-0.7.2, /usr/lib/ruby/gems/4.0.0/gems/etc-1.4.6, /usr/lib/ruby/gems/4.0.0/gems/fcntl-1.3.0, /usr/lib/ruby/gems/4.0.0/gems/fiddle-1.1.8, /usr/lib/ruby/gems/4.0.0/gems/fileutils-1.8.0, /usr/lib/ruby/gems/4.0.0/gems/find-0.2.0, /usr/lib/ruby/gems/4.0.0/gems/forwardable-1.4.0, /usr/lib/ruby/gems/4.0.0/gems/getoptlong-0.2.1, /usr/lib/ruby/gems/4.0.0/gems/io-console-0.8.2, /usr/lib/ruby/gems/4.0.0/gems/io-nonblock-0.3.2, /usr/lib/ruby/gems/4.0.0/gems/io-wait-0.4.0, /usr/lib/ruby/gems/4.0.0/gems/ipaddr-1.2.8, /usr/lib/ruby/gems/4.0.0/gems/irb-1.16.0, /usr/lib/ruby/gems/4.0.0/gems/json-2.18.0, /usr/lib/ruby/gems/4.0.0/gems/logger-1.7.0, /usr/lib/ruby/gems/4.0.0/gems/matrix-0.4.3, /usr/lib/ruby/gems/4.0.0/gems/minitest-6.0.0, /usr/lib/ruby/gems/4.0.0/gems/mutex_m-0.3.0, /usr/lib/ruby/gems/4.0.0/gems/net-ftp-0.3.9, /usr/lib/ruby/gems/4.0.0/gems/net-http-0.9.1, /usr/lib/ruby/gems/4.0.0/gems/net-imap-0.6.4.1, /usr/lib/ruby/gems/4.0.0/gems/net-pop-0.1.2, /usr/lib/ruby/gems/4.0.0/gems/net-protocol-0.2.2, /usr/lib/ruby/gems/4.0.0/gems/net-smtp-0.5.1, /usr/lib/ruby/gems/4.0.0/gems/nkf-0.2.0, /usr/lib/ruby/gems/4.0.0/gems/observer-0.1.2, /usr/lib/ruby/gems/4.0.0/gems/open-uri-0.5.0, /usr/lib/ruby/gems/4.0.0/gems/open3-0.2.1, /usr/lib/ruby/gems/4.0.0/gems/openssl-4.0.2, /usr/lib/ruby/gems/4.0.0/gems/optparse-0.8.1, /usr/lib/ruby/gems/4.0.0/gems/ostruct-0.6.3, /usr/lib/ruby/gems/4.0.0/gems/power_assert-3.0.1, /usr/lib/ruby/gems/4.0.0/gems/pp-0.6.3, /usr/lib/ruby/gems/4.0.0/gems/prettyprint-0.2.0, /usr/lib/ruby/gems/4.0.0/gems/prime-0.1.4, /usr/lib/ruby/gems/4.0.0/gems/prism-1.8.1, /usr/lib/ruby/gems/4.0.0/gems/pstore-0.2.1, /usr/lib/ruby/gems/4.0.0/gems/psych-5.3.1, /usr/lib/ruby/gems/4.0.0/gems/racc-1.8.1, /usr/lib/ruby/gems/4.0.0/gems/rake-13.3.1, /usr/lib/ruby/gems/4.0.0/gems/rbs-3.10.0, /usr/lib/ruby/gems/4.0.0/gems/rdoc-7.0.4, /usr/lib/ruby/gems/4.0.0/gems/readline-0.0.4, /usr/lib/ruby/gems/4.0.0/gems/reline-0.6.3, /usr/lib/ruby/gems/4.0.0/gems/repl_type_completor-0.1.12, /usr/lib/ruby/gems/4.0.0/gems/resolv-0.7.2, /usr/lib/ruby/gems/4.0.0/gems/resolv-replace-0.1.1, /usr/lib/ruby/gems/4.0.0/gems/rexml-3.4.4, /usr/lib/ruby/gems/4.0.0/gems/rinda-0.2.0, /usr/lib/ruby/gems/4.0.0/gems/rss-0.3.2, /usr/lib/ruby/gems/4.0.0/gems/ruby2_keywords-0.0.5, /usr/lib/ruby/gems/4.0.0/gems/securerandom-0.4.1, /usr/lib/ruby/gems/4.0.0/gems/shellwords-0.2.2, /usr/lib/ruby/gems/4.0.0/gems/singleton-0.3.0, /usr/lib/ruby/gems/4.0.0/gems/stringio-3.2.0, /usr/lib/ruby/gems/4.0.0/gems/strscan-3.1.6, /usr/lib/ruby/gems/4.0.0/gems/syntax_suggest-2.0.3, /usr/lib/ruby/gems/4.0.0/gems/syslog-0.3.0, /usr/lib/ruby/gems/4.0.0/gems/tempfile-0.3.1, /usr/lib/ruby/gems/4.0.0/gems/test-unit-3.7.5, /usr/lib/ruby/gems/4.0.0/gems/time-0.4.2, /usr/lib/ruby/gems/4.0.0/gems/timeout-0.6.0, /usr/lib/ruby/gems/4.0.0/gems/tmpdir-0.3.1, /usr/lib/ruby/gems/4.0.0/gems/tsort-0.2.0, /usr/lib/ruby/gems/4.0.0/gems/typeprof-0.31.1, /usr/lib/ruby/gems/4.0.0/gems/un-0.3.0, /usr/lib/ruby/gems/4.0.0/gems/uri-1.1.1, /usr/lib/ruby/gems/4.0.0/gems/weakref-0.1.4, /usr/lib/ruby/gems/4.0.0/gems/yaml-0.4.0, /usr/lib/ruby/gems/4.0.0/gems/zlib-3.2.3, /usr/lib/ruby/gems/4.0.0/specifications/default, /usr/lib/ruby/site_ruby, /usr/lib/ruby/vendor_ruby, /usr/share/licenses/ruby.
Short descriptions
bundle |
Ruby Dependency Management |
erb |
Ruby Templating |
irb |
Interactive Ruby Shell |
ri |
Ruby API reference front end |
ruby |
Interpreted object-oriented scripting language |
ruby-4.0.pc |
Object Oriented Script Language |
Notes
build.sh checks, after the install, that the openssl, psych, zlib and fiddle extensions were built. An extension whose library is missing is only a warning in the extension build’s output, and a LoadError on the installed system: without yaml.h there is no psych (and so no YAML), without ffi.h no fiddle. Each extension the depends line pays for must exist, or the build stops.
Ruby compiles its own code with -ggdb3, which configure adds as debugflags after the tree’s flags, so libruby.so is passed through strip --strip-debug to keep the tree’s rule that no package ships debug information.
The installer compresses ruby.1 and erb.1 with gzip whenever gzip is on PATH, so the package’s file names would depend on the build host; build.sh decompresses them, matching every other page on the image. The pages bundler, irb and rdoc carry sit inside their library trees, where man never looks, and are copied into /usr/share/man. The gem cache, a second copy of every bundled gem as a .gem archive that only gem pristine reads, is deleted.