From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Bavier Subject: Re: [PATCH 2/2] guix: build: Add transitive source building. Date: Fri, 24 Apr 2015 08:19:20 -0500 Message-ID: <1429881562-19456-1-git-send-email-bavier@member.fsf.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YldUk-0003JY-QK for guix-devel@gnu.org; Fri, 24 Apr 2015 09:18:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YldUh-0000TX-KN for guix-devel@gnu.org; Fri, 24 Apr 2015 09:18:14 -0400 Received: from mail2.openmailbox.org ([62.4.1.33]:44824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YldUh-0000TK-EU for guix-devel@gnu.org; Fri, 24 Apr 2015 09:18:11 -0400 In-Reply-To: 87r3tc61w3.fsf%40gnu.org List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org Revisiting this (old) thread... >Eric Bavier 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