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

143.2. moon-buggy-1.1.0

Drive a buggy across the moon, jumping craters and shooting meteors

Version 1.1.0, release 1
Shelf games-action — Action, arcade, racing, platform and sandbox games
Phase 41_system (System), 565 of 1047 in build order
Licence GPL-3.0-or-later
Homepage https://www.seehuhn.de/pages/moon-buggy
Build time 0.1 SBU
Installed size 167.9 KiB in 5 files
Recipe ports/core/games-action/moon-buggy/kpkgbuild

About

Moon-buggy is a curses game for the terminal: a buggy drives across the moon, and the player jumps its craters and shoots the meteors in its way. It runs in any terminal; the desktop entry the recipe writes opens it in one.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/games-action.txt:

The arcade end of the text games. It builds as it is, with no patch.

Sources

Dependencies

Depends on: ncurses, texinfo.

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 moon-buggy'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/games-action/moon-buggy.

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/games-action/moon-buggy
echo '259ae6e7b1838c40532af5c0f20cd7c6173cd5c552ede408114064475bcfc5b6  moon-buggy-1.1.0.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/moon-buggy
SRC=$SRC_ROOT/moon-buggy-1.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf moon-buggy-1.1.0.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/hangup-restore.patch"

./configure --prefix=/usr \
            --mandir=/usr/share/man \
            --infodir=/usr/share/info \
            --sharedstatedir=/var/lib
make

make DESTDIR=$PKG install-exec install-data-local install-man install-info-am

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/$name.desktop" <<'ENTRY'
[Desktop Entry]
Type=Application
Name=Moon Buggy
GenericName=Arcade Game
Comment=Drive a buggy across the moon, jumping craters and shooting meteors
Exec=moon-buggy
Icon=input-gaming
Terminal=true
Categories=Game;ArcadeGame;
Keywords=game;arcade;moon;buggy;jump;
ENTRY
chmod 644 "$PKG/usr/share/applications/$name.desktop"

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/moon-buggy, 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 moon-buggy-1.1.0-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/moon-buggy, and runs the triggers its paths call for.

Contents

Installed programs: moon-buggy.

Installed directories: /usr/share/licenses/moon-buggy, /var/lib/moon-buggy.

Short descriptions

moon-buggy drive some car across the moon

Notes

hangup-restore.patch is what keeps the game from crashing when its terminal goes away, as it does when the terminal window is closed with the game running. fatal() calls prepare_for_exit(), which calls term_restore(), and upstream’s term_restore() calls fatal() when tcgetattr() fails. On a terminal that has hung up every tcgetattr() fails, so those calls recurse until the stack runs out and the game dies of SIGSEGV. The patched term_restore() clears each flag before it acts on it and ignores the result, so the game exits with Fatal error: Cannot read keyboard input and status 1, or of the SIGHUP it was sent, whichever it reaches first.

build.sh installs through install-exec install-data-local install-man install-info-am rather than make install, which also runs upstream’s install-data-hook. That hook runs the just-installed binary with -c to create the shared score file, and the binary writes to the directory compiled into it, /var/lib/moon-buggy, which DESTDIR does not reach: the file would be written on the build machine, or as the builder’s own ~/.mbscore where that directory is missing, and never into the package. Without the hook the package ships the empty /var/lib/moon-buggy alone, which a user cannot write to, so the game keeps each user’s high scores in ~/.mbscore.