105 lines
2.5 KiB
Bash
Executable File
105 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Sign all packages in build-output
|
|
|
|
set -e
|
|
|
|
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
|
source "$BUILD_ROOT/lib/message-helpers.sh"
|
|
|
|
ARCH=${ARCH:-x86_64}
|
|
BUILD_OUTPUT_DIR="$BUILD_ROOT/build-output/$ARCH"
|
|
BUILD_DIR="$BUILD_ROOT/build"
|
|
|
|
print_header "Sign Packages"
|
|
|
|
# Parse arguments
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--arch)
|
|
ARCH="$2"
|
|
shift 2
|
|
;;
|
|
-h | --help)
|
|
echo "Usage: $0 [OPTIONS]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --arch <arch> Target architecture (x86_64 or aarch64, default: x86_64)"
|
|
echo " -h, --help Show this help message"
|
|
echo ""
|
|
echo "This script signs all packages in build-output/"
|
|
exit 0
|
|
;;
|
|
*)
|
|
print_error "Unknown option: $1"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
print_info "Target architecture: $ARCH"
|
|
print_info "Build output: $BUILD_OUTPUT_DIR"
|
|
|
|
# Check if build output exists
|
|
if [[ ! -d "$BUILD_OUTPUT_DIR" ]]; then
|
|
print_error "Build output directory not found: $BUILD_OUTPUT_DIR"
|
|
print_warning "Run bin/repo build first"
|
|
exit 1
|
|
fi
|
|
|
|
# Check for Docker
|
|
if ! command -v docker &>/dev/null; then
|
|
print_error "Docker is not installed"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if Docker daemon is running
|
|
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
|
|
|
|
# Check GPG credentials are in environment
|
|
if [[ -z "$GPG_PRIVATE_KEY" ]]; then
|
|
print_error "GPG_PRIVATE_KEY environment variable not set"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$GPG_PASSPHRASE" ]]; then
|
|
print_error "GPG_PASSPHRASE environment variable not set"
|
|
exit 1
|
|
fi
|
|
|
|
# Build/update the Docker image (reuse same image as build)
|
|
print_info "Building Docker image..."
|
|
docker build -t omarchy-aur-builder:latest -f "$BUILD_DIR/Dockerfile" "$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
|
|
|
|
# Run the signing script in Docker
|
|
docker run --rm \
|
|
-e ARCH="$ARCH" \
|
|
-e GPG_PRIVATE_KEY="$GPG_PRIVATE_KEY" \
|
|
-e GPG_PASSPHRASE="$GPG_PASSPHRASE" \
|
|
-v "$BUILD_ROOT/build-output:/build-output" \
|
|
-v "$BUILD_DIR:/build:ro" \
|
|
omarchy-aur-builder:latest /build/sign.sh
|
|
|
|
SIGN_RESULT=$?
|
|
|
|
# Summary
|
|
echo ""
|
|
if [[ $SIGN_RESULT -eq 0 ]]; then
|
|
print_success "Package signing completed successfully!"
|
|
else
|
|
print_error "Package signing failed"
|
|
exit $SIGN_RESULT
|
|
fi
|