#!/bin/sh # Cross-compile pure-X11, zero-Rust, zero-gdk-pixbuf dunst + notify-send/dunstify for aarch64. set -eu BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$BASE_DIR/build-cache" "$BASE_DIR/prebuilt/dunst" exec docker run --rm --network=host \ -e HOST_UID="$(id -u)" \ -e HOST_GID="$(id -g)" \ -e FORCE_REBUILD="${FORCE_REBUILD:-0}" \ -v "$BASE_DIR:/geminux" \ alpine:3.24 sh -eu -c ' cat > /etc/apk/repositories </dev/null || true } trap cleanup_perms EXIT echo "[1/5] Installing host aarch64 cross-compile toolchain..." apk add --no-cache \ build-base \ git \ ca-certificates \ gcc-aarch64 \ binutils-aarch64 \ pkgconf \ glib-dev \ perl \ python3 >/dev/null DUNST_CACHE="/geminux/build-cache/dunst-src" if [ ! -f "$DUNST_CACHE/Makefile" ]; then echo "[1b/5] Cloning dunst v1.12.2..." rm -rf "$DUNST_CACHE" git clone --depth 1 --branch v1.12.2 https://github.com/dunst-project/dunst.git "$DUNST_CACHE" fi echo "[2/5] Preparing pure Alpine Edge aarch64 sysroot for X11-only zero-Rust dunst..." SYSROOT="/tmp/aarch64-sysroot" mkdir -p "$SYSROOT/etc/apk/keys" cat > "$SYSROOT/etc/apk/repositories" </dev/null echo "[3/5] Patching dunst to remove gdk-pixbuf and use pure-C libpng + libjpeg-turbo..." WORK="/tmp/dunst-build" rm -rf "$WORK" cp -a "$DUNST_CACHE" "$WORK" cp -f /geminux/src/dunst-notify/icon.h "$WORK/src/icon.h" cp -f /geminux/src/dunst-notify/icon.c "$WORK/src/icon.c" python3 - "$WORK" <<'"'"'PYEOF'"'"' import os, sys work = sys.argv[1] cfg = os.path.join(work, "config.mk") txt = open(cfg).read() assert "gdk-pixbuf-2.0" in txt txt = txt.replace("gdk-pixbuf-2.0 \\", "libpng \\") txt = txt.replace("pangocairo \\", "libjpeg \\\n pangocairo \\") open(cfg, "w").write(txt) notif_p = os.path.join(work, "src", "notification.c") ntxt = open(notif_p).read() old1 = """ if (n->icon_path) { GdkPixbuf *pixbuf = get_pixbuf_from_file(n->icon_path, n->min_icon_size, n->max_icon_size, draw_get_scale()); if (pixbuf) { n->icon = gdk_pixbuf_to_cairo_surface(pixbuf); g_object_unref(pixbuf); } else { LOG_W("Failed to load icon from path: '\''%s'\''", n->icon_path); } }""" new1 = """ if (n->icon_path) { n->icon = get_surface_from_file(n->icon_path, n->min_icon_size, n->max_icon_size, draw_get_scale()); if (!n->icon) { LOG_W("Failed to load icon from path: '\''%s'\''", n->icon_path); } }""" old2 = """ GdkPixbuf *icon = icon_get_for_data(new_icon, &n->icon_id, draw_get_scale(), n->min_icon_size, n->max_icon_size); n->icon = gdk_pixbuf_to_cairo_surface(icon); if (icon) g_object_unref(icon);""" new2 = """ n->icon = icon_get_for_data(new_icon, &n->icon_id, draw_get_scale(), n->min_icon_size, n->max_icon_size);""" assert old1 in ntxt and old2 in ntxt ntxt = ntxt.replace(old1, new1).replace(old2, new2) open(notif_p, "w").write(ntxt) print("PATCHED dunst src OK") PYEOF echo "[4/5] Cross-compiling X11-only dunst and notify-send/dunstify for aarch64..." export PKG_CONFIG_SYSROOT_DIR="$SYSROOT" export PKG_CONFIG_LIBDIR="$SYSROOT/usr/lib/pkgconfig:$SYSROOT/usr/share/pkgconfig" export PKG_CONFIG_PATH="" export CC="aarch64-alpine-linux-musl-gcc --sysroot=$SYSROOT" make -C "$WORK" -j"$(nproc)" \ CC="$CC" \ VERSION="1.12.2-geminux" \ WAYLAND=0 X11=1 DUNSTIFY=0 COMPLETIONS=0 SYSTEMD=0 \ PREFIX=/usr SYSCONFDIR=/etc \ dunst rm -rf /geminux/prebuilt/dunst mkdir -p /geminux/prebuilt/dunst/usr/bin \ /geminux/prebuilt/dunst/etc/dunst \ /geminux/prebuilt/dunst/usr/share/dbus-1/services cp "$WORK/dunst" /geminux/prebuilt/dunst/usr/bin/dunst cp "$WORK/dunstctl" /geminux/prebuilt/dunst/usr/bin/dunstctl chmod 755 /geminux/prebuilt/dunst/usr/bin/dunst /geminux/prebuilt/dunst/usr/bin/dunstctl NOTIFY_CFLAGS="$(pkg-config --cflags gio-2.0 glib-2.0)" NOTIFY_LIBS="$(pkg-config --libs gio-2.0 glib-2.0)" $CC -O2 -std=gnu11 -Wall /geminux/src/dunst-notify/notify-send.c \ $NOTIFY_CFLAGS $NOTIFY_LIBS \ -o /geminux/prebuilt/dunst/usr/bin/notify-send ln -sfn notify-send /geminux/prebuilt/dunst/usr/bin/dunstify chmod 755 /geminux/prebuilt/dunst/usr/bin/notify-send cat > /geminux/prebuilt/dunst/usr/share/dbus-1/services/org.knopwob.dunst.service <