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

146.2. frotz-2.55

Z-machine interpreter — Infocom-era interactive fiction in a terminal

Version 2.55, release 1
Shelf games-rpg — RPGs, roguelikes and interactive fiction
Phase 41_system (System), 574 of 1047 in build order
Licence GPL-2.0-or-later
Homepage https://661.org/proj/if/frotz/
Build time 0.1 SBU
Installed size 222.9 KiB in 5 files
Recipe ports/core/games-rpg/frotz/kpkgbuild

About

Frotz is an interpreter for the Z-machine, the virtual machine Infocom’s interactive fiction runs on, and for the stories written for it since. KDOS builds its curses interface, so a story plays in a terminal; the package carries no story of its own, and its desktop entry, Exec=frotz %f with Terminal=true, opens one from the file manager. The entry is NoDisplay=true, so frotz is not in the application menu: started with no story it prints its usage and exits. A story file opens in it through the file’s type instead.

frotz is the worked example of Writing ports, which goes through the whole recipe; the points below are the ones a reader of build.sh needs.

Why it is in KDOS

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

Interactive fiction, with one MIT-licensed story shipped beside it so the program opens something. It also installs the z-machine MIME type, which shared-mime-info does not define — without it a story file resolves to nothing and the entry's MimeType line is decoration.

Sources

Dependencies

Depends on: ncurses, pkgconf.

Required by: no port names it.

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

What kpkg does

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

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-rpg/frotz
echo 'a8c4c4d79a2aa9b39e0efbbd3e0803f1dc5ef36f75f2c2945e295d190575eb09  frotz-2.55.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/frotz
SRC=$SRC_ROOT/frotz-2.55
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf frotz-2.55.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 -Wno-error"
export LDFLAGS="$LDFLAGS -Wl,--strip-debug"
make curses PREFIX=/usr SOUND_TYPE=none
make install PREFIX=/usr SOUND_TYPE=none DESTDIR=$PKG

install -Dm644 /dev/stdin \
	"$PKG/usr/share/mime/packages/kdos-zmachine.xml" <<'MIMEXML'
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/x-zmachine">
    <comment>Z-machine story file</comment>
    <glob pattern="*.z1"/>
    <glob pattern="*.z2"/>
    <glob pattern="*.z3"/>
    <glob pattern="*.z4"/>
    <glob pattern="*.z5"/>
    <glob pattern="*.z6"/>
    <glob pattern="*.z7"/>
    <glob pattern="*.z8"/>
  </mime-type>
  <mime-type type="application/x-blorb">
    <comment>Blorb resource file</comment>
    <glob pattern="*.zblorb"/>
    <glob pattern="*.zlb"/>
    <glob pattern="*.blorb"/>
    <glob pattern="*.blb"/>
  </mime-type>
</mime-info>
MIMEXML

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/$name.desktop" <<'ENTRY'
[Desktop Entry]
Type=Application
Name=Frotz
GenericName=Interactive Fiction
Comment=Play a Z-machine text adventure
Exec=frotz %f
Icon=input-gaming
Terminal=true
NoDisplay=true
Categories=Game;AdventureGame;
MimeType=application/x-zmachine;application/x-blorb;
Keywords=text;adventure;interactive;fiction;zmachine;infocom;story;frotz;
ENTRY
chmod 644 "$PKG/usr/share/applications/$name.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/frotz, 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 frotz-2.55-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/frotz, and runs the triggers its paths call for.

Contents

Installed programs: frotz.

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

Short descriptions

frotz interpreter for Infocom and other Z-Machine games

Notes

The desktop entry claims application/x-zmachine and application/x-blorb, and shared-mime-info defines neither, so build.sh installs /usr/share/mime/packages/kdos-zmachine.xml, which defines both by file extension. Without it a story file has no type, and the entry’s MimeType= line matches nothing. Installing the package rebuilds the MIME database on the target (see Shared indexes).