Volt CLI: source-available under AGPSL v5.0
Complete infrastructure platform CLI: - Container runtime (systemd-nspawn) - VoltVisor VMs (Neutron Stardust / QEMU) - Stellarium CAS (content-addressed storage) - ORAS Registry - GitOps integration - Landlock LSM security - Compose orchestration - Mesh networking Copyright (c) Armored Gates LLC. All rights reserved. Licensed under AGPSL v5.0
This commit is contained in:
169
scripts/build-kernels.sh
Executable file
169
scripts/build-kernels.sh
Executable file
@@ -0,0 +1,169 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Volt Platform - Kernel Build Script
|
||||
# Builds all kernel profiles from configs
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
CONFIG_DIR="$PROJECT_DIR/configs/kernels"
|
||||
OUTPUT_DIR="${OUTPUT_DIR:-/var/lib/volt/kernels}"
|
||||
KERNEL_VERSION="${KERNEL_VERSION:-6.6.15}"
|
||||
KERNEL_URL="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${KERNEL_VERSION}.tar.xz"
|
||||
BUILD_DIR="/tmp/volt-kernel-build"
|
||||
JOBS="${JOBS:-$(nproc)}"
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
log() { echo -e "${GREEN}[volt]${NC} $1"; }
|
||||
warn() { echo -e "${YELLOW}[volt]${NC} $1"; }
|
||||
error() { echo -e "${RED}[volt]${NC} $1" >&2; }
|
||||
|
||||
# Kernel profiles to build
|
||||
PROFILES=(
|
||||
"server"
|
||||
"desktop"
|
||||
"minimal"
|
||||
"rt"
|
||||
"dev"
|
||||
)
|
||||
|
||||
download_kernel() {
|
||||
log "Downloading Linux kernel ${KERNEL_VERSION}..."
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
if [[ ! -f "linux-${KERNEL_VERSION}.tar.xz" ]]; then
|
||||
curl -fSL -o "linux-${KERNEL_VERSION}.tar.xz" "$KERNEL_URL"
|
||||
fi
|
||||
|
||||
if [[ ! -d "linux-${KERNEL_VERSION}" ]]; then
|
||||
log "Extracting kernel source..."
|
||||
tar xf "linux-${KERNEL_VERSION}.tar.xz"
|
||||
fi
|
||||
}
|
||||
|
||||
build_kernel() {
|
||||
local profile="$1"
|
||||
local config_file="$CONFIG_DIR/kernel-${profile}.config"
|
||||
local output_name="kernel-${profile}"
|
||||
|
||||
log "Building kernel profile: ${profile}"
|
||||
|
||||
if [[ ! -f "$config_file" ]]; then
|
||||
warn "Config file not found: $config_file, skipping"
|
||||
return 0
|
||||
fi
|
||||
|
||||
cd "$BUILD_DIR/linux-${KERNEL_VERSION}"
|
||||
|
||||
# Clean previous build
|
||||
make mrproper
|
||||
|
||||
# Copy config
|
||||
cp "$config_file" .config
|
||||
|
||||
# Update config with defaults
|
||||
make olddefconfig
|
||||
|
||||
# Build kernel
|
||||
log "Compiling kernel (this may take a while)..."
|
||||
make -j"$JOBS" bzImage
|
||||
|
||||
# Build modules (if enabled)
|
||||
if grep -q "CONFIG_MODULES=y" .config; then
|
||||
make -j"$JOBS" modules
|
||||
fi
|
||||
|
||||
# Install to output directory
|
||||
mkdir -p "$OUTPUT_DIR/$output_name"
|
||||
|
||||
# Copy kernel image
|
||||
cp arch/x86/boot/bzImage "$OUTPUT_DIR/$output_name/vmlinuz"
|
||||
|
||||
# Copy modules if built
|
||||
if grep -q "CONFIG_MODULES=y" .config; then
|
||||
make INSTALL_MOD_PATH="$OUTPUT_DIR/$output_name" modules_install
|
||||
fi
|
||||
|
||||
# Copy config for reference
|
||||
cp .config "$OUTPUT_DIR/$output_name/config"
|
||||
|
||||
# Generate kernel info
|
||||
local size=$(du -h "$OUTPUT_DIR/$output_name/vmlinuz" | cut -f1)
|
||||
cat > "$OUTPUT_DIR/$output_name/info.json" << EOF
|
||||
{
|
||||
"profile": "${profile}",
|
||||
"version": "${KERNEL_VERSION}",
|
||||
"localversion": "-volt-${profile}",
|
||||
"size": "${size}",
|
||||
"built": "$(date -Iseconds)",
|
||||
"config_hash": "$(sha256sum "$config_file" | cut -d' ' -f1)"
|
||||
}
|
||||
EOF
|
||||
|
||||
log "Kernel ${profile} built: ${size}"
|
||||
}
|
||||
|
||||
sign_kernel() {
|
||||
local profile="$1"
|
||||
local kernel_path="$OUTPUT_DIR/kernel-${profile}/vmlinuz"
|
||||
|
||||
log "Signing kernel: ${profile}"
|
||||
|
||||
# In production, this would use proper key management
|
||||
# For now, generate signature placeholder
|
||||
sha256sum "$kernel_path" > "$OUTPUT_DIR/kernel-${profile}/vmlinuz.sha256"
|
||||
|
||||
# TODO: Integrate with ArmoredForge signing
|
||||
# armored-forge sign "$kernel_path" --key volt-kernel-key
|
||||
}
|
||||
|
||||
main() {
|
||||
log "Volt Platform Kernel Builder"
|
||||
log "================================"
|
||||
log "Kernel version: ${KERNEL_VERSION}"
|
||||
log "Output directory: ${OUTPUT_DIR}"
|
||||
log "Build jobs: ${JOBS}"
|
||||
echo ""
|
||||
|
||||
# Check dependencies
|
||||
for cmd in make gcc curl tar; do
|
||||
if ! command -v "$cmd" &>/dev/null; then
|
||||
error "Required command not found: $cmd"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Create output directory
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
# Download kernel source
|
||||
download_kernel
|
||||
|
||||
# Build each profile
|
||||
for profile in "${PROFILES[@]}"; do
|
||||
if [[ -f "$CONFIG_DIR/kernel-${profile}.config" ]]; then
|
||||
build_kernel "$profile"
|
||||
sign_kernel "$profile"
|
||||
else
|
||||
warn "Skipping ${profile} (no config file)"
|
||||
fi
|
||||
done
|
||||
|
||||
log ""
|
||||
log "Build complete!"
|
||||
log "Kernels installed to: $OUTPUT_DIR"
|
||||
ls -la "$OUTPUT_DIR"
|
||||
}
|
||||
|
||||
# Run if executed directly
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
main "$@"
|
||||
fi
|
||||
Reference in New Issue
Block a user