-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture & Design Decisions
Building a fail-safe system requires strict constraints and careful language selection. Here is the breakdown of the engineering tactics used in Melina.
We deliberately chose a hybrid approach using Ruby and Bash to separate orchestration from execution.
-
Ruby (The CLI Orchestrator): Ruby was selected for the frontend CLI (melina) due to its excellent standard libraries (FileUtils, Open3) and object-oriented structure. It handles complex logic: checking OS release, calculating ESP byte size, validating constraints, and interacting with the user safely. It does not require installing external gems, keeping the footprint minimal.
-
Bash (The Execution Engine): The actual backup script (melina-shield) is written in pure Bash. Why not Ruby? Because this script is triggered by pacman hooks during system updates. Firing up a Ruby Virtual Machine in the middle of a critical package transaction introduces unnecessary overhead and points of failure. Bash executes in milliseconds, uses minimal memory, and relies solely on core POSIX utilities (cp, rm, stat).
Most backup or snapshot tools run after an update. Melina hooks into pacman using the PreTransaction trigger. If we used a PostTransaction hook, and the system crashed during the update, the hook would never run, and the system would be left unbootable. By executing before the transaction, we guarantee that the files we are backing up are the exact ones that successfully booted the current session.
The CLI implements a strict "Fail Fast" methodology. Before modifying any system files or installing hooks, the init command verifies:
-
The presence of Arch Linux (via /etc/os-release).
-
The active presence of systemd-boot (via bootctl status).
-
The exact byte footprint of the target files against the available free bytes on the ESP.
If the ESP cannot safely hold the duplicated files, the installation aborts immediately, preventing a full disk scenario that could break the bootloader.