Commit Graph

23 Commits

Author SHA1 Message Date
918570b11a fix(apt): Use binary keyring URL so apt accepts the signed-by= source (ref #89)
DefaultGPGKeyURL pointed at /secubox.gpg, which does not exist on the
public repo (200 OK was the HTML landing page falling through
try_files). And the canonical /secubox-keyring.gpg is ASCII-armored,
which apt rejects under signed-by=. Fetch /secubox-keyring.gpg.bin
(binary) directly and write it as the keyring — no dearmor needed.

Verified end-to-end in a fresh bookworm chroot:
  secubox apt setup       # OK
  apt-get update          # Hit:1 https://apt.secubox.in bookworm InRelease

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 12:23:02 +02:00
ea47958c18 chore(go): Run go mod tidy to organize dependencies
Move direct dependencies (cobra, promptui, viper, yaml.v3) out of
indirect section. Verify all tests pass and binary builds successfully.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 06:09:34 +02:00
1b13bffee3 test: Add tests for apt and clone commands
- Add TestAptCmdHelp to verify apt help output mentions setup and publish
- Add TestAptSetupRequiresRoot to verify root privilege check
- Add TestCloneCmdHelp to verify clone help output mentions tier and minimal flags
- Add TestCloneRequiresRoot to verify root privilege check

All tests pass successfully.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 06:08:33 +02:00
647f49b9f8 feat(cli): Add clone command with interactive wizard
Implements bootstrap wizard for new SecuBox installations.

Features:
- Interactive tier selection (lite/standard/pro/minimal/custom)
- APT repository auto-setup (GPG key + sources.list)
- Multi-select custom package picker
- Non-interactive mode with --tier, --minimal, --packages
- Auto-confirmation with --yes flag
- Root privilege check

Example usage:
  sudo secubox clone              # Interactive wizard
  sudo secubox clone --tier pro -y
  sudo secubox clone --minimal -y
  sudo secubox clone --packages "secubox-core,secubox-hub" -y

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 06:06:54 +02:00
8b8e3e868c feat(apt): Add server subcommands for APT repository management
Implement all six APT server subcommands for repository management:
- init: Initialize local APT repository at /srv/apt
- publish: Publish .deb packages with optional lintian validation
- sync: Sync repository to apt.secubox.in
- list: List packages in repository
- remove: Remove package from repository
- check: Verify repository integrity

All commands support global flags (--codename, --component, --dry-run, --verbose)
and delegate to corresponding methods on the apt.Server struct.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 06:02:53 +02:00
fc05dda136 feat(apt): Create parent command and setup subcommand
- Add aptCmd parent command for repository management
- Implement aptSetupCmd for client-side repository configuration
- Support persistent flags: --codename, --component, --dry-run
- Download SecuBox GPG key and configure sources.list
- Wire to rootCmd with proper initialization

Refs: #27
2026-05-11 05:59:46 +02:00
f8502dfbd0 feat(apt): Implement APT Server package with repository operations
Implements Server struct with methods for managing APT repository:
- Init: Initialize repository with reprepro
- Publish: Publish .deb packages via apt-publish.sh script
- Sync: Sync repository to remote via apt-sync.sh script
- List: List packages in repository
- Remove: Remove package from repository
- Check: Verify repository integrity

Wraps existing shell scripts (apt-publish.sh, apt-sync.sh) and provides
direct reprepro commands for APT repository server operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 05:58:01 +02:00
220218e910 feat(apt): Create package resolution for tier-based installation
- Add Tier struct with Name, Description, Packages fields
- Define Tiers map: lite, standard, pro, minimal
- Add AvailablePackages list with 14 SecuBox modules
- Implement TierPackages() to resolve tier to package list
- Implement ValidateTier() for tier validation
- Implement TierNames() for wizard display
- Add comprehensive test coverage for all functions

All tests pass: TestTierPackages, TestValidateTier, TestTierNames, TestAvailablePackages.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 05:56:32 +02:00
9f3d60024b feat(apt): Add APT Client package for repository setup
Implements TDD-based APT client with:
- GPG key download with retry logic (3 attempts, 2s backoff)
- sources.list generation for apt.secubox.in
- Complete Setup() method combining both operations
- Comprehensive test suite with 72.2% coverage

Tests cover:
- Successful GPG key download
- HTTP error handling
- Content verification
- sources.list format validation
- NewClient defaults
- Complete setup integration

Files:
- cmd/secubox/internal/apt/client.go
- cmd/secubox/internal/apt/client_test.go

This package will be used by:
- secubox apt setup command
- secubox clone wizard

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 05:52:40 +02:00
bd7dda0c6f feat(secubox): complete meta-script generator Tasks 14-17
Task 14: Arch Profiles
- Add profiles/arch/arm64.yaml and profiles/arch/amd64.yaml
- Add ResolveWithArch() to merger for base → arch → tier chain
- Add tests for arch profile resolution

Task 15: Package secubox.yaml for All Packages
- Add scripts/generate-secubox-yaml.py generator script
- Generate 131 debian/secubox.yaml files with:
  - Category detection (security, network, system, etc.)
  - Tier assignment (all, lite, standard, pro)
  - API socket and UI path detection

Task 16: APT Repository Setup
- Add apt/conf/ reprepro configuration (multi-arch arm64/amd64)
- Add apt/hooks/lintian-check pre-publish validation
- Add scripts/apt-publish.sh and scripts/apt-sync.sh
- Add apt/README.md documentation

Task 17: CI Integration
- Add .github/workflows/build-secubox-cli.yml
- Build for linux-amd64 and linux-arm64
- Version injection via ldflags
- GitHub releases on tag push

Code Quality Fixes (Tasks 10-13):
- Add atomic writes for OTA boot control files (0600 perms)
- Fix NVME device extraction (nvme0n1p2 → nvme0n1)
- Add scanner.Err() checks in hardware detection
- Fix URL injection validation in fetch command
- Add proper cleanup on checksum failures

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 05:32:29 +02:00
295a91aac4 feat(secubox): add ota command with A/B partition support
- Implement check, packages, system, all, rollback subcommands
- Add A/B partition management (root-a/root-b slot swapping)
- Support boot-count watchdog for auto-rollback after 3 failed boots
- Add --dry-run mode for safe testing
- Verify SHA256 checksums on system updates
- Support multiple release channels (stable, beta, nightly)
- Auto-detect board type for appropriate update selection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 05:12:46 +02:00
5dba0d4106 feat(secubox): add fetch command for GitHub releases
- Download pre-built images from releases
- Support --board, --version, --list, --output flags
- Verify SHA256 checksums after download
- Show download progress with ETA
- List available releases and images

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-11 05:01:27 +02:00
871d2e9198 feat(secubox): add build command with stage orchestration
- Implement Builder with Run() and RunStage() methods
- Add rootfs stage: debootstrap with ARM64 cross-compilation support
- Add partition stage: GPT partitions with ESP, root, data
- Add boot stage: U-Boot/GRUB/extlinux bootloader installation
- Add compress stage: gzip/xz/zstd compression with parallel jobs
- Add checksums stage: SHA256/SHA512 checksum generation
- Support --dry-run to preview commands without execution
- Support -j flag for parallel compression jobs
- Support --stage flag to run individual stages
- Add 12 comprehensive tests for all functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 21:57:44 +02:00
63b1656cf8 feat(secubox): add info command with hardware detection
- Detect arch, CPU, RAM from /proc and runtime
- Detect board from device tree (/proc/device-tree/model)
- Detect VM from DMI or hypervisor flag
- Suggest tier based on RAM size
- Update gen command to use hardware.Detect
- Add --json flag for scripted output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 21:28:15 +02:00
d558b269d6 feat(secubox): add interactive wizard for gen command
- Create wizard package with Run() and discoverBoards() functions
- Discover available boards from board/ directory with fallback defaults
- Prompt for board, tier, optional packages, and output formats
- Use promptui for terminal-based interactive selection UI
- Update gen.go runWizard() to integrate wizard package
- Support loading board metadata from board.yaml when available

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 21:25:08 +02:00
29d88e20d8 feat(secubox): add gen command for manifest generation
- Load board and profile configurations
- Resolve profile inheritance chain
- Apply board-specific tweaks
- Support --enable/--disable package flags
- Generate manifest.yaml and Makefile
- Fix board.yaml tier reference to match profile naming

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 21:14:03 +02:00
bf6881fc47 feat(secubox): add Makefile generator
- Generate Makefile with image, rootfs, partition, boot stages
- Support configurable output formats (gz, xz)
- Support configurable checksums (sha256, sha512)
- Add vdi, qcow2, iso extra targets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 21:10:27 +02:00
ddd87e55c7 feat(secubox): add manifest generator
- Define Manifest struct with kernel, partitions, boot, output
- Implement Generate() from Profile and Board
- Add ToYAML() for serialization with header comments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 21:08:32 +02:00
eb91fe97c7 feat(secubox): add package scanner for debian/secubox.yaml
- Define Component struct with requirements, tags, modes
- Implement Scanner to find all secubox-* packages
- Add SupportsArch() helper method
- Create secubox-core/debian/secubox.yaml example

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 20:46:57 +02:00
7501ce80fd feat(secubox): add board configuration loader
- Define Board struct with hardware, boot, interfaces
- Define Tweaks struct for board-specific overrides
- Add LoadBoard and LoadTweaks functions
- Add MOCHAbin board.yaml and tweaks.yaml
- Support missing tweaks.yaml (optional)
- Add tests for TestLoadBoard and TestLoadTweaks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 20:41:15 +02:00
2bbecfdc5f feat(secubox): add profile inheritance merger
- Implement Merger with Resolve() for inheritance chain
- Merge packages, kernel, services, sysctl, features
- Add tier-lite, tier-standard, tier-pro profiles
- Handle excluded packages removal

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 20:35:04 +02:00
c9da45fa21 feat(secubox): add profile loader with YAML parsing
- Define Profile struct with packages, kernel, services, features
- Implement Load() function for YAML files
- Add base.yaml with common SecuBox foundation
- Add unit tests for profile loading

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 20:13:08 +02:00
300a88beb8 feat(secubox): initialize Go CLI with cobra
- Add go.mod with cobra, viper, yaml dependencies
- Create main.go entry point
- Create root command with version and config flags

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-10 20:06:38 +02:00