How bjakobson/webboot works
Main Components
• Bootloader Command Modules: Represent the multiple commands under the cmds directory (for example, cmds/cli, cmds/webboot, and cmds/wifiDebug). Highlight that webboot is the central CLI tool to trigger the boot process.
• ISO Processing and Boot Infrastructure: Show the pkg modules (e.g., pkg/bootiso handles mounting, extracting kernels/initrds; pkg/menu helps with UI/menu logic; pkg/dhclient, pkg/wifi, pkg/wpa provide networking and wireless support).
• Cache/Local File Storage: Include a component for managing cached ISO files (the README describes saving downloaded ISOs to local caches like a USB stick).
• External Dependencies & u-root Integration: Emphasize that the project bootstraps a u-root initramfs with webboot’s binary and other files. Indicate integration with u-root and additional configuration (e.g., build image tools, integration tests).
Relationships and Interactions
• Data Flow from User/Console → CLI Module: Illustrate that when a user runs the “webboot” command, the CLI first fetches an ISO from the web.
• ISO Mounting and Kernel Extraction: From the ISO module, show a branch to “ISO Parsing & Extraction” (parts of pkg/bootiso and integration tests) that deals with mounting the ISO, extracting the kernel and initrd, and processing kernel parameters.
• Networking and Wireless Support: Represent modules for handling network configuration (pkg/dhclient, pkg/wifi, pkg/wpa) which the boot process relies on, particularly when booting in environments where a network must be set up.
• Final Boot via kexec: Illustrate how the extracted kernel and initrd are passed to a “Kernel Loader” component that uses kexec to boot the operating system.
• UI Integration: Include a component for the terminal UI (via termui) that sits on top of the CLI and gives a visual interface for selecting and booting distros.
Architectural Patterns and Design Principles
• Modular Structure: Emphasize how the code is organized in separate modules (e.g., cmds, pkg) to decouple the boot process steps.
• Command/Controller Pattern: The “cmds” directory is a good indicator of a command pattern where each subcommand encapsulates a particular function.
• Plugin-like Extensibility: Note how supported distros are added via a mapping (the “supportedDistros” map in cmds/webboot/types.go) and how configurations can be overridden, suggesting an extensible architecture.
• Integration with External Tools: The design shows clear separation between the build/initramfs process (via u-root) and the boot logic.
Relevant Technologies
• Go Language as the primary implementation.
• Several Go packages for booting (u-root), network management, ISO processing.
• Use of termui for the CLI interface.
• CI/CD pipelines and GitHub Actions for workflow.
• Syslinux for USB booting as described in the README.
Final Touches
• Components have clear labels.
• How the integration tests (integration/ directory and pkg test files) verify these modules.