aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2020-10-05 10:58:55 +0200
committerMathieu Othacehe <othacehe@gnu.org>2020-10-05 11:10:35 +0200
commitb97b423e3f61c80d5877dadc95b3f316cd61788f (patch)
treeb0ba2a1458875c8e33e1430a0e04dad14ca833d8
parent525a351efaea52dbd4f93321a490397ebeb2130f (diff)
downloadguix-b97b423e3f61c80d5877dadc95b3f316cd61788f.tar
guix-b97b423e3f61c80d5877dadc95b3f316cd61788f.tar.gz
bootloader: Fix u-boot installation.
This is a follow-up of f19cf27c2b9ff92e2c0fd931ef7fde39c376adaa. The bootloader installation must be done on the final disk-image, hence using "disk-image-installer" instead of "installer" callback. * gnu/bootloader/u-boot.scm: Turn all installer callbacks into disk-image-installer callbacks. * gnu/build/bootloader.scm (write-file-on-device): Open the output file with 'no-truncate and 'no-create options. * gnu/system/image.scm (with-imported-modules*): Add (gnu build bootloader) module.
-rw-r--r--gnu/bootloader/u-boot.scm69
-rw-r--r--gnu/build/bootloader.scm15
-rw-r--r--gnu/system/image.scm2
3 files changed, 47 insertions, 39 deletions
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 1da9d04eb2..c57d4964c8 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -45,7 +45,7 @@
u-boot-wandboard-bootloader))
(define install-u-boot
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(if bootloader
(error "Failed to install U-Boot"))))
@@ -56,74 +56,74 @@
;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
;; specified DEVICE.
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(let ((mlo (string-append bootloader "/libexec/MLO"))
(u-boot (string-append bootloader "/libexec/u-boot.img")))
(write-file-on-device mlo (* 256 512)
- device (* 256 512))
+ image (* 256 512))
(write-file-on-device u-boot (* 1024 512)
- device (* 768 512)))))
+ image (* 768 512)))))
(define install-allwinner-u-boot
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(let ((u-boot (string-append bootloader
"/libexec/u-boot-sunxi-with-spl.bin")))
(write-file-on-device u-boot (stat:size (stat u-boot))
- device (* 8 1024)))))
+ image (* 8 1024)))))
(define install-allwinner64-u-boot
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(let ((spl (string-append bootloader "/libexec/spl/sunxi-spl.bin"))
(u-boot (string-append bootloader "/libexec/u-boot.itb")))
(write-file-on-device spl (stat:size (stat spl))
- device (* 8 1024))
+ image (* 8 1024))
(write-file-on-device u-boot (stat:size (stat u-boot))
- device (* 40 1024)))))
+ image (* 40 1024)))))
(define install-imx-u-boot
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(let ((spl (string-append bootloader "/libexec/SPL"))
(u-boot (string-append bootloader "/libexec/u-boot.img")))
(write-file-on-device spl (stat:size (stat spl))
- device (* 1 1024))
+ image (* 1 1024))
(write-file-on-device u-boot (stat:size (stat u-boot))
- device (* 69 1024)))))
+ image (* 69 1024)))))
(define install-puma-rk3399-u-boot
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
(u-boot (string-append bootloader "/libexec/u-boot.itb")))
(write-file-on-device spl (stat:size (stat spl))
- device (* 64 512))
+ image (* 64 512))
(write-file-on-device u-boot (stat:size (stat u-boot))
- device (* 512 512)))))
+ image (* 512 512)))))
(define install-firefly-rk3399-u-boot
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(let ((idb (string-append bootloader "/libexec/idbloader.img"))
(u-boot (string-append bootloader "/libexec/u-boot.itb")))
(write-file-on-device idb (stat:size (stat idb))
- device (* 64 512))
+ image (* 64 512))
(write-file-on-device u-boot (stat:size (stat u-boot))
- device (* 16384 512)))))
+ image (* 16384 512)))))
(define install-rock64-rk3328-u-boot
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(let ((idb (string-append bootloader "/libexec/idbloader.img"))
(u-boot (string-append bootloader "/libexec/u-boot.itb")))
(write-file-on-device idb (stat:size (stat idb))
- device (* 64 512))
+ image (* 64 512))
(write-file-on-device u-boot (stat:size (stat u-boot))
- device (* 16384 512)))))
+ image (* 16384 512)))))
(define install-rockpro64-rk3399-u-boot
- #~(lambda (bootloader device mount-point)
+ #~(lambda (bootloader root-index image)
(let ((idb (string-append bootloader "/libexec/idbloader.img"))
(u-boot (string-append bootloader "/libexec/u-boot.itb")))
(write-file-on-device idb (stat:size (stat idb))
- device (* 64 512))
+ image (* 64 512))
(write-file-on-device u-boot (stat:size (stat u-boot))
- device (* 16384 512)))))
+ image (* 16384 512)))))
(define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)
@@ -138,28 +138,29 @@
(inherit extlinux-bootloader)
(name 'u-boot)
(package #f)
- (installer install-u-boot)))
+ (installer #f)
+ (disk-image-installer install-u-boot)))
(define u-boot-beaglebone-black-bootloader
(bootloader
(inherit u-boot-bootloader)
(package u-boot-am335x-boneblack)
- (installer install-beaglebone-black-u-boot)))
+ (disk-image-installer install-beaglebone-black-u-boot)))
(define u-boot-allwinner-bootloader
(bootloader
(inherit u-boot-bootloader)
- (installer install-allwinner-u-boot)))
+ (disk-image-installer install-allwinner-u-boot)))
(define u-boot-allwinner64-bootloader
(bootloader
(inherit u-boot-bootloader)
- (installer install-allwinner64-u-boot)))
+ (disk-image-installer install-allwinner64-u-boot)))
(define u-boot-imx-bootloader
(bootloader
(inherit u-boot-bootloader)
- (installer install-imx-u-boot)))
+ (disk-image-installer install-imx-u-boot)))
(define u-boot-nintendo-nes-classic-edition-bootloader
(bootloader
@@ -196,7 +197,7 @@
(bootloader
(inherit u-boot-bootloader)
(package u-boot-firefly-rk3399)
- (installer install-firefly-rk3399-u-boot)))
+ (disk-image-installer install-firefly-rk3399-u-boot)))
(define u-boot-mx6cuboxi-bootloader
(bootloader
@@ -232,25 +233,25 @@
(bootloader
(inherit u-boot-bootloader)
(package u-boot-puma-rk3399)
- (installer install-puma-rk3399-u-boot)))
+ (disk-image-installer install-puma-rk3399-u-boot)))
(define u-boot-rock64-rk3328-bootloader
;; SD and eMMC use the same format
(bootloader
(inherit u-boot-bootloader)
(package u-boot-rock64-rk3328)
- (installer install-rock64-rk3328-u-boot)))
+ (disk-image-installer install-rock64-rk3328-u-boot)))
(define u-boot-rockpro64-rk3399-bootloader
;; SD and eMMC use the same format
(bootloader
(inherit u-boot-bootloader)
(package u-boot-rockpro64-rk3399)
- (installer install-rockpro64-rk3399-u-boot)))
+ (disk-image-installer install-rockpro64-rk3399-u-boot)))
(define u-boot-pinebook-pro-rk3399-bootloader
;; SD and eMMC use the same format
(bootloader
(inherit u-boot-bootloader)
(package u-boot-pinebook-pro-rk3399)
- (installer install-pinebook-pro-rk3399-u-boot)))
+ (disk-image-installer install-pinebook-pro-rk3399-u-boot)))
diff --git a/gnu/build/bootloader.scm b/gnu/build/bootloader.scm
index 498022f6db..5ec839f902 100644
--- a/gnu/build/bootloader.scm
+++ b/gnu/build/bootloader.scm
@@ -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))
@@ -35,11 +37,14 @@
(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
+ (open-file-output-port device
+ (file-options no-truncate no-create)
+ (buffer-mode block)
+ (native-transcoder))
+ (lambda (output)
+ (seek output offset SEEK_SET)
+ (put-bytevector output bv)))))))
;;;
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index d8d5882a54..2aa6c2ef13 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -202,6 +202,7 @@ set to the given OS."
(with-imported-modules `(,@(source-module-closure
'((gnu build vm)
(gnu build image)
+ (gnu build bootloader)
(gnu build hurd-boot)
(gnu build linux-boot)
(guix store database))
@@ -210,6 +211,7 @@ set to the given OS."
#~(begin
(use-modules (gnu build vm)
(gnu build image)
+ (gnu build bootloader)
(gnu build hurd-boot)
(gnu build linux-boot)
(guix store database)