feat(bootloader): restructure limine template with nested entries, //Snapshots support, and machine-id injection
- commit
- 01a505a9b7d69f881fbd6a9a188a181bd5e11587
- author
- brice · · 2026-02-28 05:22 UTC
- parent
- e3e15d5
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +24 -10
M install/configs/limine.conf.template +16 -10
| @@ -1,18 +1,24 @@ | |||
| 1 | 1 | timeout: {{TIMEOUT}} | |
| 2 | 2 | default_entry: 1 | |
| 3 | + | quiet: yes | |
| 3 | 4 | interface_branding: {{BRANDING}} | |
| 4 | 5 | interface_branding_colour: {{COLOR}} | |
| 5 | 6 | graphics: yes | |
| 6 | 7 | backdrop: 000000 | |
| 7 | 8 | ||
| 8 | - | /{{KERNEL}} | |
| 9 | - | protocol: linux | |
| 10 | - | kernel_path: boot():/vmlinuz-{{KERNEL}} | |
| 11 | - | kernel_cmdline: {{KERNEL_PARAMS}} | |
| 12 | - | module_path: boot():/initramfs-{{KERNEL}}.img | |
| 9 | + | /+{{KERNEL}} | |
| 10 | + | comment: machine-id={{MACHINE_ID}} | |
| 13 | 11 | ||
| 14 | - | /{{KERNEL}}-fallback | |
| 15 | - | protocol: linux | |
| 16 | - | kernel_path: boot():/vmlinuz-{{KERNEL}} | |
| 17 | - | kernel_cmdline: {{KERNEL_PARAMS}} | |
| 18 | - | module_path: boot():/initramfs-{{KERNEL}}-fallback.img | |
| 12 | + | //{{KERNEL}} | |
| 13 | + | protocol: linux | |
| 14 | + | kernel_path: boot():/vmlinuz-{{KERNEL}} | |
| 15 | + | kernel_cmdline: {{KERNEL_PARAMS}} | |
| 16 | + | module_path: boot():/initramfs-{{KERNEL}}.img | |
| 17 | + | ||
| 18 | + | //{{KERNEL}}-fallback | |
| 19 | + | protocol: linux | |
| 20 | + | kernel_path: boot():/vmlinuz-{{KERNEL}} | |
| 21 | + | kernel_cmdline: {{KERNEL_PARAMS}} | |
| 22 | + | module_path: boot():/initramfs-{{KERNEL}}-fallback.img | |
| 23 | + | ||
| 24 | + | //Snapshots | |
| @@ -1,18 +1,24 @@ | |||||
| 1 | timeout: {{TIMEOUT}} | 1 | timeout: {{TIMEOUT}} | ||
| 2 | default_entry: 1 | 2 | default_entry: 1 | ||
| 3 | + | quiet: yes | |||
| 3 | interface_branding: {{BRANDING}} | 4 | interface_branding: {{BRANDING}} | ||
| 4 | interface_branding_colour: {{COLOR}} | 5 | interface_branding_colour: {{COLOR}} | ||
| 5 | graphics: yes | 6 | graphics: yes | ||
| 6 | backdrop: 000000 | 7 | backdrop: 000000 | ||
| 7 | 8 | ||||
| 8 | - | /{{KERNEL}} | 9 | + | /+{{KERNEL}} |
| 9 | - | protocol: linux | 10 | + | comment: machine-id={{MACHINE_ID}} |
| 10 | - | kernel_path: boot():/vmlinuz-{{KERNEL}} | |||
| 11 | - | kernel_cmdline: {{KERNEL_PARAMS}} | |||
| 12 | - | module_path: boot():/initramfs-{{KERNEL}}.img | |||
| 13 | 11 | ||||
| 14 | - | /{{KERNEL}}-fallback | 12 | + | //{{KERNEL}} |
| 15 | - | protocol: linux | 13 | + | protocol: linux |
| 16 | - | kernel_path: boot():/vmlinuz-{{KERNEL}} | 14 | + | kernel_path: boot():/vmlinuz-{{KERNEL}} |
| 17 | - | kernel_cmdline: {{KERNEL_PARAMS}} | 15 | + | kernel_cmdline: {{KERNEL_PARAMS}} |
| 18 | - | module_path: boot():/initramfs-{{KERNEL}}-fallback.img | 16 | + | module_path: boot():/initramfs-{{KERNEL}}.img |
| 17 | + | ||||
| 18 | + | //{{KERNEL}}-fallback | |||
| 19 | + | protocol: linux | |||
| 20 | + | kernel_path: boot():/vmlinuz-{{KERNEL}} | |||
| 21 | + | kernel_cmdline: {{KERNEL_PARAMS}} | |||
| 22 | + | module_path: boot():/initramfs-{{KERNEL}}-fallback.img | |||
| 23 | + | ||||
| 24 | + | //Snapshots | |||
M internal/application/handlers/bootloader_handler.go +8 -0
| @@ -208,12 +208,20 @@ func (h *BootloaderHandler) configureLimine(ctx context.Context, cmd commands.In | |||
| 208 | 208 | return fmt.Errorf("failed to read Limine template: %w", err) | |
| 209 | 209 | } | |
| 210 | 210 | ||
| 211 | + | // Read machine-id from the installed system for limine-snapper-sync identification | |
| 212 | + | machineIDBytes, err := h.fs.ReadFile(filepath.Join(cmd.MountPoint, "etc", "machine-id")) | |
| 213 | + | machineID := strings.TrimSpace(string(machineIDBytes)) | |
| 214 | + | if err != nil || machineID == "" { | |
| 215 | + | machineID = "unknown" | |
| 216 | + | } | |
| 217 | + | ||
| 211 | 218 | limineConfig := string(templateBytes) | |
| 212 | 219 | limineConfig = strings.ReplaceAll(limineConfig, "{{TIMEOUT}}", fmt.Sprintf("%d", cmd.TimeoutSeconds)) | |
| 213 | 220 | limineConfig = strings.ReplaceAll(limineConfig, "{{BRANDING}}", cmd.Branding) | |
| 214 | 221 | limineConfig = strings.ReplaceAll(limineConfig, "{{COLOR}}", config.LimineColor) | |
| 215 | 222 | limineConfig = strings.ReplaceAll(limineConfig, "{{KERNEL}}", kernelName) | |
| 216 | 223 | limineConfig = strings.ReplaceAll(limineConfig, "{{KERNEL_PARAMS}}", kernelParams) | |
| 224 | + | limineConfig = strings.ReplaceAll(limineConfig, "{{MACHINE_ID}}", machineID) | |
| 217 | 225 | ||
| 218 | 226 | limineConfigPath := filepath.Join(cmd.MountPoint, "boot", "limine.conf") | |
| 219 | 227 | if err := h.fs.WriteFile(limineConfigPath, []byte(limineConfig), 0644); err != nil { | |
| @@ -208,12 +208,20 @@ func (h *BootloaderHandler) configureLimine(ctx context.Context, cmd commands.In | |||||
| 208 | return fmt.Errorf("failed to read Limine template: %w", err) | 208 | return fmt.Errorf("failed to read Limine template: %w", err) | ||
| 209 | } | 209 | } | ||
| 210 | 210 | ||||
| 211 | + | // Read machine-id from the installed system for limine-snapper-sync identification | |||
| 212 | + | machineIDBytes, err := h.fs.ReadFile(filepath.Join(cmd.MountPoint, "etc", "machine-id")) | |||
| 213 | + | machineID := strings.TrimSpace(string(machineIDBytes)) | |||
| 214 | + | if err != nil || machineID == "" { | |||
| 215 | + | machineID = "unknown" | |||
| 216 | + | } | |||
| 217 | + | ||||
| 211 | limineConfig := string(templateBytes) | 218 | limineConfig := string(templateBytes) | ||
| 212 | limineConfig = strings.ReplaceAll(limineConfig, "{{TIMEOUT}}", fmt.Sprintf("%d", cmd.TimeoutSeconds)) | 219 | limineConfig = strings.ReplaceAll(limineConfig, "{{TIMEOUT}}", fmt.Sprintf("%d", cmd.TimeoutSeconds)) | ||
| 213 | limineConfig = strings.ReplaceAll(limineConfig, "{{BRANDING}}", cmd.Branding) | 220 | limineConfig = strings.ReplaceAll(limineConfig, "{{BRANDING}}", cmd.Branding) | ||
| 214 | limineConfig = strings.ReplaceAll(limineConfig, "{{COLOR}}", config.LimineColor) | 221 | limineConfig = strings.ReplaceAll(limineConfig, "{{COLOR}}", config.LimineColor) | ||
| 215 | limineConfig = strings.ReplaceAll(limineConfig, "{{KERNEL}}", kernelName) | 222 | limineConfig = strings.ReplaceAll(limineConfig, "{{KERNEL}}", kernelName) | ||
| 216 | limineConfig = strings.ReplaceAll(limineConfig, "{{KERNEL_PARAMS}}", kernelParams) | 223 | limineConfig = strings.ReplaceAll(limineConfig, "{{KERNEL_PARAMS}}", kernelParams) | ||
| 224 | + | limineConfig = strings.ReplaceAll(limineConfig, "{{MACHINE_ID}}", machineID) | |||
| 217 | 225 | ||||
| 218 | limineConfigPath := filepath.Join(cmd.MountPoint, "boot", "limine.conf") | 226 | limineConfigPath := filepath.Join(cmd.MountPoint, "boot", "limine.conf") | ||
| 219 | if err := h.fs.WriteFile(limineConfigPath, []byte(limineConfig), 0644); err != nil { | 227 | if err := h.fs.WriteFile(limineConfigPath, []byte(limineConfig), 0644); err != nil { | ||