Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

176.3. R-4.6.1

Language and environment for statistics, with the recommended packages

Version 4.6.1, release 1
Shelf lang — Language implementations, plus the modules of any language that has no module shelf of its own
Phase 42_graphics (Graphics Stack), 140 of 189 in build order
Licence GPL-2.0-or-later AND LGPL-2.1-or-later
Homepage https://www.r-project.org/
Build time 11.7 SBU
Installed size 64.9 MiB in 1382 files
Recipe ports/core/lang/R/kpkgbuild

About

R is the language and environment for statistics and data analysis: the interpreter, Rscript, the base and recommended packages (Matrix, MASS, lattice, survival, nlme, mgcv and the rest), the graphics devices, and libR.so, through which RKWard and Cantor embed R. Linear algebra runs on openblas. The X11 graphics device and the tcltk package run under Xwayland, and cairo and pango give the PNG, SVG and PDF devices anti-aliased text with no display at all.

Sources

Dependencies

Depends on: gcc, openblas, readline, pcre2, icu, curl, xz, bzip2, zlib, libdeflate, libpng, libjpeg-turbo, libtiff, cairo, pango, harfbuzz, fontconfig, freetype2, libX11, libXt, libXmu, tcl, tk, perl, texinfo, libtirpc, zstd.

Required by (2): cantor, rkward.

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/42_graphics/phase.env && kpkg install R'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/lang/R.

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/R
echo '4da6e61d2c0aac5f14a2e7e432cb5fcc269efe83da4293050ba7f03dff4e2cf4  R-4.6.1.tar.gz' | 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/R
SRC=$SRC_ROOT/R-4.6.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf R-4.6.1.tar.gz -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:

export CXXFLAGS="$CXXFLAGS -D__MUSL__"
./configure --prefix=/usr --libdir=/usr/lib --sysconfdir=/etc/R \
	--localstatedir=/var --mandir=/usr/share/man \
	rdocdir=/usr/share/doc/R \
	rincludedir=/usr/include/R \
	rsharedir=/usr/share/R \
	--enable-R-shlib \
	--disable-R-static-lib \
	--disable-java \
	--disable-nls \
	--enable-openmp \
	--with-recommended-packages \
	--with-blas=-lopenblas \
	--with-lapack \
	--with-readline \
	--with-pcre2 \
	--with-ICU \
	--with-cairo \
	--with-libpng \
	--with-jpeglib \
	--with-libtiff \
	--with-libdeflate-compression \
	--with-x \
	--with-tcltk \
	--with-tcl-config=/usr/lib/tclConfig.sh \
	--with-tk-config=/usr/lib/tkConfig.sh
make
make DESTDIR=$PKG install
make -C src/unix DESTDIR=$PKG LIBR_LDFLAGS= install-pc

make -C src/nmath/standalone shared
make -C src/nmath/standalone DESTDIR=$PKG install
rm -f "$PKG"/usr/lib/libRmath.a

test -e "$PKG"/usr/lib/R/lib/libR.so
ln -s R/lib/libR.so "$PKG"/usr/lib/libR.so
for p in Matrix MASS lattice survival nlme mgcv; do
	test -d "$PKG/usr/lib/R/library/$p"
done
test -e "$PKG"/usr/lib/R/library/tcltk/libs/tcltk.so
test -e "$PKG"/usr/lib/R/modules/R_X11.so

The switches, and why each is set:

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/R, 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 R-4.6.1-1.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/R, and runs the triggers its paths call for.

Contents

Installed programs: R, Rscript.

Installed libraries: libR.so, libRmath.so.

Installed directories: /usr/include/R, /usr/lib/R, /usr/share/R, /usr/share/doc/R, /usr/share/licenses/R.

Short descriptions

R a language for data analysis and graphics
Rscript front end for scripting with R
libR.pc R as a library
libRmath.pc The Rmath function library

Notes

make -C src/nmath/standalone shared and its install add libRmath.so, R’s distribution functions as a plain C library that other programs link without embedding R; the static libRmath.a the install may copy is deleted.

The test -e and test -d lines at the end turn a silently dropped feature into a failed build. They check for libR.so, R_X11.so, tcltk.so and the six recommended packages Matrix, MASS, lattice, survival, nlme and mgcv. The configure turns Tcl/Tk support off with only a warning when it cannot use tcl or tk, so without these checks a build with no tcltk.so would install cleanly and the package would ship without it; with them, none of the other checked libraries or packages can go missing without the build failing either.