Three opt-in knobs for bin/build, each defaulting to today's behaviour: OMARCHY_KEEP_BUILD_WORKSPACE=1 keeps build-output/$MIRROR/$ARCH instead of wiping it, and build/build.sh now folds any packages already there into omarchy-build.db even when no database exists yet, so packages built by an earlier job (or a previous, interrupted run) resolve as dependencies of what builds next. OMARCHY_SKIP_BUILDER_IMAGE=1 uses the omarchy-pkg-builder image already present instead of building it, so a workflow can build the image once with an external BuildKit cache and fan out over package jobs that all run the same bytes. A missing image is an error, not a silent rebuild. OMARCHY_DEFER_RUNTIME_DEPS=true builds the omarchy/omarchy-settings pair with --nodeps, installing only their makedepends and checkdepends explicitly. The pair depends on each other and on packages a sharded pipeline builds in other jobs, so they cannot resolve in isolation; the assembled set is installed in one verified transaction downstream. The request is refused for anything but exactly that pair, on the host before Docker starts and again inside the container. Also fix make_dir_writable: chown -R can succeed on part of the tree and fail on files a previous container left behind as another uid, and the old `|| chmod` fallback only ran when chown failed outright. Always follow with chmod.
75 lines
1.9 KiB
Bash
75 lines
1.9 KiB
Bash
# Docker helper functions for Omarchy package build system
|
|
|
|
check_docker() {
|
|
if ! command -v docker &>/dev/null; then
|
|
print_error "Docker is not installed"
|
|
exit 1
|
|
fi
|
|
|
|
if ! docker info &>/dev/null; then
|
|
print_error "Docker daemon is not running"
|
|
print_warning "Start Docker with: sudo systemctl start docker"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
setup_qemu() {
|
|
# Setup QEMU for building ARM64 packages on x86_64 hosts
|
|
if ! docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes >/dev/null 2>&1; then
|
|
print_error "Failed to setup QEMU for ARM64 emulation"
|
|
exit 1
|
|
fi
|
|
print_success "QEMU ARM64 emulation enabled"
|
|
}
|
|
|
|
build_docker_image() {
|
|
local build_dir="$1"
|
|
local arch="${2:-x86_64}"
|
|
local mirror="${3:-edge}"
|
|
local platform=""
|
|
local image_tag="omarchy-pkg-builder:latest-$arch-$mirror"
|
|
|
|
|
|
case "$arch" in
|
|
x86_64) platform="linux/amd64" ;;
|
|
aarch64) platform="linux/arm64" ;;
|
|
*)
|
|
print_error "Unsupported architecture: $arch"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
print_info "Building Docker image for $arch ($platform) using $mirror mirror..."
|
|
|
|
docker buildx build \
|
|
--platform "$platform" \
|
|
--build-arg MIRROR="$mirror" \
|
|
--load \
|
|
-t "$image_tag" \
|
|
-f "$build_dir/Dockerfile" \
|
|
"$build_dir"
|
|
}
|
|
|
|
get_platform_arg() {
|
|
local arch="$1"
|
|
case "$arch" in
|
|
x86_64) echo "--platform linux/amd64" ;;
|
|
aarch64) echo "--platform linux/arm64" ;;
|
|
*) echo "" ;;
|
|
esac
|
|
}
|
|
|
|
make_dir_writable() {
|
|
local dir="$1"
|
|
if (( EUID == 0 )); then
|
|
chmod -R 777 "$dir"
|
|
else
|
|
# chown can succeed on part of the tree and fail on the rest (files a
|
|
# previous container left behind as another uid); the old `|| chmod`
|
|
# fallback only ran when chown failed outright, leaving those files
|
|
# unwritable. Always follow with chmod so the whole tree is usable.
|
|
sudo chown -R "$(id -u):$(id -g)" "$dir" 2>/dev/null || true
|
|
chmod -R 777 "$dir"
|
|
fi
|
|
}
|