Consolidate more helpers

This commit is contained in:
Ryan Hughes
2025-10-27 00:28:46 -04:00
parent fde981aa95
commit 51a3318b10
12 changed files with 61 additions and 52 deletions
+4 -7
View File
@@ -5,7 +5,8 @@ set -e
# Source common functions
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
source "$BUILD_ROOT/helpers/message-helpers.sh"
source "$BUILD_ROOT/helpers/docker-helpers.sh"
ARCH=${ARCH:-x86_64}
@@ -89,12 +90,8 @@ build_docker_image "$BUILD_DIR"
print_info "Running AUR package build..."
# Ensure output directories are writable by container user
# The container runs as 'builder' user, so we need to make output writable
if [ "$(id -u)" -eq 0 ]; then
chmod -R 777 "$BUILD_OUTPUT_DIR" "$FINAL_OUTPUT_DIR"
else
sudo chown -R $(id -u):$(id -g) "$BUILD_OUTPUT_DIR" "$FINAL_OUTPUT_DIR" 2>/dev/null || chmod -R 777 "$BUILD_OUTPUT_DIR" "$FINAL_OUTPUT_DIR"
fi
make_dir_writable "$BUILD_OUTPUT_DIR"
make_dir_writable "$FINAL_OUTPUT_DIR"
# Build Docker arguments
DOCKER_ARGS=(
+1 -1
View File
@@ -6,7 +6,7 @@ set -e
# Source common functions
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
source "$BUILD_ROOT/helpers/message-helpers.sh"
# Repository configuration
ARCH=${ARCH:-x86_64}
+1 -1
View File
@@ -4,7 +4,7 @@
set -e
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
source "$BUILD_ROOT/helpers/message-helpers.sh"
ARCH=${ARCH:-x86_64}
BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH"
+1 -1
View File
@@ -4,7 +4,7 @@
set -e
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
source "$BUILD_ROOT/helpers/message-helpers.sh"
ARCH=${ARCH:-x86_64}
SYNC_REMOTE=""
+3 -6
View File
@@ -2,7 +2,8 @@
set -e
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
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"
@@ -60,11 +61,7 @@ build_docker_image "$BUILD_DIR"
print_info "Removing package..."
# Ensure directory is writable by container user
if [ "$(id -u)" -eq 0 ]; then
chmod -R 777 "$REPO_DIR"
else
sudo chown -R $(id -u):$(id -g) "$REPO_DIR" 2>/dev/null || chmod -R 777 "$REPO_DIR"
fi
make_dir_writable "$REPO_DIR"
# Run the removal script in Docker
docker run --rm \
+1 -1
View File
@@ -9,7 +9,7 @@ SCRIPT_DIR=$(realpath "${BASH_SOURCE[0]%/*}")
BUILD_ROOT=$(realpath "$SCRIPT_DIR/..")
# Source common functions
source "$BUILD_ROOT/lib/message-helpers.sh"
source "$BUILD_ROOT/helpers/message-helpers.sh"
# Setup logging with timestamps
LOG_DIR="$BUILD_ROOT/logs"
+3 -6
View File
@@ -4,7 +4,8 @@
set -e
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
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"
@@ -66,11 +67,7 @@ build_docker_image "$BUILD_DIR"
print_info "Running package signing..."
# Ensure output directory is writable by container user
if [ "$(id -u)" -eq 0 ]; then
chmod -R 777 "$BUILD_OUTPUT_DIR"
else
sudo chown -R $(id -u):$(id -g) "$BUILD_OUTPUT_DIR" 2>/dev/null || chmod -R 777 "$BUILD_OUTPUT_DIR"
fi
make_dir_writable "$BUILD_OUTPUT_DIR"
# Run the signing script in Docker
docker run --rm \
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
source "$BUILD_ROOT/helpers/message-helpers.sh"
PKGBUILDS_DIR="$BUILD_ROOT/pkgbuilds"
PACKAGES_FILE="$BUILD_ROOT/build/packages/omarchy-aur.packages"
+1 -1
View File
@@ -2,7 +2,7 @@
# Source common functions
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
source "$BUILD_ROOT/helpers/message-helpers.sh"
# Default remote (production)
DEFAULT_REMOTE="pkgs.omarchy.org:omarchy-pkgs"
+3 -6
View File
@@ -6,7 +6,8 @@ set -e
# Source common functions
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
source "$BUILD_ROOT/lib/message-helpers.sh"
source "$BUILD_ROOT/helpers/message-helpers.sh"
source "$BUILD_ROOT/helpers/docker-helpers.sh"
ARCH=${ARCH:-x86_64}
BUILD_DIR="$BUILD_ROOT/build"
@@ -27,11 +28,7 @@ update_database() {
fi
# Make output directory writable for container
if [ "$(id -u)" -eq 0 ]; then
chmod -R 777 "$ARCH_DIR"
else
sudo chown -R $(id -u):$(id -g) "$ARCH_DIR" 2>/dev/null || chmod -R 777 "$ARCH_DIR"
fi
make_dir_writable "$ARCH_DIR"
# Build Docker image
build_docker_image "$BUILD_DIR"
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
# Docker helper functions for Omarchy package build system
# Check Docker is available and running
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
}
# 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"
}
# Make directory writable by Docker container user
make_dir_writable() {
local dir="$1"
if [ "$(id -u)" -eq 0 ]; then
chmod -R 777 "$dir"
else
sudo chown -R $(id -u):$(id -g) "$dir" 2>/dev/null || chmod -R 777 "$dir"
fi
}
# Run a Docker container with standard setup
run_docker() {
local script="$1"
shift
local -a args=("$@")
docker run --rm "${args[@]}" omarchy-aur-builder:latest "$script"
}
@@ -36,24 +36,3 @@ print_header() {
echo -e "${BOLD}$1${NC}"
echo -e "${BOLD}================================${NC}"
}
# Check Docker is available and running
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
}
# 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"
}