47.1. pcre2-10.49
Perl Compatible Regular Expressions library, version 2
| Version | 10.49, release 1 |
| Shelf | devlibs — General-purpose C and C++ utility libraries with no domain |
| Phase | 30_foundation (Build Foundation), 66 of 127 in build order |
| Licence | BSD-3-Clause WITH PCRE2-exception |
| Homepage | https://www.pcre.org/ |
| Build time | 0.5 SBU |
| Installed size | 4.6 MiB in 135 files |
| Recipe | ports/core/devlibs/pcre2/kpkgbuild |
About
PCRE2 is the Perl-compatible regular expression library. In KDOS it sits under GNU grep (for grep -P), less, glib and so everything built on GLib, git and libgit2, zsh, VTE, ripgrep, and both Qt bases, whose QRegularExpression is PCRE2. It installs one library per code-unit width (libpcre2-8, libpcre2-16 and libpcre2-32), the POSIX wrapper libpcre2-posix, and the pcre2grep and pcre2test programs.
Sources
pcre2-10.49.tar.gz(2.7 MiB)
sha256929f0b20e62879252a15886b06c89f1edef61a363cbd5826fb041080a5e557ae
upstream: https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.49/pcre2-10.49.tar.gz
archive copy: sources-1/devlibs--pcre2-10.49.tar.gz
Dependencies
Depends on: readline, zlib, bzip2.
Required by (37): android-tools, brltty, clamav, gdal, git, glib, glib-introspection, grep, gtksourceview5, lagrange, less, libbytesize, libgit2, lite-xl, lnav, mpd, nmap, octave, orcaslicer, poco, qt5-qtbase, qt6-qtbase, R, remmina, ripgrep, rizin, sord, swig, tig, tlf, translatelocally, universal-ctags, vte3, wireshark, wxwidgets, xastir, zsh.
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/30_foundation/phase.env && kpkg install pcre2'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/devlibs/pcre2.
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/devlibs/pcre2
echo '929f0b20e62879252a15886b06c89f1edef61a363cbd5826fb041080a5e557ae pcre2-10.49.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/pcre2
SRC=$SRC_ROOT/pcre2-10.49
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf pcre2-10.49.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 CFLAGS="${CFLAGS/-O2/-O3}"
./configure --prefix=/usr \
--disable-static \
--enable-unicode \
--enable-jit \
--enable-pcre2-16 \
--enable-pcre2-32 \
--enable-pcre2grep-libz \
--enable-pcre2grep-libbz2 \
--enable-pcre2test-libreadline
make
make DESTDIR=$PKG install
The switches, and why each is set:
export CFLAGS="${CFLAGS/-O2/-O3}"— Compile the library at-O3instead of the tree’s-O2, keeping the rest of the tree’s flags; the checks a recipe’s flags go through are in Every port.--enable-unicode— Build Unicode support: UTF-8, UTF-16 and UTF-32 matching and the Unicode property tables. It is upstream’s default, so naming it restates the default.--enable-jit— Build the just-in-time compiler, which turns a pattern into machine code for faster matching. It is off by default. A program asks for it by callingpcre2_jit_compile()on a pattern; a pattern not compiled that way is matched by the interpreter.--enable-pcre2-16— Also buildlibpcre2-16, for UTF-16 strings. Qt 6’sFEATURE_system_pcre2looks for PCRE2’s 16-bit library only, because aQStringis UTF-16.--enable-pcre2-32— Also buildlibpcre2-32, for UTF-32 strings;brlttyand rizin’slibrz_utillink it.--enable-pcre2grep-libz— Linkpcre2grepwith zlib, so it searches.gzfiles directly.--enable-pcre2grep-libbz2— Linkpcre2grepwith bzip2, so it searches.bz2files directly.--enable-pcre2test-libreadline— Linkpcre2testwith readline for line editing in its interactive mode.
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/pcre2, 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 pcre2-10.49-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/pcre2, and runs the triggers its paths call for.
Contents
Installed programs: pcre2-config, pcre2grep, pcre2test.
Installed libraries: libpcre2-16.so, libpcre2-32.so, libpcre2-8.so, libpcre2-posix.so.
Installed directories: /usr/share/doc/pcre2, /usr/share/licenses/pcre2.
Short descriptions
pcre2-config |
program to return PCRE2 configuration |
pcre2grep |
a grep with Perl-compatible regular expressions. |
pcre2test |
a program for testing Perl-compatible regular expressions. |
libpcre2-16.pc |
PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support |
libpcre2-32.pc |
PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support |
libpcre2-8.pc |
PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support |
libpcre2-posix.pc |
Posix compatible interface to libpcre2-8 |