GNU bug report logs - #29409
GuixSD ARM port.

Previous Next

Package: guix-patches;

Reported by: Mathieu Othacehe <m.othacehe <at> gmail.com>

Date: Thu, 23 Nov 2017 09:46:01 UTC

Severity: normal

Done: Danny Milosavljevic <dannym <at> scratchpost.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: m.othacehe <at> gmail.com
To: 29409 <at> debbugs.gnu.org
Cc: Mathieu Othacehe <m.othacehe <at> gmail.com>
Subject: [bug#29409] [PATCH 4/4] bootloader: Factorize write-file-on-device.
Date: Wed,  6 Dec 2017 13:59:53 +0100
From: Mathieu Othacehe <m.othacehe <at> gmail.com>

* gnu/bootloader/extlinux.scm (install-extlinux): Factorize bootloader
  writing in a new procedure ...
* gnu/bootloader.scm (write-file-on-device): ... defined and exported here.
---
 gnu/bootloader.scm          | 21 ++++++++++++++++++++-
 gnu/bootloader/extlinux.scm |  9 ++-------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 736f119..a715ba1 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -22,6 +22,7 @@
   #:use-module (guix discovery)
   #:use-module (guix records)
   #:use-module (guix ui)
+  #:use-module (guix gexp)
   #:use-module (srfi srfi-1)
   #:export (menu-entry
             menu-entry?
@@ -55,7 +56,8 @@
             bootloader-configuration-additional-configuration
 
             %bootloaders
-            lookup-bootloader-by-name))
+            lookup-bootloader-by-name
+            write-file-on-device))
 
 
 ;;;
@@ -163,3 +165,20 @@
               (eq? name (bootloader-name bootloader)))
             (force %bootloaders))
       (leave (G_ "~a: no such bootloader~%") name)))
+
+
+;;;
+;;; Writing utils.
+;;;
+
+(define write-file-on-device
+  #~(lambda (file size device offset)
+      ;; Write SIZE bytes from FILE to DEVICE starting at OFFSET.
+      (call-with-input-file file
+        (lambda (input)
+          (let ((bv (get-bytevector-n input size)))
+            (call-with-output-file device
+              (lambda (output)
+                (seek output offset SEEK_SET)
+                (put-bytevector output bv))
+              #:binary #t))))))
diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm
index 9b6e2c7..304fb98 100644
--- a/gnu/bootloader/extlinux.scm
+++ b/gnu/bootloader/extlinux.scm
@@ -95,13 +95,8 @@ TIMEOUT ~a~%"
                   (find-files syslinux-dir "\\.c32$"))
         (unless
             (and (zero? (system* extlinux "--install" install-dir))
-                 (call-with-input-file (string-append syslinux-dir "/" #$mbr)
-                   (lambda (input)
-                     (let ((bv (get-bytevector-n input 440)))
-                       (call-with-output-file device
-                         (lambda (output)
-                           (put-bytevector output bv))
-                         #:binary #t)))))
+                 (#$write-file-on-device
+                  (string-append syslinux-dir "/" #$mbr) 440 device 0))
           (error "failed to install SYSLINUX")))))
 
 (define install-extlinux-mbr
-- 
2.7.4





This bug report was last modified 7 years and 108 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.