From 2bcb57d4d1ea9f872c0af1d85a332098259b98c6 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Thu, 26 Feb 2026 12:37:33 -0500 Subject: [PATCH] Add stable migration command for edge packages --- README.md | 2 + bin/migrate-edge-to-stable | 82 ++++++++++++++++++++++++++++++++++++++ bin/repo | 5 +++ 3 files changed, 89 insertions(+) create mode 100755 bin/migrate-edge-to-stable diff --git a/README.md b/README.md index 8f1f4ed..86053a9 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,8 @@ Syncs to remote server using rclone based on the configured mirror and architect ### Other ```bash +bin/repo migrate --arch x86_64 # Migrate missing packages edge -> stable, then clean + update +bin/repo migrate --dry-run # Preview migration and cleanup bin/repo list # List packages bin/repo remove # Remove package bin/clean-docker # Clear Docker images/cache (forces fresh rebuild) diff --git a/bin/migrate-edge-to-stable b/bin/migrate-edge-to-stable new file mode 100755 index 0000000..f008a25 --- /dev/null +++ b/bin/migrate-edge-to-stable @@ -0,0 +1,82 @@ +#!/bin/bash +# Migrate package files from edge repo to stable repo without overwriting + +set -e + +BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") +source "$BUILD_ROOT/helpers/message-helpers.sh" +source "$BUILD_ROOT/helpers/paths.sh" + +DRY_RUN=false + +while [[ $# -gt 0 ]]; do + case $1 in + --arch) + ARCH="$2" + update_arch_paths + shift 2 + ;; + --dry-run) + DRY_RUN=true + shift + ;; + -h | --help) + echo "Usage: $0 [OPTIONS]" + echo "" + echo "Options:" + echo " --arch Target architecture (x86_64 or aarch64, default: x86_64)" + echo " --dry-run Preview migration and cleanup without changing files" + echo " -h, --help Show this help message" + echo "" + echo "What it does:" + echo " 1) Rsync package files from edge -> stable (without overwriting existing files)" + echo " 2) Run stable cleanup (keep 2 versions)" + echo " 3) Update stable repository database" + exit 0 + ;; + *) + print_error "Unknown option: $1" + exit 1 + ;; + esac +done + +SOURCE_DIR="$BUILD_ROOT/pkgs.omarchy.org/edge/$ARCH" +TARGET_DIR="$BUILD_ROOT/pkgs.omarchy.org/stable/$ARCH" + +print_header "Migrate Edge to Stable" +print_info "Architecture: $ARCH" +print_info "Source: $SOURCE_DIR" +print_info "Target: $TARGET_DIR" + +if [[ ! -d "$SOURCE_DIR" ]]; then + print_error "Source directory not found: $SOURCE_DIR" + exit 1 +fi + +mkdir -p "$TARGET_DIR" + +if [[ "$DRY_RUN" == true ]]; then + print_warning "DRY RUN MODE - No changes will be made" +fi + +print_info "Syncing package files from edge to stable (ignore existing)..." +RSYNC_FLAGS="-av --ignore-existing --include=*/ --include=*.pkg.tar.* --exclude=*" +if [[ "$DRY_RUN" == true ]]; then + RSYNC_FLAGS="$RSYNC_FLAGS -n" +fi + +# shellcheck disable=SC2086 +rsync $RSYNC_FLAGS "$SOURCE_DIR/" "$TARGET_DIR/" + +print_info "Cleaning stable repository..." +if [[ "$DRY_RUN" == true ]]; then + "$BUILD_ROOT/bin/repo" clean --mirror stable --arch "$ARCH" --dry-run + print_info "Skipping database update in dry run mode" +else + "$BUILD_ROOT/bin/repo" clean --mirror stable --arch "$ARCH" + print_info "Updating stable repository database..." + "$BUILD_ROOT/bin/repo" update --mirror stable --arch "$ARCH" +fi + +print_success "Migration workflow complete" diff --git a/bin/repo b/bin/repo index 6686fc3..6ca8fce 100755 --- a/bin/repo +++ b/bin/repo @@ -52,6 +52,7 @@ show_usage() { echo " promote Promote build to production (build-output → pkgs.omarchy.org)" echo " update Update repository database" echo " clean Clean old package versions" + echo " migrate Migrate edge packages into stable (no overwrite), then clean + update" echo " list List packages in repository" echo " remove Remove a specific package" echo " sync Sync repository to remote" @@ -106,6 +107,10 @@ clean) "$SCRIPT_DIR/clean-repo" "$@" 2>&1 | tee "$LOG_FILE" exit ${PIPESTATUS[0]} ;; +migrate) + "$SCRIPT_DIR/migrate-edge-to-stable" "$@" 2>&1 | tee "$LOG_FILE" + exit ${PIPESTATUS[0]} + ;; list) "$SCRIPT_DIR/list-packages" "$@" 2>&1 | tee "$LOG_FILE" exit ${PIPESTATUS[0]}