From b44380db1df75ad20445bf0c63081b6ca969d292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Mon, 24 Aug 2026 19:12:46 -0400 Subject: [PATCH] Add omarchycn update for overlay installs with migration runner Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp --- bin/omarchy-cn-update | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 bin/omarchy-cn-update diff --git a/bin/omarchy-cn-update b/bin/omarchy-cn-update new file mode 100755 index 00000000..4889a2b1 --- /dev/null +++ b/bin/omarchy-cn-update @@ -0,0 +1,47 @@ +#!/bin/bash +# omarchy:summary=Update an overlay install: pull source, reinstall, run migrations +# omarchy:examples=omarchycn update + +set -euo pipefail + +MANIFEST="$HOME/.local/state/omarchycn/overlay-manifest" +MIGRATION_STATE="$HOME/.local/state/omarchycn/last-migration" + +if [[ ! -f $MANIFEST ]]; then + echo "Not an overlay install (no $MANIFEST)." >&2 + echo "Package-based installs update through 'omarchy update' / pacman." >&2 + exit 1 +fi + +src=$(grep -m1 '^source=' "$MANIFEST" | cut -d= -f2-) +if [[ ! -d $src/.git ]]; then + echo "Overlay source $src is not a git checkout" >&2 + exit 1 +fi + +old=$(git -C "$src" rev-parse --short HEAD) +git -C "$src" pull --ff-only +new=$(git -C "$src" rev-parse --short HEAD) +echo "Source: $old -> $new" + +"$src/bin/omarchy-cn-install-overlay" + +# Run migrations newer than the last recorded one, in filename order +last="" +if [[ -f $MIGRATION_STATE ]]; then + last=$(<"$MIGRATION_STATE") +fi + +if [[ -d $src/cn/migrations ]]; then + for m in "$src"/cn/migrations/*.sh; do + [[ -f $m ]] || continue + name="${m##*/}" + if [[ $name > $last ]]; then + echo "Migration: $name" + bash "$m" + echo "$name" > "$MIGRATION_STATE" + fi + done +fi + +echo "OmarchyCN update complete ($(omarchy-cn-version 2>/dev/null || echo unknown))"