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

109.6. croc-11.5.3

One-off file transfer by code phrase, kept on this network

Version 11.5.3, release 1
Shelf transfer — File transfer, synchronisation, backup and BitTorrent
Phase 41_system (System), 981 of 1047 in build order
Licence MIT
Homepage https://github.com/schollz/croc
Build time 0.2 SBU
Installed size 10.5 MiB in 4 files
Recipe ports/core/transfer/croc/kpkgbuild

About

croc sends a file or a directory from one machine to another, the receiver typing a code phrase the sender shows. On KDOS /usr/bin/croc is a small shell wrapper that runs the real binary with --local, which keeps the transfer to direct connections on the local network. Without it croc looks for the peer on the local network and connects to its public relay on the internet at the same time, and carries the transfer over whichever answers first, without saying which. The unwrapped binary is installed as croc-relay, for a transfer that is meant to go through the relay.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/transfer.txt:

The default relay is a host on the internet and croc falls back to it SILENTLY, so the shipped wrapper is croc --local.

Sources

Dependencies

Depends on: go.

Required by (1): kdos-tools.

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

What kpkg does

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

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/transfer/croc
echo '194ec2494f1801d7baa597d30ab6571f4a25f645cf0527aa7a4b66cd5b7a6fa8  croc-11.5.3.tar.gz' | sha256sum -c -
echo '40ece0dedbd2dacafd047e011b5d13fca6f0309978c6f2dcc0b36ce4771c023a  croc-vendor-11.5.3.tar.xz' | 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/croc
SRC=$SRC_ROOT/croc-11.5.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf croc-11.5.3.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:

patch -p1 -i "$PORT_SRC/disable-update-check.patch"

tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz

export CGO_ENABLED=0
go build -mod=vendor \
	-tags croc_no_tailcat,ts_omit_webclient,ts_omit_debugeventbus \
	-ldflags "-s -w -X main.Version=$version" -o croc.bin
install -Dm755 croc.bin $PKG/usr/bin/croc-relay
install -Dm644 packaging/croc.1 -t "$PKG/usr/share/man/man1"

install -Dm755 /dev/stdin $PKG/usr/bin/croc <<'SH'
#!/bin/sh
# --local keeps the transfer on this network. `croc-relay` is the same binary
# with upstream's default, for when reaching the public relay is the intent.
exec /usr/bin/croc-relay --local "$@"
SH

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

Contents

Installed programs: croc, croc-relay.

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

Short descriptions

croc transfer files, directories, and text using a short code

Notes

The modules come from the vendor bundle, croc-vendor-<version>.tar.xz, made by ports/fetch with go mod vendor and used with -mod=vendor (see Vendoring). The binary is built as croc.bin and installed under its other name; the manual page, croc.1, describes the command as upstream ships it.

A send or a receive makes no request of its own for croc’s latest release: disable-update-check.patch removes the background check upstream starts with each, which --local does not stop. croc update answers, with no request, that the system package manager updates croc, and replaces nothing; croc update --check asks api.github.com when it is run.