From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mx2ZCpigkV/TRQAA0tVLHw (envelope-from ) for ; Thu, 22 Oct 2020 15:09:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id sLh5BJigkV/BAgAAB5/wlQ (envelope-from ) for ; Thu, 22 Oct 2020 15:09:12 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 610759403C4 for ; Thu, 22 Oct 2020 15:09:11 +0000 (UTC) Received: from localhost ([::1]:60046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVcDE-0005je-Tb for larch@yhetil.org; Thu, 22 Oct 2020 11:09:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVcD8-0005jS-Uv for guix-patches@gnu.org; Thu, 22 Oct 2020 11:09:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41948) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVcD8-00019S-GH for guix-patches@gnu.org; Thu, 22 Oct 2020 11:09:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kVcD8-0002WI-4g for guix-patches@gnu.org; Thu, 22 Oct 2020 11:09:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43193] [PATCH] guix: Add --with-dependency-source option Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 22 Oct 2020 15:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43193 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Jesse Gibbons Cc: 43193@debbugs.gnu.org Received: via spool by 43193-submit@debbugs.gnu.org id=B43193.16033793019622 (code B ref 43193); Thu, 22 Oct 2020 15:09:02 +0000 Received: (at 43193) by debbugs.gnu.org; 22 Oct 2020 15:08:21 +0000 Received: from localhost ([127.0.0.1]:53494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVcCS-0002V7-Jo for submit@debbugs.gnu.org; Thu, 22 Oct 2020 11:08:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVcCQ-0002Ut-D9 for 43193@debbugs.gnu.org; Thu, 22 Oct 2020 11:08:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44897) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVcCL-0000yP-5O; Thu, 22 Oct 2020 11:08:13 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=51376 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kVcCK-0006wr-N3; Thu, 22 Oct 2020 11:08:12 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <9c3a00ba-19bf-a8e9-8803-d150e91f1b6e@gmail.com> <87y2lige5l.fsf@gnu.org> <7f52c72f-c280-b585-d1ad-ca012f804910@gmail.com> <87wo10s4j6.fsf@gnu.org> <4c890f8c-539c-1c9c-f558-7ba01cffa480@gmail.com> <87y2ld7s5b.fsf@gnu.org> <9c60e5f2-e9fa-55c9-863f-cc3bccc2cf15@gmail.com> Date: Thu, 22 Oct 2020 17:08:10 +0200 In-Reply-To: <9c60e5f2-e9fa-55c9-863f-cc3bccc2cf15@gmail.com> (Jesse Gibbons's message of "Sat, 26 Sep 2020 16:46:16 -0600") Message-ID: <87pn5as3hh.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -0.01 X-TUID: lz2MVpIvuQHJ Hi Jesse, Jesse Gibbons skribis: > Attached are the patches that make the --with-source option recursive, > add documentation, add a test, adjust a test, and update the news. Great, and apologies for the delay. >>>From 2d2f6c97ad1deeb2fc8a214d992c7894a7c5e293 Mon Sep 17 00:00:00 2001 > From: Jesse Gibbons > Date: Thu, 3 Sep 2020 17:45:08 -0600 > Subject: [PATCH 1/2] guix: Make --with-source option recursive > > * guix/scripts/build.scm: (transform-package-inputs/source): new > function > (evaluate-source-replacement-specs): new function > (%transformations): change with-source to use > evaluate-source-replacement-specs > > * doc/guix.texi (Package Transformation Options): document it. > > * tests/scripts-build.scm: (options->transformation, with-source, no > matches): adjust to new expectations. > (options->transformation, with-source, recursive): new test. [...] > +++ b/doc/guix.texi > @@ -9142,8 +9142,8 @@ without having to type in the definitions of packag= e variants > @itemx --with-source=3D@var{package}=3D@var{source} > @itemx --with-source=3D@var{package}@@@var{version}=3D@var{source} > Use @var{source} as the source of @var{package}, and @var{version} as > -its version number. > -@var{source} must be a file name or a URL, as for @command{guix > +its version number. This replacement is applied recursively on all > +dependencies. @var{source} must be a file name or a URL, as for @comman= d{guix > download} (@pxref{Invoking guix download}). Maybe s/all dependencies/all matching dependencies/? > +++ b/guix/scripts/build.scm > @@ -201,9 +201,9 @@ matching URIs given in SOURCES." > (#f > ;; Determine the package name and version from URI. > (call-with-values > - (lambda () > - (hyphen-package-name->name+version > - (tarball-base-name (basename uri)))) > + (lambda () > + (hyphen-package-name->name+version > + (tarball-base-name (basename uri)))) Please avoid unrelated whitespace changes like this one. > +(define (transform-package-inputs/source replacement-specs) Maybe call it =E2=80=98transform-package-source=E2=80=99 and remove the pre= vious =E2=80=98transform-package-source=E2=80=99 procedure. > + "Return a procedure that, when passed a package, replaces its direct > +dependencies according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is a lis= t of > +strings like \"guile=3D/path/to/source\" or > +\"guile=3Dhttps://www.example.com/guile-source.tar.gz\" meaning that, any > +dependency on a package called \"guile\" must be replaced with a depende= ncy on a > +\"guile\" built with the source at the specified location. SPECS may al= so > +simply be a file location, in which case the package name and version ar= e parsed > +from the file name." > + (lambda (store obj) > + (let* ((replacements (evaluate-source-replacement-specs replacement-s= pecs > + (lambda* (old= file #:optional version) > + (package-with= -source store old file version)))) Please indent like the rest of the code (if you use Emacs, you can hit M-q to have it indent the surrounding expression correctly). Here the second line should be aligned with the first =E2=80=98a=E2=80=99 of =E2=80= =98lambda*=E2=80=99. Also please arrange to keep lines below 80 chars. > + (rewrite (package-input-rewriting/spec replacements)) > + (rewrite* (lambda (obj) > + (rewrite obj)))) You can remove =E2=80=98rewrite*=E2=80=99 and use =E2=80=98rewrite=E2=80=99= directly. > +(define (evaluate-source-replacement-specs specs proc) > + "Parse SPECS, a list of strings like \"guile=3D/path/to/source\", and = return a > +list of package pairs, where (PROC PACKAGE URL) returns the replacement = package. > +Raise an error if an element of SPECS uses invalid syntax, or if a packa= ge it > +refers to could not be found." > + (define* (replacement file #:optional version) > + (lambda (old) > + (proc old file version))) > + (map (lambda (spec) > + (match (string-tokenize spec %not-equal) > + ((package-spec file) > + (let* ((spec-list (call-with-values > + (lambda () > + (package-specification->name+version+o= utput package-spec)) > + list)) > + (name (list-ref spec-list 0)) > + (version (list-ref spec-list 1))) Use =E2=80=98let-values=E2=80=99 instead: (let-values (((name version) (package-specification->name+version+output spec))) =E2=80=A6) Also maybe s/package-spec/spec/; it=E2=80=99s clear enough in this context. > + (cons name (replacement file version)))) > + ((file) > + (let* ((package-spec > + (call-with-values > + (lambda () > + (hyphen-package-name->name+version > + (tarball-base-name (basename file)))) > + (lambda (name version) > + (cons name version)))) > + (name (car package-spec)) > + (version (cdr package-spec))) > + (cons name (replacement file version)))) =E2=80=98let-values=E2=80=99 also. > +++ b/tests/scripts-build.scm > @@ -94,9 +94,9 @@ > (let* ((port (open-output-string)) > (new (parameterize ((guix-warning-port port)) > (t store p)))) > - (and (eq? new p) > - (string-contains (get-output-string port) > - "had no effect")))))) > + (and (eq? (package-version new) (package-version p)) > + (eq? (package-name new) (package-name p)) > + (eq? (package-source new) (package-source p))))))) We can probably remove this test since the behavior it was checking no longer exists. > +(test-assert "options->transformation, with-source, recursive" > + (let* ((q (dummy-package "foo")) > + (p (dummy-package "guix.scm" > + (inputs `(("foo" ,q))))) > + (s (search-path %load-path "guix.scm")) > + (f (string-append "foo@42.0=3D" s)) > + (t (options->transformation `((with-source . ,f))))) > + (with-store store > + (let ((new (t store p))) > + (and (not (eq? new p)) > + (match (package-inputs new) > + ((("foo" dep1)) > + (and > + (string=3D? (package-name dep1) "foo") > + (string=3D? (package-version dep1) "42.0") > + (string=3D? (package-source dep1) > + (add-to-store store (basename s) #t > + "sha256" s)))))))))) Please indent correctly. >>>From 738fdb35af1449e245ce2e48c266c82f798d89af Mon Sep 17 00:00:00 2001 > From: Jesse Gibbons > Date: Sat, 26 Sep 2020 16:29:25 -0600 > Subject: [PATCH 2/2] news: Add entry for "--with-source" > > * etc/news,scm: Add entry. [...] > + (entry (commit "2d2f6c97ad1deeb2fc8a214d992c7894a7c5e293") > + (title (en "@option{--with-source} now recursive")) ^ + =E2=80=9Cpackage transformation option is=E2=80=9D > + (body (en "The @option{--with-source} common option now uses the > +specified source for all matching dependencies of any packages guix is d= irected > +to work with. This option is useful for all package maintainers, develop= ers, > +and, in general, all users who want guix to facilitate their rights to m= odify > +their software and share their changes."))) Usually there=E2=80=99s an extra sentence like =E2=80=9CRun info =E2=80=A6= =E2=80=9D explaining how to read the relevant part of the manual; it may be a good idea to add it. Could you send an updated patch? Hopefully the last one! Thanks, Ludo=E2=80=99.