This repository has been archived on 2026-10-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
omarchy-pkgs/bin/deploy
T
David Heinemeier HanssonandClaude Opus 5 51004999e7 Stop an unscoped deploy from rebuilding the whole repository
bin/build asks the local repository database which packages are already built.
A build machine has no such database, so every package looks out of date: an
unscoped 'bin/repo deploy' on this laptop would have built all 108 packages and
published them. Verified with a dry run.

deploy now refuses to run unscoped when that database is absent, and push
refuses the same combination under --yes, where nobody would see the list it
prints before publishing. Both are allowed on the repository host, which has
the database that makes the comparison meaningful.

Also states the split in the README: build, push and deploy are the three
commands that may run off the repository host; everything else works on the
published tree directly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-12 04:03:31 -07:00

152 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
# Build packages locally, then publish them from the repository host.
#
# The two halves of shipping a package built on a local machine: bin/build
# produces the artifacts, bin/push-build hands them to the host that owns the
# signing key and the complete repository.
set -e
SCRIPT_DIR=$(realpath "${BASH_SOURCE[0]%/*}")
BUILD_ROOT=$(realpath "$SCRIPT_DIR/..")
source "$BUILD_ROOT/helpers/message-helpers.sh"
source "$BUILD_ROOT/helpers/paths.sh"
source "$BUILD_ROOT/helpers/host-helpers.sh"
PACKAGES=()
PACKAGE_FLAG_GIVEN=false
HOST=""
REMOTE_ROOT=""
DRY_RUN=false
ASSUME_YES=false
print_header "Deploy (build + push)"
while [[ $# -gt 0 ]]; do
case $1 in
--arch)
ARCH="$2"
update_arch_paths
shift 2
;;
--mirror)
MIRROR="$2"
if [[ "$MIRROR" != "edge" && "$MIRROR" != "stable" ]]; then
print_error "Invalid mirror: $MIRROR (must be 'edge' or 'stable')"
exit 1
fi
update_arch_paths
shift 2
;;
--package)
shift
PACKAGE_FLAG_GIVEN=true
while [[ $# -gt 0 && ! "$1" =~ ^-- ]]; do
[[ -n "$1" ]] && PACKAGES+=("$1")
shift
done
;;
--host)
HOST="$2"
shift 2
;;
--remote-root)
REMOTE_ROOT="$2"
shift 2
;;
--dry-run)
DRY_RUN=true
shift
;;
-y | --yes)
ASSUME_YES=true
shift
;;
-h | --help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Build packages here, then publish them from the repository host."
echo ""
echo "Options:"
echo " --arch <arch> Target architecture (default: x86_64)"
echo " --mirror <mirror> Mirror to publish to (edge or stable, default: edge)"
echo " --package <names> Build and push only these packages (space-separated)"
echo " --host <host> ssh destination (default: \$OMARCHY_REPO_HOST or .repo-host)"
echo " --remote-root <path> Repository path on the host (default: /root/omarchy-pkgs)"
echo " --dry-run Show the plan, build nothing and transfer nothing"
echo " -y, --yes Do not ask for confirmation before publishing"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 --package nvidia-580xx-utils"
echo " $0 --package nvidia-580xx-utils --host root@example.com"
exit 0
;;
*)
print_error "Unknown option: $1"
exit 1
;;
esac
done
if [[ "$PACKAGE_FLAG_GIVEN" == true && ${#PACKAGES[@]} -eq 0 ]]; then
print_error "--package requires at least one package name"
exit 1
fi
# bin/build asks the local repository database what is already built. On a build
# machine that database does not exist, so every package looks unbuilt and an
# unscoped run rebuilds the entire repository and publishes it. Deploying from
# here is for the occasional heavy package, so name it.
if [[ ${#PACKAGES[@]} -eq 0 ]] && ! on_repo_host; then
print_error "--package is required when deploying from a build machine"
echo ""
echo "There is no repository database in:"
echo " $REPO_DIR"
echo ""
echo "bin/build uses it to tell which packages are already built, so without it"
echo "every package looks out of date and this would build and publish all of"
echo "them. Name the package you came here to build:"
echo " bin/repo deploy --package <name>"
echo ""
echo "Unscoped builds belong on the repository host, where 'bin/repo release'"
echo "does the same job against a real database."
exit 1
fi
echo ""
print_info "This will:"
echo " 1. Build packages locally"
echo " 2. Upload them to the repository host"
echo " 3. Sign, promote, update and sync them there"
echo ""
BUILD_ARGS=("--arch" "$ARCH" "--mirror" "$MIRROR")
PUSH_ARGS=("--arch" "$ARCH" "--mirror" "$MIRROR")
if [[ ${#PACKAGES[@]} -gt 0 ]]; then
BUILD_ARGS+=("--package" "${PACKAGES[@]}")
PUSH_ARGS+=("--package" "${PACKAGES[@]}")
fi
[[ -n "$HOST" ]] && PUSH_ARGS+=("--host" "$HOST")
[[ -n "$REMOTE_ROOT" ]] && PUSH_ARGS+=("--remote-root" "$REMOTE_ROOT")
[[ "$DRY_RUN" == true ]] && BUILD_ARGS+=("--dry-run") && PUSH_ARGS+=("--dry-run")
[[ "$ASSUME_YES" == true ]] && PUSH_ARGS+=("--yes")
# Resolve the repository host before spending build time on packages that cannot ship.
if [[ "$DRY_RUN" != true ]]; then
if ! resolve_repo_host "$HOST" >/dev/null; then
print_no_repo_host
exit 1
fi
fi
print_info "Step 1/2: Building..."
echo ""
"$SCRIPT_DIR/build" "${BUILD_ARGS[@]}"
echo ""
print_info "Step 2/2: Pushing to the repository host..."
echo ""
"$SCRIPT_DIR/push-build" "${PUSH_ARGS[@]}"