emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#32118: closed ([PATCH 2/2] gexp: Allow bytevector


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#32118: closed ([PATCH 2/2] gexp: Allow bytevector as content of `plain-file'.)
Date: Thu, 12 Jul 2018 04:31:03 +0000

Your message dated Thu, 12 Jul 2018 06:30:31 +0200
with message-id <address@hidden>
and subject line Re: [bug#32117] [PATCH 1/2] store: Add `binary-file'.
has caused the debbugs.gnu.org bug report #32116,
regarding [PATCH 2/2] gexp: Allow bytevector as content of `plain-file'.
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
32116: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=32116
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- 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
address@hidden (a string) to be added to the store.
address@hidden (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 <address@hidden>
 ;;; Copyright © 2018 Clément Lassieur <address@hidden>
+;;; Copyright © 2018 Jan Nieuwenhuizen <address@hidden>
 ;;;
 ;;; 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




--- End Message ---
--- Begin Message --- Subject: Re: [bug#32117] [PATCH 1/2] store: Add `binary-file'. Date: Thu, 12 Jul 2018 06:30:31 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Ludovic Courtès writes:

>> address@hidden {Monadic Procedure} binary-file* @var{name} @var{data} @dots{}
>
> There’s no ‘*’ in the actual procedure name.
>
> Also, could you move this @deffn to “The Store Monad”, right after
> ‘text-file’?

Ah, I based this on the `text-file*' description!  Moved, and rewritten
as

@deffn {Monadic Procedure} binary-file @var{name} @var{data} address@hidden
Return as a monadic value the absolute file name in the store of the file
containing @var{data}, a bytevector.  @var{references} is a list of store
items that the resulting binary file refers to; it defaults to the empty list.
@end deffn

> Apart from that it LGTM, thanks!

Pushed to master as  f3a422511f793fb6c6cfeec2bb8735965a03294a

janneke

-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com


--- End Message ---

reply via email to

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