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

107.10. netcat-1.238

OpenBSD's netcat, reading and writing data over TCP and UDP connections

Version 1.238, release 2
Shelf net-diag — Network diagnostics, capture, measurement and low-level socket tools
Phase 41_system (System), 789 of 1047 in build order
Licence BSD-3-Clause AND BSD-2-Clause AND ISC AND LicenseRef-IBM-DNS
Homepage https://salsa.debian.org/debian/netcat-openbsd
Build time 0.1 SBU
Installed size 74.9 KiB in 4 files
Recipe ports/core/net-diag/netcat/kpkgbuild

About

This is OpenBSD’s netcat, nc, as Debian maintains it for Linux: it opens TCP, UDP and UNIX socket connections or listens on them, and copies standard input and output across. The source is Debian’s packaging repository, which holds the OpenBSD code and the patch series that ports it to Linux through libbsd; two files from Alpine’s netcat-openbsd package make it build against musl.

Sources

Dependencies

Depends on: libbsd.

Required by: no port names it.

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 netcat'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/net-diag/netcat.

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/net-diag/netcat
echo 'ca2fed5e3e0e9841af812bd7ad2ed9e094f5c4cb72817e91323c75e14858af4a  netcat-1.238.tar.gz' | sha256sum -c -
echo '8c98b4f1c5ba66d17ce72a07bf31d0932c10798a624ca26b1780a83b6dac8fb0  b64.patch' | sha256sum -c -
echo '9dc47d8e013881d3372319c209dcbaa3a09dbaf440fbfa503b554ce2998b5fa6  base64.c' | 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/netcat
SRC=$SRC_ROOT/netcat-1.238
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf netcat-1.238.tar.gz -C "$SRC" --strip-components=1
cp b64.patch "$SRC"
cp base64.c "$SRC"

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 recipe’s helpers debrev, _alpine_rev and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

while read -r p; do
	case "$p" in ''|\#*) continue ;; esac
	patch -p1 -i "debian/patches/$p"
done < "debian/patches/series"

patch -p1 -i b64.patch

make SRCS="netcat.c atomicio.c socks.c base64.c" \
	CFLAGS="$CFLAGS -DIPTOS_DSCP_VA=0xb0 -DDEBIAN_VERSION=\"\\\"$version-$debrev\\\"\"" LDFLAGS="$LDFLAGS"
install -Dm755 nc $PKG/usr/bin/nc
install -Dm644 nc.1 $PKG/usr/share/man/man1/nc.1
install -Dm644 debian/copyright "$PKG/usr/share/licenses/$name/copyright"
sed '/^#if/,$d' base64.c > "$PKG/usr/share/licenses/$name/base64-COPYRIGHT"

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

Contents

Installed programs: nc.

Installed directories: /usr/share/licenses/netcat.

Short descriptions

nc arbitrary TCP and UDP connections and listens

Notes

build.sh applies every patch in debian/patches/series, in order, and then Alpine’s b64.patch. The series includes build-without-TLS-support.patch, so this nc has none of OpenBSD’s TLS options and links no TLS library. The program installs as /usr/bin/nc, where Debian names it nc.openbsd. /usr/share/licenses/netcat holds debian/copyright, with the BSD-2-Clause and BSD-3-Clause texts, and base64-COPYRIGHT, the ISC and IBM notices that open Alpine’s base64.c; the IBM grant has no SPDX identifier, so the recipe names it LicenseRef-IBM-DNS.