diff --git a/bin/build b/bin/build index f4486c7..f1ad346 100755 --- a/bin/build +++ b/bin/build @@ -7,16 +7,10 @@ set -e BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") source "$BUILD_ROOT/helpers/message-helpers.sh" source "$BUILD_ROOT/helpers/docker-helpers.sh" - -ARCH=${ARCH:-x86_64} - -BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH" -FINAL_OUTPUT_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH" -SRC_DIR="$BUILD_ROOT/src" -BUILD_DIR="$BUILD_ROOT/build" +source "$BUILD_ROOT/helpers/paths.sh" # Create directories if they don't exist -mkdir -p "$BUILD_OUTPUT_DIR" "$FINAL_OUTPUT_DIR" "$SRC_DIR" +mkdir -p "$BUILD_OUTPUT_DIR" "$REPO_DIR" "$SRC_DIR" print_header "Omarchy AUR Package Builder" @@ -28,6 +22,7 @@ while [[ $# -gt 0 ]]; do case $1 in --arch) ARCH="$2" + update_arch_paths shift 2 ;; --package) @@ -67,7 +62,7 @@ done # Show target architecture after parsing args print_info "Target architecture: $ARCH" print_info "Build workspace: $BUILD_OUTPUT_DIR" -print_info "Final output: $FINAL_OUTPUT_DIR" +print_info "Final output: $REPO_DIR" # Clean build-output directory to start fresh print_info "Cleaning build workspace..." @@ -91,7 +86,7 @@ print_info "Running AUR package build..." # Ensure output directories are writable by container user make_dir_writable "$BUILD_OUTPUT_DIR" -make_dir_writable "$FINAL_OUTPUT_DIR" +make_dir_writable "$REPO_DIR" # Build Docker arguments DOCKER_ARGS=( diff --git a/bin/clean-repo b/bin/clean-repo index 5d512d9..2d5e93f 100755 --- a/bin/clean-repo +++ b/bin/clean-repo @@ -7,10 +7,9 @@ set -e # Source common functions BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") source "$BUILD_ROOT/helpers/message-helpers.sh" +source "$BUILD_ROOT/helpers/paths.sh" # Repository configuration -ARCH=${ARCH:-x86_64} -ARCH_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH" KEEP_VERSIONS=2 # Function to clean old packages @@ -20,7 +19,7 @@ clean_packages() { print_info "Cleaning old packages (keeping $keep versions)..." - cd "$ARCH_DIR" + cd "$REPO_DIR" # Group packages by name declare -A packages @@ -105,7 +104,7 @@ remove_all_packages() { fi fi - cd "$ARCH_DIR" + cd "$REPO_DIR" local count=$(ls -1 *.pkg.tar.* 2>/dev/null | wc -l) @@ -130,7 +129,7 @@ remove_all_packages() { show_disk_usage() { print_info "Repository Disk Usage:" - cd "$ARCH_DIR" + cd "$REPO_DIR" local total_size=$(du -sh . 2>/dev/null | cut -f1) local package_count=$(ls -1 *.pkg.tar.* 2>/dev/null | grep -v '\.sig$' | wc -l) diff --git a/bin/list-packages b/bin/list-packages index ba99783..d5fe61b 100755 --- a/bin/list-packages +++ b/bin/list-packages @@ -4,9 +4,9 @@ SCRIPT_DIR=$(realpath "${BASH_SOURCE[0]%/*}") BUILD_ROOT=$(realpath "$SCRIPT_DIR/..") -ARCH=${ARCH:-x86_64} -ARCH_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH" -DB_FILE="$ARCH_DIR/omarchy.db.tar.zst" +source "$BUILD_ROOT/helpers/paths.sh" + +DB_FILE="$REPO_DIR/omarchy.db.tar.zst" if [[ ! -f "$DB_FILE" ]]; then echo "Repository database not found" diff --git a/bin/promote-build b/bin/promote-build index 94f3ba6..209589e 100755 --- a/bin/promote-build +++ b/bin/promote-build @@ -5,10 +5,7 @@ set -e BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") source "$BUILD_ROOT/helpers/message-helpers.sh" - -ARCH=${ARCH:-x86_64} -BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH" -FINAL_OUTPUT_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH" +source "$BUILD_ROOT/helpers/paths.sh" print_header "Promote Build to Production" @@ -18,6 +15,7 @@ while [[ $# -gt 0 ]]; do case $1 in --arch) ARCH="$2" + update_arch_paths shift 2 ;; --dry-run) @@ -43,7 +41,7 @@ while [[ $# -gt 0 ]]; do done print_info "Build output: $BUILD_OUTPUT_DIR" -print_info "Final output: $FINAL_OUTPUT_DIR" +print_info "Final output: $REPO_DIR" # Check if build output exists if [[ ! -d "$BUILD_OUTPUT_DIR" ]]; then @@ -72,7 +70,7 @@ if [[ "$DRY_RUN" == true ]]; then done else echo "" - mkdir -p "$FINAL_OUTPUT_DIR" + mkdir -p "$REPO_DIR" # Copy all package files (excluding build database) COPIED=0 @@ -81,7 +79,7 @@ else [[ "$pkg_file" == omarchy-build.db* ]] && continue if [[ -f "$pkg_file" ]]; then - cp -v "$pkg_file" "$FINAL_OUTPUT_DIR/" + cp -v "$pkg_file" "$REPO_DIR/" COPIED=$((COPIED + 1)) fi done diff --git a/bin/release b/bin/release index c7b3b42..41e0d2b 100755 --- a/bin/release +++ b/bin/release @@ -5,8 +5,8 @@ set -e BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") source "$BUILD_ROOT/helpers/message-helpers.sh" +source "$BUILD_ROOT/helpers/paths.sh" -ARCH=${ARCH:-x86_64} SYNC_REMOTE="" SKIP_PROD_CHECK=false diff --git a/bin/remove-package b/bin/remove-package index 12252cc..4af5906 100755 --- a/bin/remove-package +++ b/bin/remove-package @@ -4,10 +4,7 @@ set -e BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") source "$BUILD_ROOT/helpers/message-helpers.sh" source "$BUILD_ROOT/helpers/docker-helpers.sh" - -ARCH=${ARCH:-x86_64} -REPO_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH" -BUILD_DIR="$BUILD_ROOT/build" +source "$BUILD_ROOT/helpers/paths.sh" print_header "Remove Package" diff --git a/bin/repo b/bin/repo index 764479f..405a452 100755 --- a/bin/repo +++ b/bin/repo @@ -10,9 +10,9 @@ BUILD_ROOT=$(realpath "$SCRIPT_DIR/..") # Source common functions source "$BUILD_ROOT/helpers/message-helpers.sh" +source "$BUILD_ROOT/helpers/paths.sh" # Setup logging with timestamps -LOG_DIR="$BUILD_ROOT/logs" mkdir -p "$LOG_DIR" # Rotate logs first - keep only the 10 most recent diff --git a/bin/sign b/bin/sign index 393ad1a..a4c4d2a 100755 --- a/bin/sign +++ b/bin/sign @@ -6,10 +6,7 @@ set -e BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") source "$BUILD_ROOT/helpers/message-helpers.sh" source "$BUILD_ROOT/helpers/docker-helpers.sh" - -ARCH=${ARCH:-x86_64} -BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH" -BUILD_DIR="$BUILD_ROOT/build" +source "$BUILD_ROOT/helpers/paths.sh" print_header "Sign Packages" @@ -18,6 +15,7 @@ while [[ $# -gt 0 ]]; do case $1 in --arch) ARCH="$2" + update_arch_paths shift 2 ;; -h | --help) diff --git a/bin/sync-aur b/bin/sync-aur index a972376..4c03da8 100755 --- a/bin/sync-aur +++ b/bin/sync-aur @@ -2,8 +2,8 @@ BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") source "$BUILD_ROOT/helpers/message-helpers.sh" +source "$BUILD_ROOT/helpers/paths.sh" -PKGBUILDS_DIR="$BUILD_ROOT/pkgbuilds" PACKAGES_FILE="$BUILD_ROOT/build/packages/omarchy-aur.packages" TEMP_DIR=$(mktemp -d) diff --git a/bin/update-repo b/bin/update-repo index a07427b..7725d92 100755 --- a/bin/update-repo +++ b/bin/update-repo @@ -8,10 +8,7 @@ set -e BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..") source "$BUILD_ROOT/helpers/message-helpers.sh" source "$BUILD_ROOT/helpers/docker-helpers.sh" - -ARCH=${ARCH:-x86_64} -BUILD_DIR="$BUILD_ROOT/build" -ARCH_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH" +source "$BUILD_ROOT/helpers/paths.sh" # Function to update repository database using Docker update_database() { @@ -21,14 +18,14 @@ update_database() { check_docker # Ensure output directory exists - if [[ ! -d "$ARCH_DIR" ]]; then - print_error "Output directory not found: $ARCH_DIR" + if [[ ! -d "$REPO_DIR" ]]; then + print_error "Output directory not found: $REPO_DIR" print_warning "Run bin/repo build first" exit 1 fi # Make output directory writable for container - make_dir_writable "$ARCH_DIR" + make_dir_writable "$REPO_DIR" # Build Docker image build_docker_image "$BUILD_DIR" @@ -50,6 +47,7 @@ main() { case $1 in --arch) ARCH="$2" + update_arch_paths shift 2 ;; -h | --help) @@ -68,7 +66,7 @@ main() { done print_info "Target architecture: $ARCH" - print_info "Output directory: $ARCH_DIR" + print_info "Output directory: $REPO_DIR" update_database diff --git a/helpers/docker-helpers.sh b/helpers/docker-helpers.sh index 2cb160a..2562d10 100644 --- a/helpers/docker-helpers.sh +++ b/helpers/docker-helpers.sh @@ -1,4 +1,3 @@ -#!/bin/bash # Docker helper functions for Omarchy package build system # Check Docker is available and running diff --git a/helpers/message-helpers.sh b/helpers/message-helpers.sh index 69679b0..0078c51 100644 --- a/helpers/message-helpers.sh +++ b/helpers/message-helpers.sh @@ -1,4 +1,3 @@ -#!/bin/bash # Common printing functions for Omarchy scripts # Colors diff --git a/helpers/paths.sh b/helpers/paths.sh new file mode 100644 index 0000000..db1d154 --- /dev/null +++ b/helpers/paths.sh @@ -0,0 +1,21 @@ +# Common path variables for Omarchy package build system +# This file should be sourced after setting BUILD_ROOT + +# Default architecture +ARCH=${ARCH:-x86_64} + +# Core directories (architecture-independent) +BUILD_DIR="$BUILD_ROOT/build" +SRC_DIR="$BUILD_ROOT/src" +LOG_DIR="$BUILD_ROOT/logs" +PKGBUILDS_DIR="$BUILD_ROOT/pkgbuilds" + +# Function to update architecture-specific paths +# Call this after changing ARCH variable +update_arch_paths() { + BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH" # Unsigned packages + REPO_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH" # Repository (signed packages) +} + +# Initialize architecture-specific directories with default ARCH +update_arch_paths