From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLrn2-0000UM-5r for guix-patches@gnu.org; Mon, 04 Dec 2017 09:32:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLrms-0004MG-BV for guix-patches@gnu.org; Mon, 04 Dec 2017 09:32:12 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:35795) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eLrms-0004M8-7a for guix-patches@gnu.org; Mon, 04 Dec 2017 09:32:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eLrms-0008NN-1w for guix-patches@gnu.org; Mon, 04 Dec 2017 09:32:02 -0500 Subject: [bug#29409] [PATCH] build: utils: Introduce dd. Resent-Message-ID: References: <877euhtjkj.fsf@gmail.com> <1512038828-10822-1-git-send-email-m.othacehe@gmail.com> <87609qhax6.fsf@gnu.org> From: Mathieu Othacehe In-reply-to: <87609qhax6.fsf@gnu.org> Date: Mon, 04 Dec 2017 15:31:46 +0100 Message-ID: <87609m5zu5.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 29409@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit > Granted, that’s a bit more verbose, but it’s also very lightweight > compared to using ‘dd’. Here's a new implementation, using your snippet. I tested it with "installed-extlinux-os", it seems ok. Mathieu --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-bootloader-extlinux-Stop-using-dd-binary.patch >From 742662ceec2a40d664520f01977ddc4cbe64d369 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 1 Dec 2017 14:09:38 +0100 Subject: [PATCH] bootloader: extlinux: Stop using dd binary. * gnu/bootloader/extlinux.scm (dd): Remove it, (install-extlinux): replace dd call by Guile I/O procedures. * gnu/system/vm.scm (qemu-image): Add (ice-9 binary-ports) to module-closure and used-modules list to provide "get-bytevector-n" and "put-bytevector". * guix/scripts/system.scm (bootloader-installer-derivation): Ditto. --- gnu/bootloader/extlinux.scm | 18 ++++++++---------- gnu/system/vm.scm | 6 ++++-- guix/scripts/system.scm | 6 ++++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm index 0db5598..98fad0c 100644 --- a/gnu/bootloader/extlinux.scm +++ b/gnu/bootloader/extlinux.scm @@ -85,14 +85,6 @@ TIMEOUT ~a~%" ;;; Install procedures. ;;; -(define dd - #~(lambda (bs count if of) - (zero? (system* "dd" - (string-append "bs=" (number->string bs)) - (string-append "count=" (number->string count)) - (string-append "if=" if) - (string-append "of=" of))))) - (define (install-extlinux mbr) #~(lambda (bootloader device mount-point) (let ((extlinux (string-append bootloader "/sbin/extlinux")) @@ -102,8 +94,14 @@ TIMEOUT ~a~%" (install-file file install-dir)) (find-files syslinux-dir "\\.c32$")) - (unless (and (zero? (system* extlinux "--install" install-dir)) - (#$dd 440 1 (string-append syslinux-dir "/" #$mbr) device)) + (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)) + (output (open-file device "wb0"))) + (put-bytevector output bv) + (close-port output))))) (error "failed to install SYSLINUX"))))) (define install-extlinux-mbr diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index b68cce3..b5fe786 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -274,11 +274,13 @@ the image." (expression->derivation-in-linux-vm name (with-imported-modules (source-module-closure '((gnu build vm) - (guix build utils))) + (guix build utils) + (ice-9 binary-ports))) #~(begin (use-modules (gnu build vm) (guix build utils) - (srfi srfi-26)) + (srfi srfi-26) + (ice-9 binary-ports)) (let ((inputs '#$(append (list qemu parted e2fsprogs dosfstools) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 91d151d..5116b82 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -674,9 +674,11 @@ any, are available. Raise an error if they're not." and TARGET arguments." (with-monad %store-monad (gexp->file "bootloader-installer" - (with-imported-modules '((guix build utils)) + (with-imported-modules '((guix build utils) + (ice-9 binary-ports)) #~(begin - (use-modules (guix build utils)) + (use-modules (guix build utils) + (ice-9 binary-ports)) (#$installer #$bootloader #$device #$target)))))) (define* (perform-action action os -- 2.7.4 --=-=-=--