From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 17 11:14:56 2020 Received: (at submit) by debbugs.gnu.org; 17 Dec 2020 16:14:56 +0000 Received: from localhost ([127.0.0.1]:36768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kpvvZ-0006nx-8y for submit@debbugs.gnu.org; Thu, 17 Dec 2020 11:14:56 -0500 Received: from lists.gnu.org ([209.51.188.17]:38216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kprgA-0003iu-OB for submit@debbugs.gnu.org; Thu, 17 Dec 2020 06:42:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kprgA-0004ma-Fo for bug-guix@gnu.org; Thu, 17 Dec 2020 06:42:42 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:38311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kprg7-0000Ax-In for bug-guix@gnu.org; Thu, 17 Dec 2020 06:42:42 -0500 X-IronPort-AV: E=Sophos;i="5.78,426,1599516000"; d="scan'208";a="367952432" Received: from lfbn-bor-1-377-136.w109-215.abo.wanadoo.fr (HELO [192.168.1.23]) ([109.215.92.136]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES256-GCM-SHA384; 17 Dec 2020 12:42:34 +0100 To: bug-guix@gnu.org From: Philippe SWARTVAGHER Subject: [Suggestion] Add option --with-patch Message-ID: <603c5016-6eb1-4305-2825-ed0bacf66025@inria.fr> Date: Thu, 17 Dec 2020 12:42:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US Received-SPF: pass client-ip=192.134.164.104; envelope-from=philippe.swartvagher@inria.fr; helo=mail3-relais-sop.national.inria.fr X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 17 Dec 2020 11:14:52 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hello, We already have `--with-branch=3D`, `with-commit=3D`, ... An additional option could be `--with-patch=3Dpackage=3Dadd-extra-feature.patch` which would apply the patch file `add-extra-feature.patch` located in the my current directory to the sources of `package` before Guix starts building `package`. This would bring the possibility to easily share patches (for tests, reviews, ... for instance) without having to commit the patch in the source repository of the package, without changing the package definition, and without applying ourselves the patch to our local source repository of the package. Thanks ! --=20 Philippe SWARTVAGHER PhD Student TADaaM team, Inria Bordeaux Sud-Ouest From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 21 08:58:07 2020 Received: (at 45300) by debbugs.gnu.org; 21 Dec 2020 13:58:07 +0000 Received: from localhost ([127.0.0.1]:46559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1krLhO-0007V2-3a for submit@debbugs.gnu.org; Mon, 21 Dec 2020 08:58:07 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:58675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1krLhJ-0007U0-9n for 45300@debbugs.gnu.org; Mon, 21 Dec 2020 08:58:05 -0500 X-IronPort-AV: E=Sophos;i="5.78,436,1599516000"; d="scan'208,223";a="484063474" Received: from 91-160-117-201.subs.proxad.net (HELO ribbon) ([91.160.117.201]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Dec 2020 14:57:54 +0100 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Philippe SWARTVAGHER Subject: [PATCH] Add option --with-patch References: <603c5016-6eb1-4305-2825-ed0bacf66025@inria.fr> Date: Mon, 21 Dec 2020 14:57:54 +0100 In-Reply-To: <603c5016-6eb1-4305-2825-ed0bacf66025@inria.fr> (Philippe SWARTVAGHER's message of "Thu, 17 Dec 2020 12:42:34 +0100") Message-ID: <87tusf6z31.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45300 Cc: 45300@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Philippe, Philippe SWARTVAGHER skribis: > We already have `--with-branch=3D`, `with-commit=3D`, ... An additional > option could be `--with-patch=3Dpackage=3Dadd-extra-feature.patch` which > would apply the patch file `add-extra-feature.patch` located in the my > current directory to the sources of `package` before Guix starts > building `package`. Good idea! The patch below does that. Feedback welcome. :-) Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-transformations-Add-with-patch.patch Content-Description: the patch >From 12c8df7c61537e3834fac4bf0e8e340cbac2d2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 21 Dec 2020 14:52:38 +0100 Subject: [PATCH] transformations: Add '--with-patch'. Suggested by Philippe Swartvagher . * guix/transformations.scm (transform-package-patches): New procedure. (%transformations): Add it as 'with-patch'. (%transformation-options, show-transformation-options-help/detailed): Add '--with-patch'. * tests/transformations.scm ("options->transformation, with-patch"): New test. * doc/guix.texi (Package Transformation Options): Document it. --- doc/guix.texi | 18 +++++++++++ guix/transformations.scm | 63 ++++++++++++++++++++++++++++++++++++++- tests/transformations.scm | 24 +++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 392baf5910..c172a898cd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10357,6 +10357,24 @@ This is similar to @option{--with-branch}, except that it builds from @var{commit} rather than the tip of a branch. @var{commit} must be a valid Git commit SHA1 identifier or a tag. +@item --with-patch=@var{package}=@var{file} +Add @var{file} to the list of patches applied to @var{package}, where +@var{package} is a spec such as @code{python@@3.8} or @code{glibc}. +@var{file} must contain a patch; it is applied with the flags specified +in the @code{origin} of @var{package} (@pxref{origin Reference}), which +by default includes @code{-p1} (@pxref{patch Directories,,, diffutils, +Comparing and Merging Files}). + +As an example, the command below rebuilds Coreutils with the GNU C +Library (glibc) patched with the given patch: + +@example +guix build coreutils --with-patch=glibc=./glibc-frob.patch +@end example + +In this example, glibc itself as well as everything that leads to +Coreutils in the dependency graph is rebuilt. + @cindex test suite, skipping @item --without-tests=@var{package} Build @var{package} without running its tests. This can be useful in diff --git a/guix/transformations.scm b/guix/transformations.scm index d49041cf59..2385d3231e 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -41,6 +41,7 @@ #:use-module (srfi srfi-34) #:use-module (srfi srfi-37) #:use-module (ice-9 match) + #:use-module (ice-9 vlist) #:export (options->transformation manifest-entry-with-transformations @@ -456,6 +457,60 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field." (rewrite obj) obj))) +(define (transform-package-patches specs) + "Return a procedure that, when passed a package, returns a package with +additional patches." + (define (package-with-extra-patches p patches) + (if (origin? (package-source p)) + (package/inherit p + (source (origin + (inherit (package-source p)) + (patches (append (map (lambda (file) + (local-file file)) + patches) + (origin-patches (package-source p))))))) + p)) + + (define (coalesce-alist alist) + ;; Coalesce multiple occurrences of the same key in ALIST. + (let loop ((alist alist) + (keys '()) + (mapping vlist-null)) + (match alist + (() + (map (lambda (key) + (cons key (vhash-fold* cons '() key mapping))) + (delete-duplicates (reverse keys)))) + (((key . value) . rest) + (loop rest + (cons key keys) + (vhash-cons key value mapping)))))) + + (define patches + ;; Spec/patch alist. + (coalesce-alist + (map (lambda (spec) + (match (string-tokenize spec %not-equal) + ((spec patch) + (cons spec (canonicalize-path patch))) + (_ + (raise (formatted-message + (G_ "~a: invalid package patch specification") + spec))))) + specs))) + + (define rewrite + (package-input-rewriting/spec + (map (match-lambda + ((spec . patches) + (cons spec (cut package-with-extra-patches <> patches)))) + patches))) + + (lambda (obj) + (if (package? obj) + (rewrite obj) + obj))) + (define %transformations ;; Transformations that can be applied to things to build. The car is the ;; key used in the option alist, and the cdr is the transformation @@ -469,7 +524,8 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field." (with-git-url . ,transform-package-source-git-url) (with-c-toolchain . ,transform-package-toolchain) (with-debug-info . ,transform-package-with-debug-info) - (without-tests . ,transform-package-tests))) + (without-tests . ,transform-package-tests) + (with-patch . ,transform-package-patches))) (define (transformation-procedure key) "Return the transformation procedure associated with KEY, a symbol such as @@ -509,6 +565,8 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field." (parser 'with-debug-info)) (option '("without-tests") #t #f (parser 'without-tests)) + (option '("with-patch") #t #f + (parser 'with-patch)) (option '("help-transform") #f #f (lambda _ @@ -537,6 +595,9 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field." (display (G_ " --with-git-url=PACKAGE=URL build PACKAGE from the repository at URL")) + (display (G_ " + --with-patch=PACKAGE=FILE + add FILE to the list of patches of PACKAGE")) (display (G_ " --with-c-toolchain=PACKAGE=TOOLCHAIN build PACKAGE and its dependents with TOOLCHAIN")) diff --git a/tests/transformations.scm b/tests/transformations.scm index 2d33bed7ae..9053deba41 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm @@ -26,6 +26,7 @@ #:use-module (guix build-system) #:use-module (guix build-system gnu) #:use-module (guix transformations) + #:use-module ((guix gexp) #:select (local-file? local-file-file)) #:use-module (guix ui) #:use-module (guix utils) #:use-module (guix git) @@ -372,6 +373,29 @@ (match (memq #:tests? (package-arguments tar)) ((#:tests? #f _ ...) #t)))))))) +(test-equal "options->transformation, with-patch" + (search-patches "glibc-locales.patch" "guile-relocatable.patch") + (let* ((dep (dummy-package "dep" + (source (dummy-origin)))) + (p (dummy-package "foo" + (inputs `(("dep" ,dep))))) + (patch1 (search-patch "glibc-locales.patch")) + (patch2 (search-patch "guile-relocatable.patch")) + (t (options->transformation + `((with-patch . ,(string-append "dep=" patch1)) + (with-patch . ,(string-append "dep=" patch2)) + (with-patch . ,(string-append "tar=" patch1)))))) + (let ((new (t p))) + (match (bag-direct-inputs (package->bag new)) + ((("dep" dep) ("tar" tar) _ ...) + (and (member patch1 + (filter-map (lambda (patch) + (and (local-file? patch) + (local-file-file patch))) + (origin-patches (package-source tar)))) + (map local-file-file + (origin-patches (package-source dep))))))))) + (test-end) ;;; Local Variables: -- 2.29.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 27 11:25:53 2020 Received: (at 45300-done) by debbugs.gnu.org; 27 Dec 2020 16:25:53 +0000 Received: from localhost ([127.0.0.1]:33318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktYrg-0005Iw-SH for submit@debbugs.gnu.org; Sun, 27 Dec 2020 11:25:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47988) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktYrf-0005Ij-An for 45300-done@debbugs.gnu.org; Sun, 27 Dec 2020 11:25:51 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51120) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktYrZ-0005lP-Hy; Sun, 27 Dec 2020 11:25:45 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=51732 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ktYrZ-0002iS-2x; Sun, 27 Dec 2020 11:25:45 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Philippe SWARTVAGHER Subject: Re: bug#45300: [PATCH] Add option --with-patch References: <603c5016-6eb1-4305-2825-ed0bacf66025@inria.fr> <87tusf6z31.fsf@gnu.org> Date: Sun, 27 Dec 2020 17:25:43 +0100 In-Reply-To: <87tusf6z31.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Mon, 21 Dec 2020 14:57:54 +0100") Message-ID: <877dp3tdvc.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-Debbugs-Envelope-To: 45300-done Cc: 45300-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ludovic Court=C3=A8s skribis: >>>From 12c8df7c61537e3834fac4bf0e8e340cbac2d2df Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Ludovic=3D20Court=3DC3=3DA8s?=3D > Date: Mon, 21 Dec 2020 14:52:38 +0100 > Subject: [PATCH] transformations: Add '--with-patch'. > > Suggested by Philippe Swartvagher . > > * guix/transformations.scm (transform-package-patches): New procedure. > (%transformations): Add it as 'with-patch'. > (%transformation-options, show-transformation-options-help/detailed): > Add '--with-patch'. > * tests/transformations.scm ("options->transformation, with-patch"): New > test. > * doc/guix.texi (Package Transformation Options): Document it. Pushed as e38d90d497e19e00263fa28961c688a433154386! Ludo=E2=80=99. From unknown Tue Jun 17 01:50:08 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 25 Jan 2021 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator