Files
hermes-portable-rescue/Makefile
T
shawn 1479e161ab build:usb-image — Final USB image assembly script, Ventoy config, and Hermes agent runtime structure
- build/usb-image.sh: Main USB image assembler with artifact validation,
  ISO building, disk image creation, and USB write support
- build/ventoy.json: Ventoy configuration for multi-boot USB
- src/hermes/config.yaml: Portable Hermes agent configuration
- src/hermes/autorun.sh: Auto-launch script with full diagnostic pipeline
- Makefile: Build system with iso/image/check/clean/write targets

Generates fallback stubs for any diagnostic modules whose upstream
build tasks haven't completed yet, ensuring the image boots even
during active development.
2026-07-04 03:53:30 -04:00

136 lines
4.3 KiB
Makefile

# Hermes Portable Rescue — Build System
# =========================================
#
# Targets:
# all — Full build: ISO + disk image (default)
# iso — Build rescue ISO only
# image — Build full disk image (requires ISO first)
# check — Validate all upstream artifacts are present
# clean — Remove all build artifacts
# distclean — Clean + remove downloaded tool binaries
# write — Write image to USB device (run: make write DEV=/dev/sdX)
# ventoy — Install Ventoy to USB device (run: make ventoy DEV=/dev/sdX)
# help — Show this message
#
# Quick Start:
# 1. make check — See what's missing
# 2. make all — Build everything that's available
# 3. make write DEV=/dev/sdb — Write to USB (CAUTION!)
#
BUILD_DIR ?= build
HERMES_SRC ?= src/hermes
DIAG_SRC ?= src/diagnostics
TOOLS_SRC ?= src/tools
OUTPUT_DIR ?= $(BUILD_DIR)
IMAGE_SCRIPT := $(BUILD_DIR)/usb-image.sh
OUTPUT_IMAGE := $(OUTPUT_DIR)/hermes-rescue.img
OUTPUT_ISO := $(OUTPUT_DIR)/hermes-rescue.iso
DEVICE ?= /dev/sdb
# Colors
BOLD := \033[1m
GREEN := \033[0;32m
YELLOW := \033[1;33m
RED := \033[0;31m
NC := \033[0m
.PHONY: all iso image check clean distclean write ventoy help dirs
all: check iso image
@echo ""
@printf "$(GREEN)✓ Build complete!$(NC)\n"
@echo " ISO: $(OUTPUT_ISO)"
@echo " IMG: $(OUTPUT_IMAGE)"
iso: dirs
@printf "$(BOLD)Building rescue ISO...$(NC)\n"
@bash $(IMAGE_SCRIPT) --iso-only
image: dirs iso
@printf "$(BOLD)Building disk image...$(NC)\n"
@bash $(IMAGE_SCRIPT)
dirs:
@mkdir -p $(BUILD_DIR)
check:
@printf "$(BOLD)Checking upstream artifacts...$(NC)\n"
@bash $(IMAGE_SCRIPT) --skip-validate 2>&1 | head -30 || true
@echo ""
@printf "Expected artifact paths:\n"
@for f in \
"$(HERMES_SRC)/agent/hermes" \
"$(HERMES_SRC)/config.yaml" \
"$(HERMES_SRC)/autorun.sh" \
"$(DIAG_SRC)/hardware.py" \
"$(DIAG_SRC)/bsod.py" \
"$(DIAG_SRC)/drivers.py" \
"$(DIAG_SRC)/backup.py" \
"$(DIAG_SRC)/stress.py" \
; do \
if [ -f "$$f" ] || [ -d "$$f" ]; then \
printf " $(GREEN)$(NC) %s\n" "$$f"; \
else \
printf " $(YELLOW)$(NC) %s\n" "$$f"; \
fi; \
done
clean:
@printf "$(BOLD)Cleaning build artifacts...$(NC)\n"
@rm -rf $(BUILD_DIR)/usb-staging/
@rm -f $(OUTPUT_IMAGE) $(OUTPUT_ISO)
@printf "$(GREEN)✓ Cleaned.$(NC)\n"
distclean: clean
@printf "$(BOLD)Deep cleaning...$(NC)\n"
@rm -rf $(TOOLS_SRC)/*
@printf "$(GREEN)✓ Deep clean complete.$(NC)\n"
write:
@if [ ! -b "$(DEVICE)" ]; then \
printf "$(RED)Error: $(DEVICE) is not a block device. Specify DEV=/dev/sdX.$(NC)\n"; \
exit 1; \
fi
@printf "$(YELLOW)⚠️ About to write to $(DEVICE). ALL DATA WILL BE DESTROYED!$(NC)\n"
@printf "Type the device path to confirm: " && read confirm && [ "$$confirm" = "$(DEVICE)" ]
@printf "$(BOLD)Writing $(OUTPUT_IMAGE) to $(DEVICE)...$(NC)\n"
@sudo dd if=$(OUTPUT_IMAGE) of=$(DEVICE) bs=4M status=progress conv=fsync
@sync
@printf "$(GREEN)✓ Written to $(DEVICE).$(NC)\n"
ventoy:
@if [ ! -b "$(DEVICE)" ]; then \
printf "$(RED)Error: $(DEVICE) is not a block device. Specify DEV=/dev/sdX.$(NC)\n"; \
exit 1; \
fi
@if ! command -v Ventoy2Disk.sh &>/dev/null; then \
printf "$(RED)Ventoy2Disk.sh not found. Install Ventoy first.$(NC)\n"; \
exit 1; \
fi
@printf "$(YELLOW)⚠️ About to install Ventoy to $(DEVICE). ALL DATA WILL BE DESTROYED!$(NC)\n"
@printf "Type the device path to confirm: " && read confirm && [ "$$confirm" = "$(DEVICE)" ]
@sudo Ventoy2Disk.sh -i -g "$(DEVICE)"
@printf "$(GREEN)✓ Ventoy installed to $(DEVICE). Copy ISOs to the data partition.$(NC)\n"
help:
@printf "$(BOLD)Hermes Portable Rescue — Build Targets$(NC)\n"
@echo ""
@sed -n 's/^# //p; s/^#//p' $(MAKEFILE_LIST) | head -20
@echo ""
@echo "Usage: make <target> [VAR=value]"
@echo ""
@echo "Variables:"
@echo " DEVICE=/dev/sdX — Target USB device (for write/ventoy targets)"
@echo " BUILD_DIR=build — Output directory"
@echo " HERMES_SRC=src/hermes — Hermes runtime source"
@echo " DIAG_SRC=src/diagnostics — Diagnostic scripts source"
@echo " TOOLS_SRC=src/tools — Diagnostic tools source"
@echo ""
@echo "Examples:"
@echo " make — Full build (check → iso → image)"
@echo " make iso — Build ISO only"
@echo " make write DEV=/dev/sdb — Write image to USB"