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
R-4.6.1.tar.gz(39.0 MiB)
sha2564da6e61d2c0aac5f14a2e7e432cb5fcc269efe83da4293050ba7f03dff4e2cf4
upstream: https://cran.r-project.org/src/base/R-4/R-4.6.1.tar.gz
archive copy: sources-3/lang--R-4.6.1.tar.gz
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:
CXXFLAGS="$CXXFLAGS -D__MUSL__"— Defines__MUSL__for C++. The flags are recorded in R’sMakeconf, which every later package build reads, and Rcpp and the packages built on it choose their C library code paths by this macro.--sysconfdir=/etc/R— R’s build reads nosysconfdir: its configuration files (Renviron,Makeconf,repositories) are written underR_HOME/etc,/usr/lib/R/etc, whatever this says.rdocdir=/usr/share/doc/R,rincludedir=/usr/include/R,rsharedir=/usr/share/R— Put R’s documentation, C headers and shared data under/usr/shareand/usr/includeinstead of insideR_HOME, where upstream’s defaults put them.--enable-R-shlib— BuildslibR.so, the shared library theRbinary links and an embedding program loads. Upstream’s default is off.--disable-R-static-lib— Builds nolibR.a, upstream’s default.--disable-java— Skips R’s Java setup. rJava is not shipped, and on its default configure would probe a JDK and record its paths in/usr/lib/R/etc/javaconf.--disable-nls— Builds and installs no translated messages. KDOS ships English only (see the size and language policy).--enable-openmp— Uses OpenMP where R’s code supports it, upstream’s default.--with-recommended-packages— Builds and installs the recommended packages, which ship inside the tarball undersrc/library/Recommended, so they work with no network; any other CRAN package is installed by the user.--with-blas=-lopenblas,--with-lapack— Takes BLAS and LAPACK from OpenBLAS, which installs both, so matrix work runs threaded and vectorised instead of on R’s reference copy.--with-readline,--with-pcre2,--with-ICU,--with-cairo,--with-libpng,--with-jpeglib,--with-libtiff,--with-libdeflate-compression— Upstream’s defaults, named: the console’s line editing, regular expressions, ICU collation, the cairo-based bitmap and vector devices, the image formatspng(),jpeg()andtiff()write, and libdeflate for compressing lazy-loaded R objects.--with-x— Builds the X11 graphics device and data editor,R_X11.so.--with-tcltk,--with-tcl-config=/usr/lib/tclConfig.sh,--with-tk-config=/usr/lib/tkConfig.sh— Builds thetcltkpackage against tcl and tk, naming their configuration scripts directly.LIBR_LDFLAGS=— RewriteslibR.pcwithinstall-pcand this make variable emptied. Theinstalltarget writes the build’sLDFLAGSinto the file’sLibs:line, from which every program that linkslibRthrough pkg-config would take them.
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.