From mboxrd@z Thu Jan 1 00:00:00 1970 From: cmmarusich@gmail.com Subject: [PATCH 07/10] Factor out procedure: install-grub-config Date: Fri, 28 Oct 2016 03:07:24 -0700 Message-ID: <20161028100727.1182-8-cmmarusich@gmail.com> References: <20161028100727.1182-1-cmmarusich@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c044n-0004SA-82 for guix-devel@gnu.org; Fri, 28 Oct 2016 06:07:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c044m-00040l-9e for guix-devel@gnu.org; Fri, 28 Oct 2016 06:07:53 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:34590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c044m-0003zj-1U for guix-devel@gnu.org; Fri, 28 Oct 2016 06:07:52 -0400 Received: by mail-pf0-x243.google.com with SMTP id u84so874990pfj.1 for ; Fri, 28 Oct 2016 03:07:52 -0700 (PDT) In-Reply-To: <20161028100727.1182-1-cmmarusich@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org From: Chris Marusich * gnu/build/install (install-grub, install-grub-config): Extract code from 'install-grub' into a new procedure 'install-grub-config'. Also, define 'install-grub' using define, not define*, since it makes no use of the extra features that define* provides. --- gnu/build/install.scm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 7431a09..3d1594e 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès +;;; Copyright © 2016 Chris Marusich ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,6 +23,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 +38,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 +63,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