guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#29409] [PATCH] build: utils: Introduce dd.


From: Ludovic Courtès
Subject: [bug#29409] [PATCH] build: utils: Introduce dd.
Date: Fri, 01 Dec 2017 13:47:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Hello,

address@hidden skribis:

> From: Mathieu Othacehe <address@hidden>
>
> * guix/build/utils.scm (dd): New exported procedure.
> * gnu/bootloader/extlinux.scm (dd): Remove it,
> (install-extlinux): replace gexp dd with dd added above.
> ---
> Hi,
>
> dd will be used in different bootloader related gexp. So it may be
> good to add it to (guix build utils). The problem is that
> it triggers a big rebuild. I was able to test this path with
> "installed-extlinux-os".

Yes, changing (guix build utils) triggers a full rebuild because
everything depends on it.

> +(define* (dd input output #:key bs count seek (extras '()))
> +  "Call dd command with provided INPUT and OUTPUT arguments. BS, COUNT, SEEK
> +  and EXTRAS parameters are optional. EXTRAS is a list of string arguments to
> +  be passed directly to dd."
> +  (apply system* "dd"
> +         (string-append "if=" input)
> +         (string-append "of=" output)
> +         (append
> +          (if bs
> +              `(,(string-append "bs=" (number->string bs)))
> +              '())
> +          (if count
> +              `(,(string-append "count=" (number->string count)))
> +              '())
> +          (if seek
> +              `(,(string-append "seek=" (number->string seek)))
> +              '())
> +          extras)))

I’m not quite convinced.  :-)  It seems to me that it doesn’t buy us
much to have it in (guix build utils), because we don’t need it very
often anyway, and secondly, I think we can use ‘dump-port’ or other I/O
procedures instead.

Namely:

+                     (zero? (dd (string-append syslinux-dir "/" #$mbr)
+                                device
+                                #:bs 440
+                                #:count 1)))

would become:

  (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))))

Granted, that’s a bit more verbose, but it’s also very lightweight
compared to using ‘dd’.

WDYT?

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]