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