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
+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"
}
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
# Common printing functions for Omarchy scripts
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m' # No Color
# Message printing functions
print_info() {
echo -e "${BLUE}==>${NC} $1"
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_step() {
echo -e " ${BLUE}→${NC} $1"
}
print_header() {
echo -e "${BOLD}================================${NC}"
echo -e "${BOLD}$1${NC}"
echo -e "${BOLD}================================${NC}"
}