172.1. kdos-bb-1.3.0
The AAlib demo, hard-forked and rebranded, with a threaded mixer
| Version | 1.3.0, release 1 |
| Source tree | src/art/kdos-bb/ |
| Phase | 41_system (System), 955 of 1047 in build order |
| Licence | GPL-2.0-or-later |
| Homepage | https://github.com/kunaldawn/kdos |
| Build time | 0.1 SBU |
| Installed size | 1.8 MiB in 7 files |
| Recipe | src/art/kdos-bb/kpkgbuild |
About
kdos-bb is the audio-visual demo that ships with KDOS: a hard fork of bb, the AA-project’s text-mode demo, drawn by aalib and scored with three S3M tracker modules played by libmikmod. What it does, how the fork differs from upstream and why, is the program’s chapter; KDOS-FORK at the root of the port lists every change file by file. No other port depends on it.
The build has no configure step. Upstream’s autoconf script fails under GCC 14 (its compiler probe is a K&R main() that GCC 14 rejects), so the fork carries src/aconfig.h, the answers that script would have given for Linux, musl and x86-64, and build.sh compiles the source list in one cc call. It installs the binary, the three modules under /usr/share/kdos-bb, the manual page, and COPYING and AUTHORS as the licence.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/src-art.txt:
The 1997 AAlib demo, hard-forked as ours: see src/art/kdos-bb/KDOS-FORK.
Sources
None: the port builds from its own directory, /kdos/src/art/kdos-bb.
Dependencies
Depends on: aalib, libmikmod, ncurses.
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 kdos-bb'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/art/kdos-bb.
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.
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/kdos-bb
SRC=$SRC_ROOT/kdos-bb-1.3.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
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:
cd "$PORT_SRC/src"
SRC="autopilo.c backconv.c bb.c credits.c credits2.c ctrl87.c
fk1.c fk2.c fk3.c fk4.c formulas.c hh1.c hh2.c hh3.c hh4.c
image.c julia.c kdostux.c kt1.c kt2.c kt3.c kt4.c main.c messager.c minilzo.c
ms1.c ms2.c ms3.c ms4.c print.c
scene1.c scene2.c scene3.c scene4.c scene5.c scene7.c scene8.c scene9.c
tex.c textform.c timers.c uncompfn.c zeb.c zoom.c"
cc $CFLAGS -O2 -o "$SRC_ROOT/kdos-bb" $SRC \
-DSOUNDDIR='"/usr/share/kdos-bb"' \
-Wno-implicit-function-declaration -Wno-implicit-int \
-Wno-int-conversion -Wno-incompatible-pointer-types \
-Wno-return-mismatch -Wno-declaration-missing-parameter-type \
$LDFLAGS -laa -lmikmod -lncurses -lm -lpthread
install -Dm755 "$SRC_ROOT/kdos-bb" "$PKG/usr/bin/kdos-bb"
for m in "$PORT_SRC"/data/*.s3m; do
install -Dm644 "$m" "$PKG/usr/share/kdos-bb/$(basename "$m")"
done
install -Dm644 "$PORT_SRC/kdos-bb.1" "$PKG/usr/share/man/man1/kdos-bb.1"
install -Dm644 "$PORT_SRC/COPYING" "$PKG/usr/share/licenses/kdos-bb/COPYING"
install -Dm644 "$PORT_SRC/AUTHORS" "$PKG/usr/share/licenses/kdos-bb/AUTHORS"
The switches, and why each is set:
-O2— The optimisation level the tree’sCFLAGSalready carries, named again on the command line.-DSOUNDDIR='"/usr/share/kdos-bb"'— The directorymain.cprefixes to a module’s name when it loads one, which is wherebuild.shinstallsbb.s3m,bb2.s3mandbb3.s3m.-Wno-implicit-function-declaration,-Wno-implicit-int,-Wno-int-conversion,-Wno-incompatible-pointer-types,-Wno-return-mismatch,-Wno-declaration-missing-parameter-type— The six diagnostics GCC 14 turned from warnings into errors: a call to an undeclared function, a declaration with no type, an integer used as a pointer, a pointer of the wrong type, areturnthat does not match its function, and an old style parameter with no type. The flags turn them back into warnings for the demo’s pre-standard C. aalib passes the same six.-laa,-lmikmod,-lncurses,-lm,-lpthread— The libraries, named by hand because no build system finds them. AAlib draws through its curses driver, so ncurses is linked as well;-lpthreadis for the mixer thread that feeds libmikmod (The mixer runs on its own thread).
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/kdos-bb, 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 kdos-bb-1.3.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/kdos-bb, and runs the triggers its paths call for.
Other files in the port directory, read by build.sh: AUTHORS, COPYING, KDOS-FORK, data/, genimg.py, kdos-bb.1, src/.
Contents
Installed programs: kdos-bb.
Installed directories: /usr/share/kdos-bb, /usr/share/licenses/kdos-bb.
Short descriptions
kdos-bb |
the AAlib demo |
Notes
The source list in build.sh is the build: a .c file added under src/ is not compiled until it is named there, and nothing reports one that is missing until the link fails.
src/aconfig.h states what one target has. On another C library or architecture it has to be checked by hand. timers.c takes its clock from the first of HAVE_GETTIMEOFDAY and HAVE_FTIME that is defined; aconfig.h defines only the first, so the demo is timed with gettimeofday.
src/kdostux.c, the mascot as an LZO-compressed image, is the output of genimg.py, which runs on a development host with Pillow and a C compiler: it compiles the fork’s own minilzo.c to compress the picture, because only the matching LZO1X implementation is guaranteed to decompress it. The build never runs it, so a changed picture means running it and committing its output.
The port builds only where aalib and libmikmod are installed, which is inside the build tree, not on a bare host; rebuilding it alone is in Building and changing it.