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

122.5. cncjs-1.11.5

Web-based controller for Grbl, Marlin, Smoothieware and TinyG CNC machines, served to the browser

Version 1.11.5, release 1
Shelf fabrication — 3D-printing slicers and hosts, and CNC control
Phase 41_system (System), 498 of 1047 in build order
Licence MIT
Homepage https://cnc.js.org/
Build time 3.3 SBU
Installed size 138.2 MiB in 25131 files
Recipe ports/core/fabrication/cncjs/kpkgbuild

About

CNCjs is a machine controller for Grbl, Marlin, Smoothieware and TinyG boards, written in JavaScript. It is a nodejs server that talks to the machine over a serial port and serves the controller’s interface to a web browser. Upstream builds it with Yarn and packages it as an Electron application; this port builds only the server and its browser client, and installs it under /usr/lib/cncjs with cncjs on the path. Its desktop entry runs the server in a terminal, and the interface is then opened at http://localhost:8000.

Sources

Dependencies

Depends on: nodejs, python3, make.

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

What kpkg does

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

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/fabrication/cncjs
echo '03862c05383a7f04f5a91fdb4c555a651deaf1132a70bc750e7ab9b6292f729e  cncjs-1.11.5.tar.gz' | sha256sum -c -
echo 'b2eb26b16d723289c477159b8ec04ca14534291cbc8c42232f3e53f9df176848  cncjs-vendor-1.11.5.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/cncjs
SRC=$SRC_ROOT/cncjs-1.11.5
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf cncjs-1.11.5.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 recipe’s helpers npmflags and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

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

tar xf "$PORT_SRC/$name-vendor-$version.tar.xz"
rm -rf node_modules/@serialport/bindings-cpp/prebuilds node_modules/@parcel/watcher-* \
	node_modules/@unrs node_modules/app-builder-bin node_modules/7zip-bin \
	node_modules/term-size/vendor
export PATH="$SRC/node_modules/.bin:$PATH"
_nodedir=$(dirname "$(dirname "$(command -v node)")")

node scripts/package-sync.js
mkdir -p dist/cncjs
cp -af src/package.json dist/cncjs/
( cd src && NODE_ENV=production babel "*.js" --config-file ../babel.config.js --out-dir ../dist/cncjs )
NODE_ENV=production babel -d dist/cncjs/server src/server
NODE_ENV=production webpack-cli --config webpack.config.production.js
mkdir -p dist/cncjs/app dist/cncjs/server
cp -af src/app/favicon.ico src/app/i18n src/app/images src/app/assets dist/cncjs/app/
cp -af src/server/i18n src/server/views dist/cncjs/server/
find dist -name '*.map' -delete
find dist/cncjs/app/i18n dist/cncjs/server/i18n -mindepth 1 -maxdepth 1 -type d ! -name en \
	-exec rm -rf {} +

( cd node_modules/@serialport/bindings-cpp && node-gyp rebuild --nodedir="$_nodedir" )

npm prune --omit=dev --offline --ignore-scripts --legacy-peer-deps --no-audit --no-fund

_dir=/usr/lib/cncjs
install -d "$PKG$_dir/bin" "$PKG/usr/bin"
cp -a dist node_modules package.json "$PKG$_dir/"
find "$PKG$_dir/node_modules" \( -name '*.orig' -o -name '*.rej' \) -delete
install -m755 bin/cncjs "$PKG$_dir/bin/cncjs"
ln -s ../lib/cncjs/bin/cncjs "$PKG/usr/bin/cncjs"

install -Dm644 src/app/images/logo-square-256x256.png "$PKG/usr/share/icons/hicolor/256x256/apps/cncjs.png"

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/cncjs.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=CNCjs Server
GenericName=CNC Controller
Comment=Serve the CNCjs machine controller at http://localhost:8000
Exec=cncjs --host 127.0.0.1
Icon=cncjs
Terminal=true
Categories=Utility;Engineering;
Keywords=cnc;grbl;marlin;smoothie;tinyg;gcode;g-code;mill;laser;
DESKTOP
chmod 644 "$PKG/usr/share/applications/cncjs.desktop"

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

Contents

Installed programs: cncjs.

Installed directories: /usr/lib/cncjs, /usr/share/licenses/cncjs.

Notes

The vendor bundle, cncjs-vendor-<version>.tar.xz, is node_modules/ and the package-lock.json that ports/fetch writes by running npm install --ignore-scripts --legacy-peer-deps against the source, packed reproducibly and pinned by its own sha256 = line. A version bump regenerates it, and its hash line changes with it.

npm downloads prebuilt native binaries into that tree, compiled elsewhere for Linux, macOS, Windows and Android: the @serialport/bindings-cpp prebuilds, the glibc builds of @parcel/watcher and of the @unrs resolver, and the executables in app-builder-bin, 7zip-bin and term-size/vendor. build.sh deletes them all before building, because nothing on the host may run a binary it did not compile (see What is built from source). The serial-port module is then compiled from its source by node-gyp; without it the server cannot open a machine’s port.

The build steps are upstream’s scripts/build-prod.sh, run as plain commands: no Yarn, no i18next-scanner pass, and no Electron application. Translations other than English are removed from the client and the server, and source maps are deleted.