Consolidate more helpers
This commit is contained in:
@@ -5,7 +5,8 @@ set -e
|
|||||||
|
|
||||||
# Source common functions
|
# Source common functions
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
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}
|
ARCH=${ARCH:-x86_64}
|
||||||
|
|
||||||
@@ -89,12 +90,8 @@ build_docker_image "$BUILD_DIR"
|
|||||||
print_info "Running AUR package build..."
|
print_info "Running AUR package build..."
|
||||||
|
|
||||||
# Ensure output directories are writable by container user
|
# Ensure output directories are writable by container user
|
||||||
# The container runs as 'builder' user, so we need to make output writable
|
make_dir_writable "$BUILD_OUTPUT_DIR"
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
make_dir_writable "$FINAL_OUTPUT_DIR"
|
||||||
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
|
|
||||||
|
|
||||||
# Build Docker arguments
|
# Build Docker arguments
|
||||||
DOCKER_ARGS=(
|
DOCKER_ARGS=(
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ set -e
|
|||||||
|
|
||||||
# Source common functions
|
# Source common functions
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
||||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
source "$BUILD_ROOT/helpers/message-helpers.sh"
|
||||||
|
|
||||||
# Repository configuration
|
# Repository configuration
|
||||||
ARCH=${ARCH:-x86_64}
|
ARCH=${ARCH:-x86_64}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
||||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
source "$BUILD_ROOT/helpers/message-helpers.sh"
|
||||||
|
|
||||||
ARCH=${ARCH:-x86_64}
|
ARCH=${ARCH:-x86_64}
|
||||||
BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH"
|
BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH"
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
||||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
source "$BUILD_ROOT/helpers/message-helpers.sh"
|
||||||
|
|
||||||
ARCH=${ARCH:-x86_64}
|
ARCH=${ARCH:-x86_64}
|
||||||
SYNC_REMOTE=""
|
SYNC_REMOTE=""
|
||||||
|
|||||||
+3
-6
@@ -2,7 +2,8 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
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}
|
ARCH=${ARCH:-x86_64}
|
||||||
REPO_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH"
|
REPO_DIR="$BUILD_ROOT/pkgs.omarchy.org/$ARCH"
|
||||||
@@ -60,11 +61,7 @@ build_docker_image "$BUILD_DIR"
|
|||||||
print_info "Removing package..."
|
print_info "Removing package..."
|
||||||
|
|
||||||
# Ensure directory is writable by container user
|
# Ensure directory is writable by container user
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
make_dir_writable "$REPO_DIR"
|
||||||
chmod -R 777 "$REPO_DIR"
|
|
||||||
else
|
|
||||||
sudo chown -R $(id -u):$(id -g) "$REPO_DIR" 2>/dev/null || chmod -R 777 "$REPO_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run the removal script in Docker
|
# Run the removal script in Docker
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ SCRIPT_DIR=$(realpath "${BASH_SOURCE[0]%/*}")
|
|||||||
BUILD_ROOT=$(realpath "$SCRIPT_DIR/..")
|
BUILD_ROOT=$(realpath "$SCRIPT_DIR/..")
|
||||||
|
|
||||||
# Source common functions
|
# Source common functions
|
||||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
source "$BUILD_ROOT/helpers/message-helpers.sh"
|
||||||
|
|
||||||
# Setup logging with timestamps
|
# Setup logging with timestamps
|
||||||
LOG_DIR="$BUILD_ROOT/logs"
|
LOG_DIR="$BUILD_ROOT/logs"
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
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}
|
ARCH=${ARCH:-x86_64}
|
||||||
BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH"
|
BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH"
|
||||||
@@ -66,11 +67,7 @@ build_docker_image "$BUILD_DIR"
|
|||||||
print_info "Running package signing..."
|
print_info "Running package signing..."
|
||||||
|
|
||||||
# Ensure output directory is writable by container user
|
# Ensure output directory is writable by container user
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
make_dir_writable "$BUILD_OUTPUT_DIR"
|
||||||
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
|
|
||||||
|
|
||||||
# Run the signing script in Docker
|
# Run the signing script in Docker
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
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"
|
PKGBUILDS_DIR="$BUILD_ROOT/pkgbuilds"
|
||||||
PACKAGES_FILE="$BUILD_ROOT/build/packages/omarchy-aur.packages"
|
PACKAGES_FILE="$BUILD_ROOT/build/packages/omarchy-aur.packages"
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Source common functions
|
# Source common functions
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
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 (production)
|
||||||
DEFAULT_REMOTE="pkgs.omarchy.org:omarchy-pkgs"
|
DEFAULT_REMOTE="pkgs.omarchy.org:omarchy-pkgs"
|
||||||
|
|||||||
+3
-6
@@ -6,7 +6,8 @@ set -e
|
|||||||
|
|
||||||
# Source common functions
|
# Source common functions
|
||||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
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}
|
ARCH=${ARCH:-x86_64}
|
||||||
BUILD_DIR="$BUILD_ROOT/build"
|
BUILD_DIR="$BUILD_ROOT/build"
|
||||||
@@ -27,11 +28,7 @@ update_database() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Make output directory writable for container
|
# Make output directory writable for container
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
make_dir_writable "$ARCH_DIR"
|
||||||
chmod -R 777 "$ARCH_DIR"
|
|
||||||
else
|
|
||||||
sudo chown -R $(id -u):$(id -g) "$ARCH_DIR" 2>/dev/null || chmod -R 777 "$ARCH_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build Docker image
|
# Build Docker image
|
||||||
build_docker_image "$BUILD_DIR"
|
build_docker_image "$BUILD_DIR"
|
||||||
|
|||||||
@@ -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}$1${NC}"
|
||||||
echo -e "${BOLD}================================${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"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user