From 55cf900abf6dba10ed640d24433cc1ca23e4acf2 Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Tue, 2 Aug 2016 21:28:21 -0700 Subject: [PATCH 7/9] gnu/build/install: Factor out procedure: install-grub-config --- gnu/build/install.scm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 7431a09..ce4f06e 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -22,6 +22,7 @@ #:use-module (srfi srfi-26) #:use-module (ice-9 match) #:export (install-grub + install-grub-config populate-root-file-system reset-timestamps register-closure @@ -36,13 +37,24 @@ ;;; ;;; Code: -(define* (install-grub grub.cfg device mount-point) +(define (install-grub grub.cfg device mount-point) "Install GRUB with GRUB.CFG on DEVICE, which is assumed to be mounted on MOUNT-POINT. Note that the caller must make sure that GRUB.CFG is registered as a GC root so that the fonts, background images, etc. referred to by GRUB.CFG are not GC'd." + (install-grub-config grub.cfg mount-point) + (unless (zero? (system* "grub-install" "--no-floppy" + "--boot-directory" + (string-append mount-point "/boot") + device)) + (error "failed to install GRUB"))) + +(define (install-grub-config grub.cfg mount-point) + "Atomically copy GRUB.CFG into boot/grub/grub.cfg on the MOUNT-POINT. Note +that the caller must make sure that GRUB.CFG is registered as a GC root so +that the fonts, background images, etc. referred to by GRUB.CFG are not GC'd." (let* ((target (string-append mount-point "/boot/grub/grub.cfg")) (pivot (string-append target ".new"))) (mkdir-p (dirname target)) @@ -50,13 +62,7 @@ GC'd." ;; Copy GRUB.CFG instead of just symlinking it, because symlinks won't ;; work when /boot is on a separate partition. Do that atomically. (copy-file grub.cfg pivot) - (rename-file pivot target) - - (unless (zero? (system* "grub-install" "--no-floppy" - "--boot-directory" - (string-append mount-point "/boot") - device)) - (error "failed to install GRUB")))) + (rename-file pivot target))) (define (evaluate-populate-directive directive target) "Evaluate DIRECTIVE, an sexp describing a file or directory to create under -- 2.9.2