build: add date-based release versioning script and remove hardcoded version
This commit is contained in:
@@ -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
|
||||
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# Compute and apply the Bananarchy Linux release version:
|
||||
# <year-letter><MM><DD>
|
||||
# where <year-letter> 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
|
||||
Reference in New Issue
Block a user