unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [PATCH 2/2] guix: build: Add transitive source building.
@ 2015-04-24 13:19 Eric Bavier
  2015-04-24 13:19 ` [PATCH 1/2] guix: packages: Add package-direct-sources and package-transitive-sources Eric Bavier
  2015-04-24 13:19 ` [PATCH 2/2] guix: build: Add transitive source building Eric Bavier
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Bavier @ 2015-04-24 13:19 UTC (permalink / raw)
  To: guix-devel

Revisiting this (old) thread...

>Eric Bavier <bavier@member.fsf.org> skribis:
>
>> * guix/scripts/build.scm (%options): Add --sources option.
>>   (package-sources, package-direct-sources)
>>   (package-transitive-sources, package-source-derivations): New
>>   procedures.
>>   (options->derivations)[--sources]: Use them.
>> * doc/guix.texi (Invoking guix build): Document --sources option.
>> * tests/guix-build.sh: Add tests.
>
>[...]
>
>> @item --sources
>> +An extension of the @code{--source} option.  If a package's source is
>
>What about starting with a couple of sentences that better describe what
>it does and what the use case is, like:
>
>  Fetch and return the source of @var{package-or-derivation} and all
>    their dependencies, recursively.  This is a handy way to obtain a
>      local copy of all the source code needed to build @var{packages},
>        allowing you to eventually build them even without network
>    access.

I liked your wording, so I used it ;)

>BTW, what happens when one passes arguments that are not packages?
>Like:
>
>  guix build --sources /gnu/store/...-foo.drv

It behaves in the way 'guix build -S' currently behaves with a
derivation, it just builds the derivation.  It might be interesting if
it examined the derivation and built any sources associated with it, but
that can be a later patch.

>> +  --sources[=TYPE]       build source derivations; TYPE may
>> optionally be one
>> +                         of \"package\", \"all\" (default), or
>> \"transitive\"."))
>
>No period.

Good catch, thanks.

>> +(define (package-sources package)
>
>This procedure appears to be unused (and is awkward anyway ;-)).

Removed.

>> +(define (package-direct-sources package)
>> +  "Return all source origins associated with PACKAGE; including
>> origins in
>> +PACKAGE's inputs."
>> +  `(,@(or (and=> (package-source package) list) '())
>> +    ,@(filter-map (match-lambda
>> +                   ((_ (? origin? orig) _ ...)
>> +                    orig)
>> +                   (_ #f))
>> +                  (package-direct-inputs package))))
>> +
>> +(define (package-transitive-sources package)
>> +  "Return PACKAGE's direct sources, and its input sources,
>> recursively."
>> +  (delete-duplicates
>> +   (concatenate (filter-map (match-lambda
>> +                             ((_ (? origin? orig) _ ...)
>> +                              (list orig))
>> +                             ((_ (? package? p) _ ...)
>> +                              (package-direct-sources p))
>> +                             (_ #f))
>> +                            (bag-transitive-inputs
>> +                             (package->bag package))))))
>
>Perhaps these two could go to (guix packages), with a test in
>tests/packages.scm.

Done in patch [1/2].

>> +# foo.tar.gz
>> +guix build -d -S foo
>> +guix build -d -S foo | grep -e 'foo\.tar\.gz'
>
>Nice tests, thanks for taking the time!

No problem.  I kinda like writing tests. :)


Eric Bavier (2):
  guix: packages: Add package-direct-sources and
    package-transitive-sources.
  guix: build: Add transitive source building.

 doc/guix.texi          |   43 +++++++++++++++++++++++++
 guix/packages.scm      |   24 ++++++++++++++
 guix/scripts/build.scm |   55 +++++++++++++++++++++----------
 guix/tests.scm         |   10 +++++-
 tests/guix-build.sh    |   82 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/packages.scm     |   30 +++++++++++++++++
 6 files changed, 226 insertions(+), 18 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH 1/2] packages: Getting unpatched origin derivations.
@ 2015-02-24 17:54 Eric Bavier
  2015-02-24 17:54 ` [PATCH 2/2] guix: build: Add transitive source building Eric Bavier
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Bavier @ 2015-02-24 17:54 UTC (permalink / raw)
  To: guix-devel

* guix/packages.scm (origin->derivation): Add #:patched? keyword argument.
---
 guix/packages.scm |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index 96f3adf..301623b 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -938,7 +938,8 @@ cross-compilation target triplet."
   (store-lift patch-and-repack))
 
 (define* (origin->derivation source
-                             #:optional (system (%current-system)))
+                             #:optional (system (%current-system))
+                             #:key (patched? #t))
   "When SOURCE is an <origin> object, return its derivation for SYSTEM.  When
 SOURCE is a file name, return either the interned file name (if SOURCE is
 outside of the store) or SOURCE itself (if SOURCE is already a store item.)"
@@ -956,14 +957,16 @@ outside of the store) or SOURCE itself (if SOURCE is already a store item.)"
                                                           (default-guile))
                                                       system
                                                       #:graft? #f)))
-       (patch-and-repack* source patches
-                          #:inputs inputs
-                          #:snippet snippet
-                          #:flags flags
-                          #:system system
-                          #:modules modules
-                          #:imported-modules modules
-                          #:guile-for-build guile)))
+       (if patched?
+           (patch-and-repack* source patches
+                              #:inputs inputs
+                              #:snippet snippet
+                              #:flags flags
+                              #:system system
+                              #:modules modules
+                              #:imported-modules modules
+                              #:guile-for-build guile)
+           (return source))))
     ((and (? string?) (? direct-store-path?) file)
      (with-monad %store-monad
        (return file)))
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-05-01 20:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-24 13:19 [PATCH 2/2] guix: build: Add transitive source building Eric Bavier
2015-04-24 13:19 ` [PATCH 1/2] guix: packages: Add package-direct-sources and package-transitive-sources Eric Bavier
2015-05-01 20:12   ` Ludovic Courtès
2015-04-24 13:19 ` [PATCH 2/2] guix: build: Add transitive source building Eric Bavier
2015-05-01 20:14   ` Ludovic Courtès
  -- strict thread matches above, loose matches on Subject: below --
2015-02-24 17:54 [PATCH 1/2] packages: Getting unpatched origin derivations Eric Bavier
2015-02-24 17:54 ` [PATCH 2/2] guix: build: Add transitive source building Eric Bavier
2015-02-26 17:03   ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).