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

101.18. nspr-4.40

Netscape Portable Runtime — the platform layer under NSS

Version 4.40, release 1
Shelf crypto — Cryptographic libraries, PKCS#11, smartcards and TPM
Phase 41_system (System), 326 of 1047 in build order
Licence MPL-2.0
Homepage https://firefox-source-docs.mozilla.org/nspr/index.html
Build time 0.3 SBU
Installed size 927.2 KiB in 74 files
Recipe ports/core/crypto/nspr/kpkgbuild

About

NSPR, the Netscape Portable Runtime, is the platform layer under nss: threads, locks, time, file and socket I/O, and name lookup, behind one API on every system Mozilla supports. Firefox ESR, LibreWolf, Thunderbird, Chromium and Qt WebEngine link it, directly and through NSS. It depends on nothing but the C library.

Sources

Dependencies

Depends on: nothing a recipe names.

Required by (7): chromium, firefox-esr, librewolf, nss, qt6-qtwebengine, thunderbird, volume_key.

Patches

build.sh applies these; kpkg applies nothing by itself.

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/41_system/phase.env && kpkg install nspr'

What kpkg does

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

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/crypto/nspr
echo 'c0c1884c627f3db7a783f7c7314c695226b2043696791d15519e7e0578c19bdc  nspr-4.40.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/nspr
SRC=$SRC_ROOT/nspr-4.40
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf nspr-4.40.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 -D_PR_POLL_AVAILABLE -D_PR_INET6 \
	-D_PR_HAVE_INET_NTOP -D_PR_HAVE_GETHOSTBYNAME2 -D_PR_HAVE_GETADDRINFO \
	-D_PR_INET6_PROBE"

patch -p1 -i "$PORT_SRC/nspr-musl-lfs64.patch"

mkdir build && cd build
../nspr/configure --prefix=/usr --libdir=/usr/lib \
	--with-mozilla --with-pthreads --enable-64bit --enable-ipv6 \
	--enable-optimize --disable-debug
make
make DESTDIR="$PKG" install

rm -f "$PKG"/usr/lib/*.a "$PKG"/usr/bin/compile-et.pl "$PKG"/usr/bin/prerr.properties

install -Dm644 "$SRC/nspr/LICENSE" "$PKG/usr/share/licenses/$name/LICENSE"

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/nspr, 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 nspr-4.40-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/nspr, and runs the triggers its paths call for.

Contents

Installed programs: nspr-config.

Installed libraries: libnspr4.so, libplc4.so, libplds4.so.

Installed directories: /usr/include/nspr, /usr/share/licenses/nspr.

Short descriptions

nspr.pc The Netscape Portable Runtime

Notes

The source carries NSPR in a subdirectory, nspr/, and its configure is run from a separate build directory. After the install build.sh removes the static libraries and two files of NSPR’s own build machinery that it installs into /usr/bin, compile-et.pl and prerr.properties.

nspr-musl-lfs64.patch makes pr/include/md/_linux.h define _PR_HAVE_LARGE_OFF_T where it would define _PR_NO_LARGE_FILES for any C library that is not glibc. musl’s off_t is 64 bits on every architecture, so NSPR’s 64-bit file calls go to plain open, stat, fstat, lseek and mmap, as on the BSDs. Under _PR_NO_LARGE_FILES PR_Seek64 would go through NSPR’s own seek wrapper, which refuses an offset past 2 GiB with EFBIG. The 32-bit PR_GetFileInfo reports PR_FILE_TOO_BIG_ERROR for a file over 2 GiB; PR_GetFileInfo64 does not.