system: reconfigure: Use the disk-installer if provided.
[jackhill/guix/guix.git] / gnu / build / bootloader.scm
index 498022f..3916930 100644 (file)
@@ -22,6 +22,8 @@
   #:use-module (guix utils)
   #:use-module (ice-9 binary-ports)
   #:use-module (ice-9 format)
+  #:use-module (rnrs io ports)
+  #:use-module (rnrs io simple)
   #:export (write-file-on-device
             install-efi-loader))
 
   (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)))))
+        (call-with-port
+         ;; Do not use "call-with-output-file" that would truncate the file.
+         (open-file-output-port device
+                                (file-options no-truncate no-fail)
+                                (buffer-mode block)
+                                ;; Use the binary-friendly ISO-8859-1
+                                ;; encoding.
+                                (make-transcoder (latin-1-codec)))
+         (lambda (output)
+           (seek output offset SEEK_SET)
+           (put-bytevector output bv)))))))
 
 \f
 ;;;