MCPcopy Index your code
hub / github.com/AerynOS/blsforme

github.com/AerynOS/blsforme @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
132 symbols 262 edges 20 files 79 documented · 60%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

blsforme

A management tool and library enabling Linux distributions to more easily adopt the Boot Loader Specification.

  • Discovery of ESP through Boot Loader Interface - allow suppression of ESP & XBOOTLDR automounting to alleviate weak data integrity concerns.
  • Automatic promotion of kernels/initrds to $BOOT
  • Synchronise $BOOT state with the source intent, i.e. mirroring /usr/lib/kernel to facilitate garbage collection.
  • Cascading filesystem policy allowing vendor overrides/masking for initrds, cmdlines, etc.
  • Heavy focus on enabling type 1 BLS entries with automatic root= cmdline generation.
  • XBOOTLDR support per the Discoverable Partitions Specification
  • Concrete policy for kernel packaging, prebuilt vendor initrds, etc.
  • Rudimentary fallback for non-UEFI cases (GRUB2 chained bootloader)

Primarily this tooling has been designed to assist the moss package manager, but will remain agnostic to support the use case of Solus and other interested parties.

Testing

# Update your clone with git pull
# Build fresh release
cargo build
# Show commit of the build
git log -1
# Run blsforme test
sudo RUST_LOG=trace ./target/debug/blsctl status
# Compare to existing boot arguments
cat /proc/cmdline
# Compare blsforme discovery to blkid discovery
sudo lsblk -f

Paste a suitable excerpt of the above to e.g. https://bpa.st and link to it in the 'General - AerynOS' channel on Zulip

Difference to alternatives

As the original author of clr-boot-manager it needs listing here as "prior art", in terms of synchronising $BOOT and /usr/lib/kernel for type 1 BLS entries.

However the original design has a number of weaknesses and doesn't provide a sane schema for the automated discovery of kernel assets without a compile-time vendor prefix.

In a similar vein, kernel-install is very fuzzy on type 1 vendoring and instead relies on plugins to generate an initramfs (or indeed a staging directory for dracut via a package trigger).

Additionally kernel-install is designed to be a one-shot utility invoked by packaging triggers (or users) rather than a more contained facility to synchronise the target ESP (or $BOOT) with the expected state as provided by the final package-managed state.

In the scope of AerynOS and Solus - prebuilt initrds have been in use for years with great success. Given the requirement for both distributions to function correctly in dual-boot and non-appliance use cases, a .uki isn't going to permit our use case of generating dynamic cmdlines and shipping pre-signed assets.

Filesystem layout

For discovery to work, blsforme expects kernels to live in versioned directories under /usr/lib/kernel:

    /usr/lib/kernel
        6.8.9-289.current/
            vmlinuz # Kernel boot image

            boot.json # Kernel manifest

            # Version specific files.
            10-default.initrd
            10-default.cmdline

        initrd.d/
            # Non-version specific initrd
            01-firmware.initrd

        cmdline.d/
            99-global.cmdline

    /etc/kernel
        initrd.d/
            # Non-version specific
            ...
        cmdline.d/
            00-local.cmdline

        cmdline -> cmdline.d/00-local.cmdline

boot.json

To further facilitate the development of utilities to enumerate and manipulate boot entries, we augment the kernel packages with a JSON file. Right now this is a developing format which primarily lists the variant of the kernel, allowing users to set their preferred default variant when updating/manipulating kernels. As an example, lts vs mainline.

{
    "name": "linux-current",
    "version": "6.8.9-289.current", /* uname -r */
    "variant": "lts", /* effectively a grouping key. */
}

License

blsforme is available under the terms of the MPL-2.0

Extension points exported contracts — how you extend this code

MapDecode (Interface)
Private helper to decode types from a map Ok it's not the most efficient way, we could use Cow on a Read... It just gets [6 …
blsforme/src/os_release.rs
PathExt (Interface)
Case-insensitive path joining for FAT, respecting existing entries on the filesystem Note, this discards errors, so will [1 …
blsforme/src/file_utils.rs

Core symbols most depended-on inside this repo

iter
called by 33
crates/topology/src/disk/mounts.rs
join_insensitive
called by 17
blsforme/src/file_utils.rs
path
called by 15
blsforme/src/lib.rs
esp
called by 4
blsforme/src/bootenv.rs
xbootldr
called by 4
blsforme/src/bootenv.rs
as_str
called by 4
blsforme/src/bootloader/systemd_boot/interface.rs
cmdline_snippet
called by 3
blsforme/src/file_utils.rs
os_namespace
called by 3
blsforme/src/kernel.rs

Shape

Method 78
Class 25
Function 14
Enum 13
Interface 2

Languages

Rust100%

Modules by API surface

blsforme/src/manager.rs14 symbols
blsforme/src/kernel.rs14 symbols
blsforme/src/entry.rs11 symbols
blsforme/src/bootloader/systemd_boot/interface.rs11 symbols
blsforme/src/os_release.rs10 symbols
blsforme/src/bootloader/systemd_boot/mod.rs10 symbols
crates/topology/src/disk/mounts.rs9 symbols
blsforme/src/bootenv.rs9 symbols
crates/topology/src/disk/probe.rs8 symbols
blsctl/src/main.rs8 symbols
crates/topology/src/disk/builder.rs6 symbols
blsforme/src/file_utils.rs6 symbols

For agents

$ claude mcp add blsforme \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact