118.26. aalib-1.4rc5
ASCII art graphics library — renders true-color images to text
| Version | 1.4rc5, release 1 |
| Shelf | image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output |
| Phase | 41_system (System), 705 of 1047 in build order |
| Licence | LGPL-2.0-or-later |
| Homepage | https://aa-project.sourceforge.net/aalib/ |
| Build time | 0.1 SBU |
| Installed size | 455.8 KiB in 79 files |
| Recipe | ports/core/image-libs/aalib/kpkgbuild |
About
aalib is the aa-project’s ASCII-art library: it renders an image as text, on a terminal through curses or on the Linux console. kdos-bb draws with it, and aview, gst-plugins-good, gimp and gphoto2 link it. The package also installs aalib’s own demonstrations, aafire, aatest, aainfo and aasavefont.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/image-libs.txt:
ASCII art from the aa-project, on the TTY. aalib's own demos are aafire/aatest/aainfo/aasavefont.
Sources
aalib-1.4rc5.tar.gz(381.9 KiB)
sha256fbddda9230cf6ee2a4f5706b4b11e2190ae45f5eda1f0409dc4f99b35e0a70ee
upstream: https://downloads.sourceforge.net/project/aa-project/aa-lib/1.4rc5/aalib-1.4rc5.tar.gz
archive copy: sources-3/image-libs--aalib-1.4rc5.tar.gz
Dependencies
Depends on: ncurses.
Required by (5): aview, gimp, gphoto2, gst-plugins-good, kdos-bb.
Patches
build.sh applies these; kpkg applies nothing by itself.
config-no-rpath.patch— removes@AALIB_RLD_FLAGS@from the--libsoutput ofaalib-config, so a program that links aalib through the script is not given-Wl,-rpath,/usr/lib.curses-kbd-debug-print.patch— deletes theprintf("uninitializing\n")in the curses keyboard driver’scurses_uninit(). It runs afterendwin()has restored the screen, so the word lands on the user’s terminal, over the shell prompt, every time a curses program such askdos-bbexits.curses-resize.patch— Read the terminal size in the curses driver's getsize and resize ncurses to itcurses_getsize() answered a resize with endwin() and a second initscr(), and ncurses' initscr() returns the existing stdscr after its first call, so the reported size never changed and aa_resize() kept the old buffers. Ask the terminal for its size with TIOCGWINSZ on every call and give a changed size to resize_term(), which resizes stdscr in place, then mark curscr for a full repaint. resize_term() and not resizeterm(): the latter also queues KEY_RESIZE, which the curses keyboard driver reports as AA_UNKNOWN, so every resize would hand the program a spurious key and aafire, which quits on any key, would exit. Checking on every call also covers a keyboard driver other than curses, which installs no SIGWINCH handler. Without ncurses or TIOCGWINSZ the driver keeps the reinit path.
linuxkbd-bounds.patch— in the Linux console keyboard driver, sizeskey_down[]byNR_KEYS(256) instead of 128, since the driver’s loops index it up toNR_KEYS, and passes theKDGKBENTioctl its argument as a pointer instead of casting it tounsigned int, a cast that cuts the address to 32 bits on x86-64.ltconfig-musl.patch— lets the bundled libtool 1.3.5ltconfigtreat alinux-muslhost as Linux ELF, as it doeslinux-gnu. An unmatched host falls through todynamic_linker=no, and libtool then builds no shared library, so there would be nolibaa.so.1.m4-quote.patch— quotes the macro name inaalib.m4’sAC_DEFUN(AM_PATH_AALIB, ...), soaclocalin a project that uses the macro does not warn about an underquoted definition.ncurses-opaque-window.patch— reads the curses screen size withgetmaxx(stdscr)andgetmaxy(stdscr)instead ofstdscr->_maxxand_maxy: ncurses’WINDOWis opaque, so the fields do not compile.
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 aalib'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/image-libs/aalib.
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/image-libs/aalib
echo 'fbddda9230cf6ee2a4f5706b4b11e2190ae45f5eda1f0409dc4f99b35e0a70ee aalib-1.4rc5.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/aalib
SRC=$SRC_ROOT/aalib-1.4rc5
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf aalib-1.4rc5.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/ncurses-opaque-window.patch
patch -p1 -i $PORT_SRC/curses-kbd-debug-print.patch
patch -p1 -i "$PORT_SRC/m4-quote.patch"
patch -p1 -i "$PORT_SRC/linuxkbd-bounds.patch"
patch -p1 -i "$PORT_SRC/config-no-rpath.patch"
patch -p1 -i "$PORT_SRC/ltconfig-musl.patch"
patch -p1 -i "$PORT_SRC/curses-resize.patch"
export CFLAGS="$CFLAGS -Wno-implicit-function-declaration -Wno-implicit-int \
-Wno-int-conversion -Wno-incompatible-pointer-types \
-Wno-return-mismatch -Wno-declaration-missing-parameter-type"
ac_cv_lib_gpm_Gpm_Repeat=no CC="$CC $LDFLAGS" \
./configure --prefix=/usr \
--libdir=/usr/lib \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--disable-static \
--with-ncurses \
--with-slang-driver=no \
--with-x11-driver=no \
--without-x
make
make DESTDIR=$PKG install
readelf -d $PKG/usr/lib/libaa.so.1 | grep -q 'NEEDED.*\[libncursesw\?\.so'
rm -f $PKG/usr/share/info/dir
The switches, and why each is set:
-Wno-implicit-function-declaration— With-Wno-implicit-int,-Wno-int-conversion,-Wno-incompatible-pointer-types,-Wno-return-mismatchand-Wno-declaration-missing-parameter-type, turn back into warnings the diagnostics current GCC makes errors by default. aalib’s configure was generated by autoconf 2.13, and its very first test program is K&R C,main(){return(0);}: with implicitintan error, that test fails and configure stops with “C compiler cannot create executables”. The other switches keep aalib’s own old-style C sources compiling.ac_cv_lib_gpm_Gpm_Repeat=no— Answer the gpm library check in advance with “no”, so no console-mouse support is built. gpm is not a port, and--with-gpm-mousetakes only a directory:--with-gpm-mouse=nowould add-Lno/lib -lgpm.CC="$CC $LDFLAGS"— Put the tree’s linker flags on the compiler command itself, so every command that runs$CCcarries them, whether or not it also passesLDFLAGS.--with-ncurses— Build the curses driver against ncurses.--with-slang-driver=no— Build no S-Lang driver. slang is a port, and when configure finds it, it turns the curses driver off unless that is forced, so consumers would get S-Lang instead of curses.--with-x11-driver=no— Build no X11 driver;--without-xis the matching autoconf switch.
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/aalib, 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 aalib-1.4rc5-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/aalib, and runs the triggers its paths call for.
Contents
Installed programs: aafire, aainfo, aalib-config, aasavefont, aatest.
Installed libraries: libaa.so.
Installed directories: /usr/share/licenses/aalib.
Short descriptions
aafire |
aalib example programs |
Notes
After the install, build.sh reads the dynamic section of libaa.so.1 and fails unless it names libncurses.so or libncursesw.so as needed. configure finds ncurses by probing, and a probe that misses still produces a library, one with no curses driver, which every consumer would then receive; the check stops the build there instead.
curses-resize.patch is what lets a curses program follow a terminal resize: kdos-bb calls aa_resize() at the start of each scene and takes the new size there.