bootloader: limine: Simplify error handling in installation script, again.

This commit is contained in:
Hilton Chain 2026-03-21 09:21:56 +08:00
parent 1233c2154a
commit 68573186b5
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292

View File

@ -59,11 +59,11 @@
;; Install unified kernel images and generate Limine configuration.
(call-with-output-file (in-vicinity limine-directory "limine.conf.tmp")
(lambda (port)
(let* ((ukify #$(file-append ukify "/bin/ukify"))
(current-label (first '#$labels))
(current-args (first (list #$@ukify-args)))
(old-labels (cdr '#$labels))
(old-args (cdr (list #$@ukify-args))))
(let ((ukify #$(file-append ukify "/bin/ukify"))
(current-label (first '#$labels))
(current-args (first (list #$@ukify-args)))
(old-labels (cdr '#$labels))
(old-args (cdr (list #$@ukify-args))))
(format port "\
timeout: 5~%")
(with-directory-excursion guix-directory
@ -78,30 +78,29 @@ timeout: 5~%")
(unless (null? old-labels)
(format port "
/GNU system, old configurations...~%"))
(false-if-exception
(let loop ((count 1)
(labels old-labels)
(args old-args))
(let* ((image-name (format #f "OLD-~a.EFI" count)))
(unless (null? labels)
(with-exception-handler
(lambda _
(delete-file image-name)
;; Exit loop.
(loop 0 '() '()))
(lambda ()
(apply invoke/quiet
ukify "build" "--output" image-name
(first args))
(format port "~
(let loop ((count 1)
(labels old-labels)
(args old-args))
(let ((image-name (format #f "OLD-~a.EFI" count)))
(unless (null? labels)
(catch #t
(lambda ()
(apply invoke/quiet
ukify "build" "--output" image-name
(first args))
(format port "~
//~a
protocol: efi
path: boot():/EFI/Guix/OLD-~a.EFI~%"
(first labels)
count)))
(loop (1+ count)
(cdr labels)
(cdr args))))))))
(first labels)
count))
(lambda _
(delete-file image-name)
;; Exit loop.
(loop 0 '() '())))
(loop (1+ count)
(cdr labels)
(cdr args)))))))
(rename-file (in-vicinity limine-directory "limine.conf.tmp")
(in-vicinity limine-directory "limine.conf"))
;; Finally, install Limine.