Files
bananarchy/scripts/build-dmenu.sh
T
Luxferre 3eb54e4306 fix(games): correct Snake self-collision on spawn, enlarge Tetris, brighten labels
Snake: the snake was initialized with its head at the left end while
moving right, so the first gravity step walked the head into its own
body and the game started at Game Over. Initialize the head at the
right end (cx) so the initial direction is valid.

Tetris: enlarge the playfield cell (10 -> 12px) so pieces are not too
small, and slow gravity (800ms base, gentler per-level ramp, 250ms
floor) so pieces do not fall too fast.

Both: brighten the secondary/dim text colour (0x0a3a0a -> 0x2f9f2f)
so score/label/menu text is actually legible on the black background.

Also wire the Games section into the real main menu: the system menu
is hardcoded in the dwm-plugin dmenu (src/sxmo-dmenu/dmenu.c), not in
sxmo_appmenu.sh, so add a 'games' builtin menu that loads
sxmo_hook_games.sh and a Games entry after Apps in the sys menu, plus
scripts/build-dmenu.sh to cross-compile dmenu.so.
2026-10-23 14:57:59 +03:00

79 lines
3.0 KiB
Bash
Executable File

#!/bin/sh
# Cross-compile the patched sxmo-dmenu plugin (dmenu.so) for armv7.
# Mirrors the dmenu section of scripts/build-sxmo-x11.sh.
set -eu
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
ROOTFS_DIR="${ROOTFS_DIR:-$BASE_DIR/rootfs}"
if [ -e "$ROOTFS_DIR" ]; then
ROOTFS_DIR="$(realpath "$ROOTFS_DIR")"
fi
exec docker run --rm --network=host \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
-v "$BASE_DIR:/bananarchy" \
-v "$ROOTFS_DIR:/target-rootfs" \
alpine:3.24 sh -eu -c '
cat > /etc/apk/repositories <<EOF
https://mirror.nura.eco/postmarketos/v26.06
https://dl-cdn.alpinelinux.org/alpine/edge/main
https://dl-cdn.alpinelinux.org/alpine/edge/community
https://dl-cdn.alpinelinux.org/alpine/edge/testing
EOF
cp /bananarchy/keys/* /etc/apk/keys/
echo "[1/3] Installing host cross-compilation toolchain..."
apk add --no-cache \
build-base \
gcc-armv7 \
g++-armv7 \
binutils-armv7 \
pkgconf >/dev/null
echo "[2/3] Preparing armv7 sysroot (X11 + xinerama/xft/fontconfig)..."
SYSROOT="/tmp/armv7-sysroot"
mkdir -p "$SYSROOT/etc/apk/keys"
cp /etc/apk/repositories "$SYSROOT/etc/apk/repositories"
cp /etc/apk/keys/* "$SYSROOT/etc/apk/keys/"
apk --root "$SYSROOT" --initdb --arch armv7 add --no-scripts \
alpine-baselayout \
musl-dev \
linux-headers \
libx11-dev \
libxinerama-dev \
libxft-dev \
fontconfig-dev \
freetype-dev >/dev/null
export PKG_CONFIG_SYSROOT_DIR="$SYSROOT"
export PKG_CONFIG_LIBDIR="$SYSROOT/usr/lib/pkgconfig:$SYSROOT/usr/share/pkgconfig"
CC="armv7-alpine-linux-musleabihf-gcc --sysroot=$SYSROOT"
STRIP="armv7-alpine-linux-musleabihf-strip"
OPT_CFLAGS="-O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -fno-plt -fomit-frame-pointer"
mkdir -p /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins
echo "[3/3] Compiling dmenu.so..."
cd /bananarchy/src/sxmo-dmenu
cp -f config.def.h config.h
DMENU_INCS="$(pkgconf --cflags x11 xinerama xft fontconfig freetype2)"
DMENU_LIBS="$(pkgconf --libs x11 xinerama xft fontconfig freetype2)"
$CC $OPT_CFLAGS -fPIC -shared -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"5.0.14-bananarchy\" -DXINERAMA $DMENU_INCS \
dmenu.c drw.c util.c $DMENU_LIBS -o /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so
$STRIP --strip-unneeded /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so
echo "Installing into overlay and (optional) target rootfs..."
mkdir -p /bananarchy/overlay/rootfs/usr/lib/dwm/plugins
cp -f /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so /bananarchy/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so
if [ -d /target-rootfs/usr/lib/dwm/plugins ]; then
cp -f /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so /target-rootfs/usr/lib/dwm/plugins/dmenu.so
fi
chown -R "$HOST_UID:$HOST_GID" \
/bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins \
/bananarchy/overlay/rootfs/usr/lib/dwm/plugins \
/bananarchy/src/sxmo-dmenu
ls -lh /bananarchy/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so
'