From b12cd738afc43f1b168c68d79e2eb71ab8f17d67 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Thu, 22 Oct 2026 20:20:16 +0300 Subject: [PATCH] build: add date-based release versioning script and remove hardcoded version --- AGENTS.md | 1 + MANUAL.md | 2 +- README.md | 2 -- overlay/rootfs/etc/issue | 2 +- overlay/rootfs/etc/motd | 2 +- overlay/rootfs/etc/os-release | 6 ++-- rebuild-image.sh | 6 +++- scripts/apply-bananarchy-overlay.sh | 3 ++ scripts/version.sh | 46 +++++++++++++++++++++++++++++ 9 files changed, 61 insertions(+), 9 deletions(-) create mode 100755 scripts/version.sh diff --git a/AGENTS.md b/AGENTS.md index 98afa7c..e76d824 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,6 +29,7 @@ All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7` - `./scripts/build-xlibre.sh` — Builds Xlibre `Xorg` and `libinput`/`fbdev` DDX drivers. - `./scripts/build-bantam.sh` — Fetches and cross-compiles the `bantam` AI agent. - `./scripts/generate-artwork.py` — Regenerates wallpapers, splashes, and icons from `artwork/icon-large.png`. +- `./scripts/version.sh [--print | target_rootfs]` — Computes the date-based release version (`
` with `2026 = a`) and substitutes `@BANANARCHY_VERSION@` in `etc/os-release`, `etc/issue`, and `etc/motd` (invoked automatically during overlay application and image builds). - `./chroot-shell.sh` — Opens an `armv7` container shell to manage packages in `rootfs/` (`pkg-add`, `pkg-del`, `pkg-search`). - `./rebuild-image.sh [--mkinitfs]` — Applies `overlay/rootfs/` + `prebuilt/` into `rootfs/` and produces flashable images in `images/`. - `sudo ./flash-edl.sh [device]` — Flashes `lk2nd` and the system image over Qualcomm USB EDL (`05c6:9008`). diff --git a/MANUAL.md b/MANUAL.md index 37209c3..5687e23 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -2,7 +2,7 @@ ![Bananarchy Banner](artwork/banner-800x240.png) -This manual covers flashing, operating, and customizing **Bananarchy Linux** (`v0.0.1`, Sxmo `240x320` native edition) on **Qualcomm MSM8905 / MSM8909** Nokia feature phones: +This manual covers flashing, operating, and customizing **Bananarchy Linux** (Sxmo `240x320` native edition) on **Qualcomm MSM8905 / MSM8909** Nokia feature phones: - **Nokia 8110 4G (`nokia-argon`)** - **Nokia 2720 Flip (`nokia-beatles`)** - **Nokia 800 Tough (`nokia-tough` / `nokia-coconut`)** diff --git a/README.md b/README.md index b21a5df..3fcc8f0 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,6 @@ Bananarchy targets an ultra-lightweight **Sxmo X11 (`sxmo-de-dwm`)** environment - **Pre-integrated Bantam AI agent**: cross-compiled from `https://code.luxferre.top/luxferre/bantam-cpp` and integrated into the Sxmo **Apps** menu (`Applications -> Bantam`, launching in an `st` terminal with `$HOME` as its default working directory). - **Complete on-device development & scripting stack**: `git`, `gcc`/`g++`, `make`, GNU `coreutils`, `nano` (`$EDITOR`, pre-configured in `/etc/nanorc` with `-FEDSMAGic/max%_T2`), `ed`, `less` (`$PAGER="less -RXF"`), `rlwrap`, `frotz` (Z-machine interactive fiction interpreter), `janet` + `jpm`, `perl` + `IO::Socket::SSL`, `tcl` + `tcllib`/`tcl-tls`/`sqlite-tcl`, `sqlite`, `i2c-tools`, and `v4l-utils`. -The current Bananarchy version is `v0.0.1`. - --- ## Supported MSM8909 / MSM8905 devices diff --git a/overlay/rootfs/etc/issue b/overlay/rootfs/etc/issue index f4825bf..3728832 100644 --- a/overlay/rootfs/etc/issue +++ b/overlay/rootfs/etc/issue @@ -1,2 +1,2 @@ -Welcome to Bananarchy Linux v0.0.1 (msm8909) on \l +Welcome to Bananarchy Linux @BANANARCHY_VERSION@ (msm8909) on \l diff --git a/overlay/rootfs/etc/motd b/overlay/rootfs/etc/motd index 24c89ec..2fd4b0c 100644 --- a/overlay/rootfs/etc/motd +++ b/overlay/rootfs/etc/motd @@ -1,5 +1,5 @@ ============================================================ - BANANARCHY LINUX v0.0.1 (Qualcomm MSM8905 / MSM8909) + BANANARCHY LINUX @BANANARCHY_VERSION@ (Qualcomm MSM8905 / MSM8909) 240x320 Native Sxmo * Multi-Mode T9 * QDSP6 Voice ------------------------------------------------------------ * Keypad '#' cycles T9 modes: abc / Abc / ABC / Sym / Ctl / 123 diff --git a/overlay/rootfs/etc/os-release b/overlay/rootfs/etc/os-release index 756d2b4..a3d04b8 100644 --- a/overlay/rootfs/etc/os-release +++ b/overlay/rootfs/etc/os-release @@ -1,7 +1,7 @@ -PRETTY_NAME="Bananarchy Linux v0.0.1 (msm8909)" +PRETTY_NAME="Bananarchy Linux @BANANARCHY_VERSION@ (msm8909)" NAME="Bananarchy" -VERSION_ID="v0.0.1" -VERSION="v0.0.1 (msm8909)" +VERSION_ID="@BANANARCHY_VERSION@" +VERSION="@BANANARCHY_VERSION@ (msm8909)" ID="bananarchy" ID_LIKE="postmarketos alpine" HOME_URL="https://bananahackers.net/" diff --git a/rebuild-image.sh b/rebuild-image.sh index f3247ac..2af0086 100755 --- a/rebuild-image.sh +++ b/rebuild-image.sh @@ -55,11 +55,15 @@ if [ -x "$BANANARCHY_DIR/scripts/apply-bananarchy-overlay.sh" ]; then "$BANANARCHY_DIR/scripts/apply-bananarchy-overlay.sh" "$ROOTFS_HOST" "$TARGET_DEVICE" fi +BANANARCHY_VERSION="$("$BANANARCHY_DIR/scripts/version.sh" --print)" +"$BANANARCHY_DIR/scripts/version.sh" "$ROOTFS_HOST" >/dev/null + exec docker run --rm --network=host \ -e HOST_UID="$(id -u)" \ -e HOST_GID="$(id -g)" \ -e TARGET_DEVICE="$TARGET_DEVICE" \ -e RUN_MKINITFS="$RUN_MKINITFS" \ + -e BANANARCHY_VERSION="$BANANARCHY_VERSION" \ -v "$ROOTFS_HOST:/rootfs" \ -v "$IMAGES_HOST:/images" \ -v "$BANANARCHY_DIR:/bananarchy:ro" \ @@ -92,7 +96,7 @@ EOF ROOT_UUID="a1b2c3d4-8110-4000-8000-000000000002" echo "============================================================" - echo "Building Bananarchy Linux (Sxmo 240x320) for: $TARGET_DEVICE" + echo "Building Bananarchy Linux $BANANARCHY_VERSION (Sxmo 240x320) for: $TARGET_DEVICE" echo "Source rootfs: $ROOTFS" echo "============================================================" diff --git a/scripts/apply-bananarchy-overlay.sh b/scripts/apply-bananarchy-overlay.sh index e9290a8..ef17444 100755 --- a/scripts/apply-bananarchy-overlay.sh +++ b/scripts/apply-bananarchy-overlay.sh @@ -42,6 +42,9 @@ esac echo "[1/4] Installing Bananarchy rootfs overlay (artwork, branding, Sxmo 240x320, UCM, udev)..." rm -f "$TARGET_ROOTFS/usr/bin/bantam" "$TARGET_ROOTFS/usr/local/bin/bantam" "$TARGET_ROOTFS/etc/doas.d/wheel.conf" cp -af "$BASE_DIR/overlay/rootfs/." "$TARGET_ROOTFS/" +if [ -x "$BASE_DIR/scripts/version.sh" ]; then + "$BASE_DIR/scripts/version.sh" "$TARGET_ROOTFS" +fi chown -R 10000:10000 "$TARGET_ROOTFS/home/user" 2>/dev/null || true chown 0:0 "$TARGET_ROOTFS/etc/doas.d/50-sxmo.conf" 2>/dev/null || true chmod 640 "$TARGET_ROOTFS/etc/doas.d/50-sxmo.conf" 2>/dev/null || true diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..e5880c1 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Compute and apply the Bananarchy Linux release version: +#
+# where is 'a'..'z' for (year - 2026) mod 26 (2026 = 'a'), +# followed by the two-digit local month and two-digit local day. +set -eu + +BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)" + +YEAR="$(date +%Y)" +MONTH="$(date +%m)" +DAY="$(date +%d)" + +LETTER_IDX=$(( ((YEAR - 2026) % 26 + 26) % 26 )) +YEAR_LETTER="$(printf "\\$(printf '%03o' $(( 97 + LETTER_IDX )))")" +VERSION="${BANANARCHY_VERSION:-${YEAR_LETTER}${MONTH}${DAY}}" + +if [ "${1:-}" = "--print" ] || [ "${1:-}" = "-p" ]; then + printf '%s\n' "$VERSION" + exit 0 +fi + +TARGET_ROOTFS="${1:-${ROOTFS_DIR:-$BASE_DIR/rootfs}}" + +apply_template() { + src_tpl="$1" + dst_file="$2" + if [ -f "$src_tpl" ]; then + mkdir -p "$(dirname "$dst_file")" + sed "s/@BANANARCHY_VERSION@/$VERSION/g" "$src_tpl" > "$dst_file" + elif [ -f "$dst_file" ]; then + sed -i -E \ + -e "s/@BANANARCHY_VERSION@/$VERSION/g" \ + -e "s/v0\.0\.1/$VERSION/g" \ + "$dst_file" + fi +} + +if [ -d "$TARGET_ROOTFS" ]; then + for rel in etc/os-release etc/issue etc/motd; do + apply_template "$BASE_DIR/overlay/rootfs/$rel" "$TARGET_ROOTFS/$rel" + done + echo "Applied Bananarchy version $VERSION to $TARGET_ROOTFS" +else + printf '%s\n' "$VERSION" +fi