deb-bootc-image-builder/scripts/build-scripts/build-apt-ostree-in-container.sh
robojerk 126ee1a849
Some checks failed
particle-os CI / Test particle-os (push) Failing after 1s
particle-os CI / Integration Test (push) Has been skipped
particle-os CI / Security & Quality (push) Failing after 1s
Test particle-os Basic Functionality / test-basic (push) Failing after 1s
particle-os CI / Build and Release (push) Has been skipped
cleanup
2025-08-27 12:30:24 -07:00

129 lines
3 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Build apt-ostree in Debian container environment
# This script uses the existing deb-bootc-image-builder container infrastructure
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
WORKSPACE_PATH="/home/rob/Documents/Projects/overseer"
APT_OSTREE_PATH="$WORKSPACE_PATH/apt-ostree"
CONTAINER_NAME="apt-ostree-builder"
IMAGE_NAME="apt-ostree-builder:latest"
# Functions
log_info() {
echo -e "${BLUE} $1${NC}"
}
log_success() {
echo -e "${GREEN}$1${NC}"
}
log_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
log_error() {
echo -e "${RED}$1${NC}"
}
cleanup() {
log_info "Cleaning up container..."
podman rm -f "$CONTAINER_NAME" 2>/dev/null || true
}
# Set up cleanup on exit
trap cleanup EXIT
# Check if we're in the right directory
if [[ ! -d "$APT_OSTREE_PATH" ]]; then
log_error "apt-ostree directory not found at $APT_OSTREE_PATH"
exit 1
fi
log_info "Building apt-ostree in Debian container environment..."
# Create a temporary Dockerfile for building apt-ostree
cat > /tmp/apt-ostree.Dockerfile << 'EOF'
FROM debian:trixie
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cargo \
rustc \
pkg-config \
libostree-dev \
libapt-pkg-dev \
libglib2.0-dev \
libgirepository1.0-dev \
libgio-2.0-dev \
libpolkit-gobject-1-dev \
debootstrap \
ostree \
git \
curl \
wget \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /workspace
# Copy apt-ostree source
COPY . /workspace/
# Build command
CMD ["bash", "-c", "cargo build --release && echo 'Build completed successfully'"]
EOF
# Build the container image
log_info "Building container image..."
cd "$APT_OSTREE_PATH"
if ! podman build -f /tmp/apt-ostree.Dockerfile -t "$IMAGE_NAME" .; then
log_error "Failed to build container image"
exit 1
fi
log_success "Container image built successfully"
# Run the build in the container
log_info "Building apt-ostree in container..."
if ! podman run --rm \
--name "$CONTAINER_NAME" \
-v "$APT_OSTREE_PATH:/workspace:z" \
"$IMAGE_NAME"; then
log_error "Failed to build apt-ostree in container"
exit 1
fi
log_success "apt-ostree built successfully in Debian container!"
# Check if the binary was created
if [[ -f "$APT_OSTREE_PATH/target/release/apt-ostree" ]]; then
log_success "Binary found at: $APT_OSTREE_PATH/target/release/apt-ostree"
# Test the binary
log_info "Testing apt-ostree binary..."
if "$APT_OSTREE_PATH/target/release/apt-ostree" --help >/dev/null 2>&1; then
log_success "apt-ostree binary works correctly!"
"$APT_OSTREE_PATH/target/release/apt-ostree" --version
else
log_error "apt-ostree binary failed to run"
exit 1
fi
else
log_error "Binary not found after build"
exit 1
fi
# Clean up temporary files
rm -f /tmp/apt-ostree.Dockerfile
log_success "apt-ostree build and test completed successfully!"