GNU bug report logs - #32118
[PATCH 2/2] gexp: Allow bytevector as content of `plain-file'.

Previous Next

Package: guix-patches;

Reported by: Jan Nieuwenhuizen <janneke <at> gnu.org>

Date: Tue, 10 Jul 2018 17:42:03 UTC

Severity: normal

Tags: patch

Merged with 32116, 32117

Done: Jan Nieuwenhuizen <janneke <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32118 in the body.
You can then email your comments to 32118 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#32118; Package guix-patches. (Tue, 10 Jul 2018 17:42:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jan Nieuwenhuizen <janneke <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 10 Jul 2018 17:42:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: guix-patches <at> gnu.org
Subject: [PATCH 2/2] gexp: Allow bytevector as content of `plain-file'.
Date: Tue, 10 Jul 2018 19:41:28 +0200
This allows for using a package source directly from git, doing something like

    (define (command->bytevector command)
      (let ((port (apply open-pipe* OPEN_READ command)))
        (let ((output (get-bytevector-all port)))
          (close-port port)
          output)))

    (define-public hello-git
      (package
        (name "hello")
        (version "git")
        (source (let* ((commit "stable-2.0")
                       (content (command->bytevector
                                 `("git" "archive" "--format" "tar" "--prefix"
                                   ,(string-append commit "/") ,commit)))
                       (file-name (string-append "hello-" commit)))
                  (plain-file file-name content)))
        ...
        ))

* guix/gexp.scm (<plain-file>): Also allow bytevector content.
(plain-file-compiler): Handle bytevector content.
* doc/guix.texi (G-Expressions): Describe plain-file now also taking
bytevectors.
---
 doc/guix.texi |  2 +-
 guix/gexp.scm | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 04d7a79ac..4d80f3e19 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5349,7 +5349,7 @@ procedure (@pxref{The Store Monad, @code{interned-file}}).
 
 @deffn {Scheme Procedure} plain-file @var{name} @var{content}
 Return an object representing a text file called @var{name} with the given
-@var{content} (a string) to be added to the store.
+@var{content} (a string or a bytevector) to be added to the store.
 
 This is the declarative counterpart of @code{text-file}.
 @end deffn
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 153b29bd4..cc3613f6f 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2018 Clément Lassieur <clement <at> lassieur.org>
+;;; Copyright © 2018 Jan Nieuwenhuizen <janneke <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,6 +24,7 @@
   #:use-module (guix derivations)
   #:use-module (guix grafts)
   #:use-module (guix utils)
+  #:use-module (rnrs bytevectors)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-9 gnu)
@@ -334,7 +336,7 @@ appears."
   (%plain-file name content references)
   plain-file?
   (name        plain-file-name)                   ;string
-  (content     plain-file-content)                ;string
+  (content     plain-file-content)                ;string or bytevector
   (references  plain-file-references))            ;list (currently unused)
 
 (define (plain-file name content)
@@ -349,8 +351,10 @@ This is the declarative counterpart of 'text-file'."
 (define-gexp-compiler (plain-file-compiler (file <plain-file>) system target)
   ;; "Compile" FILE by adding it to the store.
   (match file
-    (($ <plain-file> name content references)
-     (text-file name content references))))
+    (($ <plain-file> name (and (? string?) content) references)
+     (text-file name content references))
+    (($ <plain-file> name (and (? bytevector?) content) references)
+     (binary-file name content references))))
 
 (define-record-type <computed-file>
   (%computed-file name gexp guile options)
-- 
2.18.0





Merged 32116 32117 32118. Request was from Jan Nieuwenhuizen <janneke <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 10 Jul 2018 18:04:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#32118; Package guix-patches. (Wed, 11 Jul 2018 22:12:02 GMT) Full text and rfc822 format available.

Message #10 received at 32118 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Jan Nieuwenhuizen <janneke <at> gnu.org>
Cc: 32116 <at> debbugs.gnu.org, 32118 <at> debbugs.gnu.org
Subject: Re: [bug#32118] [PATCH 2/2] gexp: Allow bytevector as content of
 `plain-file'.
Date: Thu, 12 Jul 2018 00:11:31 +0200
Jan Nieuwenhuizen <janneke <at> gnu.org> skribis:

> This allows for using a package source directly from git, doing something like
>
>     (define (command->bytevector command)
>       (let ((port (apply open-pipe* OPEN_READ command)))
>         (let ((output (get-bytevector-all port)))
>           (close-port port)
>           output)))
>
>     (define-public hello-git
>       (package
>         (name "hello")
>         (version "git")
>         (source (let* ((commit "stable-2.0")
>                        (content (command->bytevector
>                                  `("git" "archive" "--format" "tar" "--prefix"
>                                    ,(string-append commit "/") ,commit)))
>                        (file-name (string-append "hello-" commit)))
>                   (plain-file file-name content)))
>         ...
>         ))
>
> * guix/gexp.scm (<plain-file>): Also allow bytevector content.
> (plain-file-compiler): Handle bytevector content.
> * doc/guix.texi (G-Expressions): Describe plain-file now also taking
> bytevectors.

LGTM, thanks!

Ludo'.




Information forwarded to guix-patches <at> gnu.org:
bug#32118; Package guix-patches. (Thu, 12 Jul 2018 04:33:02 GMT) Full text and rfc822 format available.

Message #13 received at 32118-done <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 32116-done <at> debbugs.gnu.org, 32118-done <at> debbugs.gnu.org
Subject: Re: [bug#32118] [PATCH 2/2] gexp: Allow bytevector as content of
 `plain-file'.
Date: Thu, 12 Jul 2018 06:31:38 +0200
Ludovic Courtès writes:

>> * guix/gexp.scm (<plain-file>): Also allow bytevector content.
>> (plain-file-compiler): Handle bytevector content.
>> * doc/guix.texi (G-Expressions): Describe plain-file now also taking
>> bytevectors.
>
> LGTM, thanks!

Pushed to master as e8e1f295f15fa56660a2c460d422795b1a31bed8

janneke

-- 
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 09 Aug 2018 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 313 days ago.

Previous Next


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