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

306.18. grafx2-2.9

Pixel-art paint program in the Deluxe Paint tradition, on SDL2 with no toolkit

Version 2.9, release 1
Shelf graphics — Graphics applications: painting, vector, photo development and management, image viewers, screenshot and image optimisers
Phase 44_apps (Applications), 238 of 422 in build order
Licence GPL-2.0-only
Homepage http://grafx2.eu
Build time 1.7 SBU
Installed size 2.2 MiB in 107 files
Recipe ports/core/graphics/grafx2/kpkgbuild

About

GrafX2 is a pixel-art paint program in the tradition of Deluxe Paint and Brilliance: indexed colour, palette tools, brushes, animation frames and Lua scripts. It draws its own interface through SDL, so it links no toolkit, and it loads many retro computer picture formats.

Sources

Dependencies

Depends on: pkgconf, sdl2-compat, sdl2-image, sdl2-ttf, lua54, libpng, libtiff, zlib, fontconfig, freetype2, librsvg.

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/44_apps/phase.env && kpkg install grafx2'

What kpkg does

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

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/graphics/grafx2
echo '343d3c39cf89a60617858e0c7311bd261d90e28b8ae8794ae177edf6fc1b1556  grafx2-2.9.tar.gz' | sha256sum -c -
echo '23dec191a766b55d6057a8886285cee9defcccecb141ae777f4245a6dc63e3dc  recoil-6.4.2.tar.gz' | sha256sum -c -
echo 'bba50f327163d40b1014f5affc8042137f37b200dae50a4f0fe56b5769b3940f  6502-v0.1.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/grafx2
SRC=$SRC_ROOT/grafx2-2.9
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf grafx2-2.9.tar.gz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf recoil-6.4.2.tar.gz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf 6502-v0.1.tar.xz -C "$SRC_ROOT"

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 _recoil and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

cp -a "$SRC_ROOT/recoil-$_recoil" 3rdparty/
cp -a "$SRC_ROOT/6502" 3rdparty/
(cd 3rdparty/6502 && patch -p1 -i ../6502-illegal-opcode.patch)

install -d "$SRC_ROOT/shim"
printf '#!/bin/sh\nexec pkg-config sdl2 "$@"\n' > "$SRC_ROOT/shim/sdl2-config"
chmod 755 "$SRC_ROOT/shim/sdl2-config"
export PATH="$SRC_ROOT/shim:$PATH"

export CFLAGS="$CFLAGS -g0"

_opts="API=sdl2 NO_X11=1 LUAPKG=lua5.4 PREFIX=/usr"
make -C src $_opts
make -C src $_opts DESTDIR=$PKG install

mv "$PKG/usr/bin/grafx2-sdl2" "$PKG/usr/bin/grafx2"

for s in 48 64 128; do
	install -d "$PKG/usr/share/icons/hicolor/${s}x${s}/apps"
	rsvg-convert -w $s -h $s share/icons/grafx2.svg \
		-o "$PKG/usr/share/icons/hicolor/${s}x${s}/apps/grafx2.png"
done

cat > "$PKG/usr/share/applications/grafx2.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=GrafX2
GenericName=Pixel Art Editor
Comment=Draw pixel art and edit indexed-colour pictures
TryExec=grafx2
Exec=grafx2 %f
Icon=grafx2
Terminal=false
StartupWMClass=grafx2
Categories=Graphics;2DGraphics;RasterGraphics;
Keywords=pixel;art;paint;sprite;palette;deluxe;grafx2;
DESKTOP
chmod 644 "$PKG/usr/share/applications/grafx2.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/grafx2, 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 grafx2-2.9-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/grafx2, and runs the triggers its paths call for.

Contents

Installed programs: grafx2.

Installed directories: /usr/share/grafx2, /usr/share/licenses/grafx2.

Notes

RECOIL, the retro-format picture decoder, and a 6502 emulator core are compiled into the program from 3rdparty/. When their sources are missing, src/Makefile calls 3rdparty/Makefile, which downloads them, and which asks GitHub and other upstream sites for their newest library releases as soon as make reads it. The two later sources are those trees: build.sh copies them into 3rdparty/ first, and applies 3rdparty/6502-illegal-opcode.patch, which ships in the GrafX2 tarball, to the 6502 core, so the build fetches nothing. RECOIL’s version, _recoil in the recipe, must be the RECOILVER that 3rdparty/Makefile names, or the makefile looks for a directory that is not there.

sdl2-compat installs no sdl2-config, and src/Makefile runs that name for the SDL 2 flags. A two-line shim in $SRC_ROOT/shim, put first on PATH, answers from pkg-config sdl2 instead.

The makefile names the binary after its front end, grafx2-sdl2. It is installed as plain grafx2, the name the window’s app id carries; the program finds its data at ../share/grafx2 from the binary, which the rename keeps.

Upstream ships its icon as SVG and XPM, which the panel does not read, so build.sh rasterises the SVG into hicolor PNGs. Upstream’s desktop entry is replaced: it claims PNG, GIF and BMP among its MIME types, which belong to the image viewer.