From 34297628a3e8fdf48a10f868a2d56e732f6a6cba Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Mon, 27 Oct 2025 23:22:17 -0400 Subject: [PATCH] Update builds --- README.md | 26 +++++++++------ bin/build | 34 ++++++++++++------- bin/promote-build | 11 ++++--- bin/remove-package | 10 +++--- bin/sign | 10 +++--- build/{Dockerfile => Dockerfile.x86_64} | 0 build/build.sh | 44 ++++++++++++++++++------- build/sign.sh | 4 +-- helpers/docker-helpers.sh | 30 ++++++++++++++--- 9 files changed, 115 insertions(+), 54 deletions(-) rename build/{Dockerfile => Dockerfile.x86_64} (100%) diff --git a/README.md b/README.md index bb26e55..5e7962c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ This repository manages the Omarchy Package Repository, building a host of PKGBU The build system uses Docker to create a clean, reproducible build environment. Packages are built unsigned, then signed in a separate step, promoted to production, and synced to a remote server. +**Multi-Architecture Support**: The build system supports both **x86_64** and **aarch64** (ARM64) architectures. See [docs/AARCH64_BUILDS.md](docs/AARCH64_BUILDS.md) for aarch64 setup and usage. + ### Directory Structure ``` @@ -30,9 +32,10 @@ bin/repo release With options: ```bash -bin/repo release --skip-prod-check # Skip production confirmation -bin/repo release --sync-remote dev-pkgs:/ # Sync to dev remote instead -bin/repo release --package omarchy-nvim # Build only one package +bin/repo release --skip-prod-check # Skip production confirmation +bin/repo release --sync-remote dev-pkgs:/ # Sync to dev remote instead +bin/repo release --package omarchy-nvim # Build only one package +bin/repo release --package yay cursor-bin omarchy-nvim # Build multiple packages ``` ### Step-by-Step Workflow @@ -72,8 +75,10 @@ Builds packages from `pkgbuilds/` directory in a Docker container. **Examples:** ```bash -bin/repo build # Build all packages -bin/repo build --package omarchy-nvim # Build only yay +bin/repo build # Build all packages (x86_64) +bin/repo build --package omarchy-nvim # Build only one package +bin/repo build --package yay omarchy-nvim cursor-bin # Build multiple packages +bin/repo build --arch aarch64 # Build for ARM64/aarch64 ``` ### `bin/repo sign` @@ -152,7 +157,7 @@ bin/repo sync pkgs.omarchy.org/x86_64 --remote dev-pkgs:/# Sync to dev Runs the complete release workflow in sequence. **Options:** -- `--package ` - Build only a specific package +- `--package ` - Build only specific package(s) (space-separated) - `--arch ` - Target architecture (default: x86_64) - `--sync-remote ` - Rclone remote for sync (default: production) - `--skip-prod-check` - Skip production confirmation @@ -166,10 +171,11 @@ Runs the complete release workflow in sequence. **Examples:** ```bash -bin/repo release # Full workflow -bin/repo release --skip-prod-check # Skip prod confirmation -bin/repo release --sync-remote dev-pkgs:/ # Sync to dev -bin/repo release --package omarchy-nvim # Single package +bin/repo release # Full workflow +bin/repo release --skip-prod-check # Skip prod confirmation +bin/repo release --sync-remote dev-pkgs:/ # Sync to dev +bin/repo release --package omarchy-nvim # Single package +bin/repo release --package yay cursor-bin omarchy-nvim # Multiple packages ``` ### Other Commands diff --git a/bin/build b/bin/build index f1ad346..7aba76a 100755 --- a/bin/build +++ b/bin/build @@ -26,15 +26,20 @@ while [[ $# -gt 0 ]]; do shift 2 ;; --package) - SINGLE_PACKAGE="$2" - shift 2 + shift + PACKAGES="" + while [[ $# -gt 0 && ! "$1" =~ ^-- ]]; do + PACKAGES="$PACKAGES $1" + shift + done + PACKAGES="${PACKAGES# }" ;; -h | --help) echo "Usage: $0 [OPTIONS]" echo "" echo "Options:" echo " --arch Target architecture (x86_64 or aarch64, default: x86_64)" - echo " --package Build only the specified package (with optional options)" + echo " --package Build only the specified package(s) (space-separated)" echo " -h, --help Show this help message" echo "" echo "This script builds AUR packages from:" @@ -47,8 +52,7 @@ while [[ $# -gt 0 ]]; do echo "Examples:" echo " $0 --arch aarch64" echo " $0 --package yay" - echo " $0 --package \"elephant install\"" - echo " $0 --package \"owner/repo skip-pgp\"" + echo " $0 --package yay elephant cursor-bin" echo "" exit 0 ;; @@ -69,18 +73,18 @@ print_info "Cleaning build workspace..." rm -rf "$BUILD_OUTPUT_DIR"/* mkdir -p "$BUILD_OUTPUT_DIR" -# Check if AUR package list exists (only required if not building single package) -if [[ -z "$SINGLE_PACKAGE" ]]; then +# Check if AUR package list exists (only required if not building specific packages) +if [[ -z "$PACKAGES" ]]; then if [[ ! -f "$BUILD_DIR/packages/omarchy-aur.packages" ]]; then print_error "omarchy-aur.packages not found at $BUILD_DIR/packages/" exit 1 fi else - print_info "Building single package: $SINGLE_PACKAGE" + print_info "Building packages: $PACKAGES" fi # Build/update the Docker image -build_docker_image "$BUILD_DIR" +build_docker_image "$BUILD_DIR" "$ARCH" print_info "Running AUR package build..." @@ -92,7 +96,7 @@ make_dir_writable "$REPO_DIR" DOCKER_ARGS=( --rm -e ARCH="$ARCH" - -e SINGLE_PACKAGE="$SINGLE_PACKAGE" + -e PACKAGES="$PACKAGES" -v "$BUILD_ROOT/build-output:/build-output" -v "$BUILD_ROOT/pkgs.omarchy.org:/pkgs.omarchy.org" -v "$BUILD_DIR:/build:ro" @@ -105,7 +109,15 @@ if [ -d "/var/cache/pacman/pkg" ]; then fi # Run the builder with assembled args -docker run "${DOCKER_ARGS[@]}" omarchy-aur-builder:latest /build/build.sh +IMAGE_TAG="omarchy-pkg-builder:latest-$ARCH" +PLATFORM_ARG="" +if [[ "$ARCH" == "aarch64" ]]; then + PLATFORM_ARG="--platform linux/arm64" +elif [[ "$ARCH" == "x86_64" ]]; then + PLATFORM_ARG="--platform linux/amd64" +fi + +docker run $PLATFORM_ARG "${DOCKER_ARGS[@]}" "$IMAGE_TAG" /build/build.sh BUILD_RESULT=$? diff --git a/bin/promote-build b/bin/promote-build index 209589e..2724f8d 100755 --- a/bin/promote-build +++ b/bin/promote-build @@ -72,20 +72,21 @@ else echo "" mkdir -p "$REPO_DIR" - # Copy all package files (excluding build database) - COPIED=0 + # Move all package files (excluding build database) + # Using mv instead of cp avoids filesystem sync issues and is atomic + MOVED=0 for pkg_file in *.pkg.tar.*; do # Skip build database files [[ "$pkg_file" == omarchy-build.db* ]] && continue if [[ -f "$pkg_file" ]]; then - cp -v "$pkg_file" "$REPO_DIR/" - COPIED=$((COPIED + 1)) + mv -v "$pkg_file" "$REPO_DIR/" + MOVED=$((MOVED + 1)) fi done echo "" - print_success "Promoted $COPIED file(s) to pkgs.omarchy.org" + print_success "Promoted $MOVED file(s) to pkgs.omarchy.org" # Cleanup build directory after successful promotion print_info "Cleaning up build directory..." diff --git a/bin/remove-package b/bin/remove-package index 4af5906..8c1f952 100755 --- a/bin/remove-package +++ b/bin/remove-package @@ -52,20 +52,20 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 0 fi -# Build/update the Docker image -build_docker_image "$BUILD_DIR" +# Build/update the Docker image (always use x86_64 for removal - it's architecture independent) +build_docker_image "$BUILD_DIR" "x86_64" print_info "Removing package..." # Ensure directory is writable by container user make_dir_writable "$REPO_DIR" -# Run the removal script in Docker -docker run --rm \ +# Run the removal script in Docker (always use x86_64 image) +docker run --rm --platform linux/amd64 \ -e ARCH="$ARCH" \ -v "$BUILD_ROOT/pkgs.omarchy.org:/pkgs.omarchy.org" \ -v "$BUILD_DIR:/build:ro" \ - omarchy-aur-builder:latest /build/remove-package.sh "$PACKAGE_NAME" + omarchy-pkg-builder:latest-x86_64 /build/remove-package.sh "$PACKAGE_NAME" RESULT=$? diff --git a/bin/sign b/bin/sign index a4c4d2a..db6d2e5 100755 --- a/bin/sign +++ b/bin/sign @@ -59,22 +59,22 @@ if [[ -z "$GPG_PASSPHRASE" ]]; then exit 1 fi -# Build/update the Docker image (reuse same image as build) -build_docker_image "$BUILD_DIR" +# Build/update the Docker image (always use x86_64 for signing - it's architecture independent) +build_docker_image "$BUILD_DIR" "x86_64" print_info "Running package signing..." # Ensure output directory is writable by container user make_dir_writable "$BUILD_OUTPUT_DIR" -# Run the signing script in Docker -docker run --rm \ +# Run the signing script in Docker (always use x86_64 image) +docker run --rm --platform linux/amd64 \ -e ARCH="$ARCH" \ -e GPG_PRIVATE_KEY="$GPG_PRIVATE_KEY" \ -e GPG_PASSPHRASE="$GPG_PASSPHRASE" \ -v "$BUILD_ROOT/build-output:/build-output" \ -v "$BUILD_DIR:/build:ro" \ - omarchy-aur-builder:latest /build/sign.sh + omarchy-pkg-builder:latest-x86_64 /build/sign.sh SIGN_RESULT=$? diff --git a/build/Dockerfile b/build/Dockerfile.x86_64 similarity index 100% rename from build/Dockerfile rename to build/Dockerfile.x86_64 diff --git a/build/build.sh b/build/build.sh index b40f905..6dab211 100755 --- a/build/build.sh +++ b/build/build.sh @@ -264,18 +264,38 @@ echo "==> Checking which packages need building..." # First pass: determine which packages need building PACKAGES_TO_BUILD=() -for pkgdir in /pkgbuilds/*/; do - [[ ! -d "$pkgdir" ]] && continue - pkg=$(basename "$pkgdir") - [[ ! -f "$pkgdir/PKGBUILD" ]] && continue - - if check_needs_build "$pkg"; then - PACKAGES_TO_BUILD+=("$pkg") - else - echo " ✓ $pkg - already up to date" - SKIPPED_PACKAGES="$SKIPPED_PACKAGES $pkg" - fi -done + +# If PACKAGES is specified, only check those packages +if [[ -n "$PACKAGES" ]]; then + echo "==> Checking specified packages: $PACKAGES" + for pkg_name in $PACKAGES; do + if [[ ! -f "/pkgbuilds/$pkg_name/PKGBUILD" ]]; then + echo "==> ERROR: Package '$pkg_name' not found in /pkgbuilds/" + exit 1 + fi + + if check_needs_build "$pkg_name"; then + PACKAGES_TO_BUILD+=("$pkg_name") + else + echo " ✓ $pkg_name - already up to date" + SKIPPED_PACKAGES="$SKIPPED_PACKAGES $pkg_name" + fi + done +else + # Build all packages that need updates + for pkgdir in /pkgbuilds/*/; do + [[ ! -d "$pkgdir" ]] && continue + pkg=$(basename "$pkgdir") + [[ ! -f "$pkgdir/PKGBUILD" ]] && continue + + if check_needs_build "$pkg"; then + PACKAGES_TO_BUILD+=("$pkg") + else + echo " ✓ $pkg - already up to date" + SKIPPED_PACKAGES="$SKIPPED_PACKAGES $pkg" + fi + done +fi if [[ ${#PACKAGES_TO_BUILD[@]} -eq 0 ]]; then echo "==> All packages are up to date!" diff --git a/build/sign.sh b/build/sign.sh index 3924572..a05c79e 100755 --- a/build/sign.sh +++ b/build/sign.sh @@ -72,10 +72,10 @@ for pkg_file in $PACKAGE_FILES; do if gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" \ --detach-sign --use-agent --no-armor --local-user "$KEY_ID" "$pkg_file" 2>/dev/null; then echo "✓" - ((SIGNED_COUNT++)) + SIGNED_COUNT=$((SIGNED_COUNT + 1)) else echo "✗" - ((FAILED_COUNT++)) + FAILED_COUNT=$((FAILED_COUNT + 1)) fi done diff --git a/helpers/docker-helpers.sh b/helpers/docker-helpers.sh index 2562d10..0b05386 100644 --- a/helpers/docker-helpers.sh +++ b/helpers/docker-helpers.sh @@ -17,8 +17,20 @@ check_docker() { # Build the Docker image if needed build_docker_image() { local build_dir="$1" - print_info "Building Docker image..." - docker build -t omarchy-aur-builder:latest -f "$build_dir/Dockerfile" "$build_dir" + local arch="${2:-x86_64}" + local dockerfile="$build_dir/Dockerfile.$arch" + local platform="" + local image_tag="omarchy-pkg-builder:latest-$arch" + + # Set platform for Docker build + if [[ "$arch" == "aarch64" ]]; then + platform="--platform linux/arm64" + elif [[ "$arch" == "x86_64" ]]; then + platform="--platform linux/amd64" + fi + + print_info "Building Docker image for $arch..." + docker build $platform -t "$image_tag" -f "$dockerfile" "$build_dir" } # Make directory writable by Docker container user @@ -34,8 +46,18 @@ make_dir_writable() { # Run a Docker container with standard setup run_docker() { local script="$1" - shift + local arch="${2:-x86_64}" + shift 2 local -a args=("$@") + local image_tag="omarchy-pkg-builder:latest-$arch" + local platform="" - docker run --rm "${args[@]}" omarchy-aur-builder:latest "$script" + # Set platform for Docker run + if [[ "$arch" == "aarch64" ]]; then + platform="--platform linux/arm64" + elif [[ "$arch" == "x86_64" ]]; then + platform="--platform linux/amd64" + fi + + docker run --rm $platform "${args[@]}" "$image_tag" "$script" }