From unknown Fri Jun 13 11:19:19 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#53828] [PATCH] guix: opam: Allow importing local files. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 06 Feb 2022 21:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 53828 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53828@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164418373724190 (code B ref -1); Sun, 06 Feb 2022 21:43:02 +0000 Received: (at submit) by debbugs.gnu.org; 6 Feb 2022 21:42:17 +0000 Received: from localhost ([127.0.0.1]:39975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGpIW-0006I6-NA for submit@debbugs.gnu.org; Sun, 06 Feb 2022 16:42:17 -0500 Received: from lists.gnu.org ([209.51.188.17]:37360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGpIV-0006Hy-3W for submit@debbugs.gnu.org; Sun, 06 Feb 2022 16:42:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGpIU-0007wM-ML for guix-patches@gnu.org; Sun, 06 Feb 2022 16:42:14 -0500 Received: from [2a00:5884:8208::1] (port=35922 helo=lepiller.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGpI2-0006Lw-3K for guix-patches@gnu.org; Sun, 06 Feb 2022 16:41:49 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 5c328a32 for ; Sun, 6 Feb 2022 21:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:mime-version:content-type; s=dkim; bh=V5n maPMXPc32Hoqgk9j6lNhM0FesZDhSCkXEZ9qBakE=; b=mV+E8Q7kAyLAfWLMHhW Kt8i/eZwvldjss7CJtovIG3pTffPTRxj+JCTYj0hFkE+7cU/YW4oosngn3idopVX lBe8CTz8N/SDr9NZ1qv2SJYTXBSHn9XFo3y16eK4sLLR016C+X6pz6aZrb1Dmqyk MEXzL3Gq1Eqv4l3RQ4AizbV6u/fPVquBr1KAfBNErIy8AIxNny3glWUkURpHTh75 zVBH0tD5WMCPYDOCRaGr5vcnbpdvzz/MuE4qmk4GEVJe70icrlxlvfCxPTCRZH1q jusdlQ4PX6fGArL9D7AfUsGDoaUJBY0cF38BMptWRdwdLzxCkFO9SPUIEK/wPoLt yVA== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 7855a846 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Sun, 6 Feb 2022 21:41:39 +0000 (UTC) Date: Sun, 6 Feb 2022 22:41:30 +0100 From: Julien Lepiller Message-ID: <20220206224130.2220aae9@tachikoma.lepiller.eu> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/GxuYmKHeuMF5J7IXm2T6L90" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:5884:8208::1 (failed) Received-SPF: pass client-ip=2a00:5884:8208::1; envelope-from=julien@lepiller.eu; helo=lepiller.eu X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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 (--) --MP_/GxuYmKHeuMF5J7IXm2T6L90 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Guix! This patch lets you import opam packages from a local file. This is a feature that was requested a few times, and there it is :) Now, if you have an OCaml package sources that provides an opam file (usually called opam, or with the .opam extension), you can import the package, recursively or not with something like: guix import opam foo -f foo.opam -r instead of fetching foo from the repositories, it will fetch the data directly from the given file. WDYT? --MP_/GxuYmKHeuMF5J7IXm2T6L90 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-guix-opam-Allow-importing-local-files.patch >From b027391357eef4d6fa1bb8741528cf9650aef568 Mon Sep 17 00:00:00 2001 Message-Id: From: Julien Lepiller Date: Sun, 6 Feb 2022 22:35:14 +0100 Subject: [PATCH] guix: opam: Allow importing local files. * guix/scripts/import/opam.scm (guix-import-opam): Support `--file` flag. * guix/import/utils.scm (recursive-import): Add optional file argument. Pass it to the first iteration when available. * guix/import/opam.scm (opam-fetch): Fetch from file when available. (opam->guix-source): Factorize source out of opam->guix-package. (opam->guix-package): Add file argument. Ensure it does not fail when name, version and url are not available. --- guix/import/opam.scm | 101 +++++++++++++++++++---------------- guix/import/utils.scm | 17 +++--- guix/scripts/import/opam.scm | 11 +++- 3 files changed, 75 insertions(+), 54 deletions(-) diff --git a/guix/import/opam.scm b/guix/import/opam.scm index a6f6fe8c9f..05f79110f8 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -310,8 +310,11 @@ (define (dependency-list->inputs lst) (map string->symbol (ocaml-names->guix-names lst))) -(define* (opam-fetch name #:optional (repositories-specs '("opam"))) - (or (fold (lambda (repository others) +(define* (opam-fetch name #:optional (repositories-specs '("opam")) (file #f)) + (or (and file (let ((metadata (get-metadata file))) + `(("metadata" . ,metadata) + ("version" . #f)))) + (fold (lambda (repository others) (match (find-latest-version name repository) ((_ version file) `(("metadata" ,@(get-metadata file)) ("version" . ,version))) @@ -320,17 +323,29 @@ (define* (opam-fetch name #:optional (repositories-specs '("opam"))) (filter-map get-opam-repository repositories-specs)) (warning (G_ "opam: package '~a' not found~%") name))) -(define* (opam->guix-package name #:key (repo 'opam) version) +(define (opam->guix-source url-dict) + (let ((source-url (and url-dict + (or (metadata-ref url-dict "src") + (metadata-ref url-dict "archive"))))) + (if source-url + (call-with-temporary-output-file + (lambda (temp port) + (and (url-fetch source-url temp) + `(origin + (method url-fetch) + (uri ,source-url) + (sha256 (base32 ,(guix-hash-url temp))))))) + 'no-source-information))) + +(define* (opam->guix-package name #:key (repo '("opam")) (file #f) version) "Import OPAM package NAME from REPOSITORY (a directory name) or, if -REPOSITORY is #f, from the official OPAM repository. Return a 'package' sexp +REPOSITORY is #f, from the official OPAM repository. When FILE is defined, +import the packaged defined in the opam FILE instead. Return a 'package' sexp or #f on failure." (and-let* ((with-opam (if (member "opam" repo) repo (cons "opam" repo))) - (opam-file (opam-fetch name with-opam)) - (version (assoc-ref opam-file "version")) + (opam-file (opam-fetch name with-opam file)) (opam-content (assoc-ref opam-file "metadata")) - (url-dict (metadata-ref opam-content "url")) - (source-url (or (metadata-ref url-dict "src") - (metadata-ref url-dict "archive"))) + (source (opam->guix-source (metadata-ref opam-content "url"))) (requirements (metadata-ref opam-content "depends")) (names (dependency-list->names requirements)) (dependencies (filter-dependencies names)) @@ -344,47 +359,41 @@ (define* (opam->guix-package name #:key (repo 'opam) version) (not (member name '("dune" "jbuilder")))) native-dependencies)))) (let ((use-dune? (member "dune" names))) - (call-with-temporary-output-file - (lambda (temp port) - (and (url-fetch source-url temp) - (values - `(package - (name ,(ocaml-name->guix-name name)) - (version ,version) - (source - (origin - (method url-fetch) - (uri ,source-url) - (sha256 (base32 ,(guix-hash-url temp))))) - (build-system ,(if use-dune? - 'dune-build-system - 'ocaml-build-system)) - ,@(if (null? inputs) - '() - `((propagated-inputs (list ,@inputs)))) - ,@(if (null? native-inputs) - '() - `((native-inputs (list ,@native-inputs)))) - ,@(if (equal? name (guix-name->opam-name (ocaml-name->guix-name name))) - '() - `((properties - ,(list 'quasiquote `((upstream-name . ,name)))))) - (home-page ,(metadata-ref opam-content "homepage")) - (synopsis ,(metadata-ref opam-content "synopsis")) - (description ,(beautify-description - (metadata-ref opam-content "description"))) - (license ,(spdx-string->license - (metadata-ref opam-content "license")))) - (filter - (lambda (name) - (not (member name '("dune" "jbuilder")))) - dependencies)))))))) + (values + `(package + (name ,(and name (ocaml-name->guix-name name))) + (version ,(assoc-ref opam-file "version")) + (source ,source) + (build-system ,(if use-dune? + 'dune-build-system + 'ocaml-build-system)) + ,@(if (null? inputs) + '() + `((propagated-inputs (list ,@inputs)))) + ,@(if (null? native-inputs) + '() + `((native-inputs (list ,@native-inputs)))) + ,@(if (and name (equal? name (guix-name->opam-name (ocaml-name->guix-name name)))) + '() + `((properties + ,(list 'quasiquote `((upstream-name . ,name)))))) + (home-page ,(metadata-ref opam-content "homepage")) + (synopsis ,(metadata-ref opam-content "synopsis")) + (description ,(beautify-description + (metadata-ref opam-content "description"))) + (license ,(spdx-string->license + (metadata-ref opam-content "license")))) + (filter + (lambda (name) + (not (member name '("dune" "jbuilder")))) + dependencies))))) -(define* (opam-recursive-import package-name #:key repo) +(define* (opam-recursive-import package-name #:key repo file) (recursive-import package-name #:repo->guix-package opam->guix-package #:guix-name ocaml-name->guix-name - #:repo repo)) + #:repo repo + #:file file)) (define (guix-name->opam-name name) (if (string-prefix? "ocaml-" name) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 1c3cfa3e0b..ab35b8a4fc 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -470,7 +470,7 @@ (define (topological-sort nodes (set-insert (node-name head) visited)))))))) (define* (recursive-import package-name - #:key repo->guix-package guix-name version repo + #:key repo->guix-package guix-name version repo file #:allow-other-keys) "Return a list of package expressions for PACKAGE-NAME and all its dependencies, sorted in topological order. For each package, @@ -488,10 +488,15 @@ (define* (recursive-import package-name (define (exists? name version) (not (null? (find-packages-by-name (guix-name name) version)))) - (define (lookup-node name version) - (let* ((package dependencies (repo->guix-package name - #:version version - #:repo repo)) + (define* (lookup-node name version #:optional file) + (let* ((package dependencies (if file + (repo->guix-package name + #:version version + #:repo repo + #:file file) + (repo->guix-package name + #:version version + #:repo repo))) (normalized-deps (map (match-lambda ((name version) (list name version)) (name (list name #f))) dependencies))) @@ -499,7 +504,7 @@ (define* (recursive-import package-name (filter-map node-package - (topological-sort (list (lookup-node package-name version)) + (topological-sort (list (lookup-node package-name version file)) (lambda (node) (map (lambda (name-version) (apply lookup-node name-version)) diff --git a/guix/scripts/import/opam.scm b/guix/scripts/import/opam.scm index 834ac34cb0..b58c6eab3d 100644 --- a/guix/scripts/import/opam.scm +++ b/guix/scripts/import/opam.scm @@ -50,6 +50,8 @@ (define (show-help) --repo import packages from this opam repository (name, URL or local path) can be used more than once")) (display (G_ " + -f, --file import the package defined from a .opam file")) + (display (G_ " -V, --version display version information and exit")) (newline) (show-bug-report-information)) @@ -66,6 +68,9 @@ (define %options (option '(#f "repo") #t #f (lambda (opt name arg result) (alist-cons 'repo arg result))) + (option '(#\f "file") #t #f + (lambda (opt name arg result) + (alist-cons 'file arg result))) (option '(#\r "recursive") #f #f (lambda (opt name arg result) (alist-cons 'recursive #t result))) @@ -100,9 +105,11 @@ (define (guix-import-opam . args) `(define-public ,(string->symbol name) ,pkg)) (_ #f)) - (opam-recursive-import package-name #:repo repo)) + (opam-recursive-import package-name #:repo repo + #:file (assoc-ref opts 'file))) ;; Single import - (let ((sexp (opam->guix-package package-name #:repo repo))) + (let ((sexp (opam->guix-package package-name #:repo repo + #:file (assoc-ref opts 'file)))) (unless sexp (leave (G_ "failed to download meta-data for package '~a'~%") package-name)) -- 2.34.0 --MP_/GxuYmKHeuMF5J7IXm2T6L90-- From unknown Fri Jun 13 11:19:19 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#53828] [PATCH] guix: opam: Allow importing local files. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 06 Feb 2022 22:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53828 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Julien Lepiller , 53828@debbugs.gnu.org Received: via spool by 53828-submit@debbugs.gnu.org id=B53828.164418474225922 (code B ref 53828); Sun, 06 Feb 2022 22:00:02 +0000 Received: (at 53828) by debbugs.gnu.org; 6 Feb 2022 21:59:02 +0000 Received: from localhost ([127.0.0.1]:40002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGpYk-0006k2-9G for submit@debbugs.gnu.org; Sun, 06 Feb 2022 16:59:02 -0500 Received: from laurent.telenet-ops.be ([195.130.137.89]:34914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGpYh-0006jc-UA for 53828@debbugs.gnu.org; Sun, 06 Feb 2022 16:59:00 -0500 Received: from [172.20.10.5] ([188.188.37.53]) by laurent.telenet-ops.be with bizsmtp id rxyx2600K18o4tG01xyyek; Sun, 06 Feb 2022 22:58:58 +0100 Message-ID: From: Maxime Devos Date: Sun, 06 Feb 2022 22:58:52 +0100 In-Reply-To: <20220206224130.2220aae9@tachikoma.lepiller.eu> References: <20220206224130.2220aae9@tachikoma.lepiller.eu> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-+coQc1aDVWtBPE70kDkl" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1644184738; bh=a2e88jEihs1CmQgNBXRAsa+3UOQG5ipZtRDWmRg6Bro=; h=Subject:From:To:Date:In-Reply-To:References; b=eR9ONTjvqMks+yIYkLdbvVNXg8lhvfgKzlTOQPCNTrf9kIQ9g3FIE7XCr2mhDkYhz wOsLUon5G5OArBS4K9eKWFXutVOZeTjCodBDaio2iOsQ9d3WkSlrcffb9vpKBmn5/D RDhYHyWswTk63b1mEk9L1hzSgvRiEJPg68HWow4rIgTjidUTsn38gcUix1/efEpr/p wMvCD/j8qAqnMi5t9zfnqtZ73K1Nnvo14xbzzP2YuKr2xWdK0BV7YnvFOaCUAYCKU1 W4IuEC34Y1Wx+UoJVB+wTV0GqkAzQBRGf6FP3D8ERXUWO7q4qZFhyDyLsgZ1lAccwc gcCzHhxmMAFeQ== X-Spam-Score: -0.7 (/) 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: -1.7 (-) --=-+coQc1aDVWtBPE70kDkl Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Julien Lepiller schreef op zo 06-02-2022 om 22:41 [+0100]: > Now, if you have an OCaml package sources that provides an opam file > (usually called opam, or with the .opam extension), you can import > the > package, recursively or not with something like: >=20 > guix import opam foo -f foo.opam -r >=20 > instead of fetching foo from the repositories, it will fetch the data > directly from the given file. WDYT? I don't know OCaml at all, but that seems potentially useful. Can we have some tests for this in tests/opam.scm? Greetings, Maxime. --=-+coQc1aDVWtBPE70kDkl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYgBEnBccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7knRAQCi2ZjhnPN1LWFPJDAfi9HCBN+h uM+77YR+GNec2y6zYwD8CYIcFLIqXa2nDdLV2SPvBMu+jbaOSHQgLPeOb3s+OAU= =xYaa -----END PGP SIGNATURE----- --=-+coQc1aDVWtBPE70kDkl-- From unknown Fri Jun 13 11:19:19 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#53828] [PATCH] guix: opam: Allow importing local files. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 07 Feb 2022 08:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53828 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Julien Lepiller , 53828@debbugs.gnu.org Received: via spool by 53828-submit@debbugs.gnu.org id=B53828.164422247521897 (code B ref 53828); Mon, 07 Feb 2022 08:28:02 +0000 Received: (at 53828) by debbugs.gnu.org; 7 Feb 2022 08:27:55 +0000 Received: from localhost ([127.0.0.1]:40825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGzNK-0005h3-Cn for submit@debbugs.gnu.org; Mon, 07 Feb 2022 03:27:55 -0500 Received: from h178-251-242-94.cust.a3fiber.se ([178.251.242.94]:54446 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGzNE-0005gd-Ds for 53828@debbugs.gnu.org; Mon, 07 Feb 2022 03:27:52 -0500 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yoctocell.xyz; s=mail; t=1644222460; bh=qHPRTx3d9xugIG/M1mi0pRqjU0ZKV/Zd94Ts1hg6GAU=; h=From:To:Subject:In-Reply-To:References:Date; b=rDbsDfLhzRu3i62spNo/cCJhnvJWaNRGUu/vvbhcKWTuhguFu/acQ0uDDRuyKpuAF NJAl0CBT6lfkPZUAHAlK+YOqorEZQk34ZzyMvOOYkAylBPlwt2uyAU3NG2sNQyJZ7t 5GihoWCmlFOtCUbMghN+yXHNqx1Uei4vA9P0RKTY= In-Reply-To: <20220206224130.2220aae9@tachikoma.lepiller.eu> References: <20220206224130.2220aae9@tachikoma.lepiller.eu> Date: Mon, 07 Feb 2022 09:27:39 +0100 Message-ID: <87k0e713pg.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Julien schrieb am Sonntag der 06. Februar 2022 um 22:41 +01: > Hi Guix! > > This patch lets you import opam packages from a local file. This is a > feature that was requested a few times, and there it is :) > > Now, if you have an OCaml package sources that pro [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps 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.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Julien schrieb am Sonntag der 06. Februar 2022 um 22:41 +01: > Hi Guix! > > This patch lets you import opam packages from a local file. This is a > feature that was requested a few times, and there it is :) > > Now, if you have an OCaml package sources that pro [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Julien schrieb am Sonntag der 06. Februar 2022 um 22:41 +01: > Hi Guix! > > This patch lets you import opam packages from a local file. This is a > feature that was requested a few times, and there it is :) > > Now, if you have an OCaml package sources that provides an opam file > (usually called opam, or with the .opam extension), you can import the > package, recursively or not with something like: > > guix import opam foo -f foo.opam -r > > instead of fetching foo from the repositories, it will fetch the data > directly from the given file. WDYT? Why just limit it to local files? What about accepting a tarball on the internet or any VCS repository? This could generally be useful for any importer. Also, since we already know the name of the package, maybe specifying the directory that contains the OCaml project would be enough? guix import opam foo --type=3Dlocal /path/to/directory guix import opam foo --type=3Dtarball https://example.org/foo.tar.gz guix import opam foo --type=3Dgit https://git.example.org/foo =E2=80=A6 Or am I asking for too much? :-) > From b027391357eef4d6fa1bb8741528cf9650aef568 Mon Sep 17 00:00:00 2001 > Message-Id: > From: Julien Lepiller > Date: Sun, 6 Feb 2022 22:35:14 +0100 > Subject: [PATCH] guix: opam: Allow importing local files. It should be =E2=80=9Cimport: opam: =E2=80=A6=E2=80=9D. > * guix/scripts/import/opam.scm (guix-import-opam): Support `--file` flag. > * guix/import/utils.scm (recursive-import): Add optional file argument. > Pass it to the first iteration when available. > * guix/import/opam.scm (opam-fetch): Fetch from file when available. > (opam->guix-source): Factorize source out of opam->guix-package. > (opam->guix-package): Add file argument. Ensure it does not fail when > name, version and url are not available. > --- > guix/import/opam.scm | 101 +++++++++++++++++++---------------- > guix/import/utils.scm | 17 +++--- > guix/scripts/import/opam.scm | 11 +++- > 3 files changed, 75 insertions(+), 54 deletions(-) > > diff --git a/guix/import/opam.scm b/guix/import/opam.scm > index a6f6fe8c9f..05f79110f8 100644 > --- a/guix/import/opam.scm > +++ b/guix/import/opam.scm > @@ -310,8 +310,11 @@ (define (dependency-list->inputs lst) > (map string->symbol > (ocaml-names->guix-names lst))) >=20=20 > -(define* (opam-fetch name #:optional (repositories-specs '("opam"))) > - (or (fold (lambda (repository others) > +(define* (opam-fetch name #:optional (repositories-specs '("opam")) (fil= e #f)) > + (or (and file (let ((metadata (get-metadata file))) > + `(("metadata" . ,metadata) > + ("version" . #f)))) > + (fold (lambda (repository others) > (match (find-latest-version name repository) > ((_ version file) `(("metadata" ,@(get-metadata file)) > ("version" . ,version))) > @@ -320,17 +323,29 @@ (define* (opam-fetch name #:optional (repositories-= specs '("opam"))) > (filter-map get-opam-repository repositories-specs)) > (warning (G_ "opam: package '~a' not found~%") name))) >=20=20 > -(define* (opam->guix-package name #:key (repo 'opam) version) > +(define (opam->guix-source url-dict) > + (let ((source-url (and url-dict > + (or (metadata-ref url-dict "src") > + (metadata-ref url-dict "archive"))))) > + (if source-url > + (call-with-temporary-output-file > + (lambda (temp port) > + (and (url-fetch source-url temp) > + `(origin > + (method url-fetch) > + (uri ,source-url) > + (sha256 (base32 ,(guix-hash-url temp))))))) > + 'no-source-information))) I would use =E2=80=98and-let*=E2=80=99 instead of =E2=80=98let=E2=80=99, an= d drop the =E2=80=98if=E2=80=99 form. The ability to import from a local file seems to mostly be useful when the package isn=E2=80=99t meant to be submitted to Guix, right? Wouldn=E2= =80=99t it make more sense to make the source a =E2=80=98local-file=E2=80=99 object in= stead of just setting it to #f? > +(define* (opam->guix-package name #:key (repo '("opam")) (file #f) versi= on) > "Import OPAM package NAME from REPOSITORY (a directory name) or, if > -REPOSITORY is #f, from the official OPAM repository. Return a 'package'= sexp > +REPOSITORY is #f, from the official OPAM repository. When FILE is defin= ed, > +import the packaged defined in the opam FILE instead. Return a 'package= ' sexp s/packaged/package/ > (and-let* ((with-opam (if (member "opam" repo) repo (cons "opam" repo)= )) > - (opam-file (opam-fetch name with-opam)) > - (version (assoc-ref opam-file "version")) > + (opam-file (opam-fetch name with-opam file)) > (opam-content (assoc-ref opam-file "metadata")) > - (url-dict (metadata-ref opam-content "url")) > - (source-url (or (metadata-ref url-dict "src") > - (metadata-ref url-dict "archive"))) > + (source (opam->guix-source (metadata-ref opam-content "url"= ))) > (requirements (metadata-ref opam-content "depends")) > (names (dependency-list->names requirements)) > (dependencies (filter-dependencies names)) > @@ -344,47 +359,41 @@ (define* (opam->guix-package name #:key (repo 'opam= ) version) > (not (member name '("dune" "jbuilder")= ))) > native-dependencies)))) > (let ((use-dune? (member "dune" names))) > - (call-with-temporary-output-file > - (lambda (temp port) > - (and (url-fetch source-url temp) > - (values > - `(package > - (name ,(ocaml-name->guix-name name)) > - (version ,version) > - (source > - (origin > - (method url-fetch) > - (uri ,source-url) > - (sha256 (base32 ,(guix-hash-url temp))))) > - (build-system ,(if use-dune? > - 'dune-build-system > - 'ocaml-build-system)) > - ,@(if (null? inputs) > - '() > - `((propagated-inputs (list ,@inputs)))) > - ,@(if (null? native-inputs) > - '() > - `((native-inputs (list ,@native-inputs)))) > - ,@(if (equal? name (guix-name->opam-name (ocaml-n= ame->guix-name name))) > - '() > - `((properties > - ,(list 'quasiquote `((upstream-name . ,na= me)))))) > - (home-page ,(metadata-ref opam-content "homepage"= )) > - (synopsis ,(metadata-ref opam-content "synopsis")) > - (description ,(beautify-description > - (metadata-ref opam-content "descri= ption"))) > - (license ,(spdx-string->license > - (metadata-ref opam-content "license"))= )) > - (filter > - (lambda (name) > - (not (member name '("dune" "jbuilder")))) > - dependencies)))))))) > + (values > + `(package > + (name ,(and name (ocaml-name->guix-name name))) > + (version ,(assoc-ref opam-file "version")) > + (source ,source) > + (build-system ,(if use-dune? > + 'dune-build-system > + 'ocaml-build-system)) > + ,@(if (null? inputs) > + '() > + `((propagated-inputs (list ,@inputs)))) > + ,@(if (null? native-inputs) > + '() > + `((native-inputs (list ,@native-inputs)))) > + ,@(if (and name (equal? name (guix-name->opam-name (ocaml-= name->guix-name name)))) > + '() > + `((properties > + ,(list 'quasiquote `((upstream-name . ,name)))))) > + (home-page ,(metadata-ref opam-content "homepage")) > + (synopsis ,(metadata-ref opam-content "synopsis")) > + (description ,(beautify-description > + (metadata-ref opam-content "description"))) > + (license ,(spdx-string->license > + (metadata-ref opam-content "license")))) > + (filter > + (lambda (name) > + (not (member name '("dune" "jbuilder")))) > + dependencies))))) >=20=20 > -(define* (opam-recursive-import package-name #:key repo) > +(define* (opam-recursive-import package-name #:key repo file) > (recursive-import package-name > #:repo->guix-package opam->guix-package > #:guix-name ocaml-name->guix-name > - #:repo repo)) > + #:repo repo > + #:file file)) >=20=20 > (define (guix-name->opam-name name) > (if (string-prefix? "ocaml-" name) > diff --git a/guix/import/utils.scm b/guix/import/utils.scm > index 1c3cfa3e0b..ab35b8a4fc 100644 > --- a/guix/import/utils.scm > +++ b/guix/import/utils.scm > @@ -470,7 +470,7 @@ (define (topological-sort nodes > (set-insert (node-name head) visited)))))))) >=20=20 > (define* (recursive-import package-name > - #:key repo->guix-package guix-name version re= po > + #:key repo->guix-package guix-name version re= po file > #:allow-other-keys) > "Return a list of package expressions for PACKAGE-NAME and all its > dependencies, sorted in topological order. For each package, The docstrings should also be updated. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmIA1/sVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5i1oP/1TZbQVKhanj9SBwv1P4b1Fp6/0e PQAVN2Koms7eSLsSmApR3Fw6k5HBPWMbBlwcY7UaRBg1eZai0Nbzc7IfEWG3WDNO XjRTT5DNK3ek74Ibq5LZVv9HLyLg59/E3fjr91JVKHesdDCTvSJOz3Zi+u2FXd/7 TWfJfeZIP/L8Y5L819IKyKcnH6oQYocSgnhXUPrbVATWvvd6wk6a7clOZN30pPmK rwruQyfSwe12gCIxYx9bDELeRLTUz7tVw7Lm0MA5xDnBy+RwS4xv0WLOobO+vL8K qCTWloJL3hKRYSu56P24tALQgdfBRAzrXRIKi4dHeMVhRr9AwYLo6DOcNDm9Q6M3 g4KF9l8fqUwuiRCzeKj3V9gs6db76LhsugJPfxCBeaVNg3rX6oo09Q/mKENrR4a2 A/cso8cR7wgViwtD9vUqN9W/YQCuKHFnT8lwb7lRi93TOn59r7Q+Mr7dS8ZgPmL2 ZA2r3+OcVyMLioyPxhQ2OPfHiayY1zAmJl7M5C/pJ0xYy3aZdWqMrbHDePCvNy3K uYTvUSQPWLox37kMAXqAWgN+ElQnQb/d7U72erGlgF3imh1JQTcH4boWgJSVSvZN 6IOEcqG+Vm4iJkKWoJafS8rmyS8FP19sZCQ4TYf6oPFCApw3cHpYlYHfnELNu4J7 mbsgpexm6KbIwJhC =1m+M -----END PGP SIGNATURE----- --=-=-=-- From unknown Fri Jun 13 11:19:19 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#53828] [PATCH] guix: opam: Allow importing local files. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 07 Feb 2022 08:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53828 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Xinglu Chen , 53828@debbugs.gnu.org Received: via spool by 53828-submit@debbugs.gnu.org id=B53828.164422362232653 (code B ref 53828); Mon, 07 Feb 2022 08:48:02 +0000 Received: (at 53828) by debbugs.gnu.org; 7 Feb 2022 08:47:02 +0000 Received: from localhost ([127.0.0.1]:40880 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGzfp-0008UU-8o for submit@debbugs.gnu.org; Mon, 07 Feb 2022 03:47:01 -0500 Received: from lepiller.eu ([89.234.186.109]:46778) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGzfm-0008UK-Uo for 53828@debbugs.gnu.org; Mon, 07 Feb 2022 03:47:00 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 6c8b50a5; Mon, 7 Feb 2022 08:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:in-reply-to:references:message-id:mime-version :content-type:content-transfer-encoding; s=dkim; bh=EoFFm+flW95U vQBoMMrG5zhLGbXongkby4wNpu7Id2E=; b=PGOkcOEkNQjYQxG6NOskrJJ+GuNm y2Up0/0eGAOPiRhVFNJdOVaSygd2BuA6deZdTKrgmKV8VPkN12D4SJPtzaXrbvER T+ImL4N7lAq+hQ9611lB27/PALnEEYdFrPwKFHai0pmnhKe+onCH9RM0hrKldIuZ thMX+/0izUIelQfQeC1NqCDVDtoAN0rXf7As7TIfb4Xi77R3hx19zmURngVTj890 AwXdeRzR0yoSIjgXIiU8dUqudzjXplhmc9HWOPFi6aYMkMenhB6/LDoghU0MejZE VXZciEWyt4BC34vRW7KOQDxhGtOM4V0+1OWrHxf2wtLAC5+s3LK41hlQ2w== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id cbcb3ff2 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Mon, 7 Feb 2022 08:46:55 +0000 (UTC) Date: Mon, 07 Feb 2022 09:46:51 +0100 From: Julien Lepiller User-Agent: K-9 Mail for Android In-Reply-To: <87k0e713pg.fsf@yoctocell.xyz> References: <20220206224130.2220aae9@tachikoma.lepiller.eu> <87k0e713pg.fsf@yoctocell.xyz> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.6 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On February 7, 2022 9:27:39 AM GMT+01:00, Xinglu Chen wrote: >Julien schrieb am Sonntag der 06. Februar 2022 um 22:41 +01: > >> Hi Guix! >> >> This patch lets you import opam pa [...] Content analysis details: (1.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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: 0.6 (/) On February 7, 2022 9:27:39 AM GMT+01:00, Xinglu Chen wrote: >Julien schrieb am Sonntag der 06=2E Februar 2022 um 22:41 +01: > >> Hi Guix! >> >> This patch lets you import opam packages from a local file=2E This is a >> feature that was requested a few times, and there it is :) >> >> Now, if you have an OCaml package sources that provides an opam file >> (usually called opam, or with the =2Eopam extension), you can import th= e >> package, recursively or not with something like: >> >> guix import opam foo -f foo=2Eopam -r >> >> instead of fetching foo from the repositories, it will fetch the data >> directly from the given file=2E WDYT? > >Why just limit it to local files? What about accepting a tarball on the >internet or any VCS repository? This could generally be useful for any >importer=2E That's a good idea, but I'm not sure how to recognize these cases=2E > >Also, since we already know the name of the package, maybe specifying >the directory that contains the OCaml project would be enough? Sure, that could be useful for your suggestion below to use the local dire= ctory as the source=2E > > guix import opam foo --type=3Dlocal /path/to/directory > guix import opam foo --type=3Dtarball https://example=2Eorg/foo=2Etar= =2Egz > guix import opam foo --type=3Dgit https://git=2Eexample=2Eorg/foo > =E2=80=A6 > >Or am I asking for too much? :-) > >> From b027391357eef4d6fa1bb8741528cf9650aef568 Mon Sep 17 00:00:00 2001 >> Message-Id: >> From: Julien Lepiller >> Date: Sun, 6 Feb 2022 22:35:14 +0100 >> Subject: [PATCH] guix: opam: Allow importing local files=2E > >It should be =E2=80=9Cimport: opam: =E2=80=A6=E2=80=9D=2E > >> * guix/scripts/import/opam=2Escm (guix-import-opam): Support `--file` f= lag=2E >> * guix/import/utils=2Escm (recursive-import): Add optional file argumen= t=2E >> Pass it to the first iteration when available=2E >> * guix/import/opam=2Escm (opam-fetch): Fetch from file when available= =2E >> (opam->guix-source): Factorize source out of opam->guix-package=2E >> (opam->guix-package): Add file argument=2E Ensure it does not fail whe= n >> name, version and url are not available=2E >> --- >> guix/import/opam=2Escm | 101 +++++++++++++++++++--------------= -- >> guix/import/utils=2Escm | 17 +++--- >> guix/scripts/import/opam=2Escm | 11 +++- >> 3 files changed, 75 insertions(+), 54 deletions(-) >> >> diff --git a/guix/import/opam=2Escm b/guix/import/opam=2Escm >> index a6f6fe8c9f=2E=2E05f79110f8 100644 >> --- a/guix/import/opam=2Escm >> +++ b/guix/import/opam=2Escm >> @@ -310,8 +310,11 @@ (define (dependency-list->inputs lst) >> (map string->symbol >> (ocaml-names->guix-names lst))) >> =20 >> -(define* (opam-fetch name #:optional (repositories-specs '("opam"))) >> - (or (fold (lambda (repository others) >> +(define* (opam-fetch name #:optional (repositories-specs '("opam")) (f= ile #f)) >> + (or (and file (let ((metadata (get-metadata file))) >> + `(("metadata" =2E ,metadata) >> + ("version" =2E #f)))) >> + (fold (lambda (repository others) >> (match (find-latest-version name repository) >> ((_ version file) `(("metadata" ,@(get-metadata file)) >> ("version" =2E ,version))) >> @@ -320,17 +323,29 @@ (define* (opam-fetch name #:optional (repositorie= s-specs '("opam"))) >> (filter-map get-opam-repository repositories-specs)) >> (warning (G_ "opam: package '~a' not found~%") name))) >> =20 >> -(define* (opam->guix-package name #:key (repo 'opam) version) >> +(define (opam->guix-source url-dict) >> + (let ((source-url (and url-dict >> + (or (metadata-ref url-dict "src") >> + (metadata-ref url-dict "archive"))))) >> + (if source-url >> + (call-with-temporary-output-file >> + (lambda (temp port) >> + (and (url-fetch source-url temp) >> + `(origin >> + (method url-fetch) >> + (uri ,source-url) >> + (sha256 (base32 ,(guix-hash-url temp))))))) >> + 'no-source-information))) > >I would use =E2=80=98and-let*=E2=80=99 instead of =E2=80=98let=E2=80=99, = and drop the =E2=80=98if=E2=80=99 form=2E That would return #f and make the ocher and-let* in opam->guix-package fai= l=2E > >The ability to import from a local file seems to mostly be useful when >the package isn=E2=80=99t meant to be submitted to Guix, right? Wouldn= =E2=80=99t it >make more sense to make the source a =E2=80=98local-file=E2=80=99 object = instead of just >setting it to #f? Excellent idea=2E > >> +(define* (opam->guix-package name #:key (repo '("opam")) (file #f) ver= sion) >> "Import OPAM package NAME from REPOSITORY (a directory name) or, if >> -REPOSITORY is #f, from the official OPAM repository=2E Return a 'pack= age' sexp >> +REPOSITORY is #f, from the official OPAM repository=2E When FILE is d= efined, >> +import the packaged defined in the opam FILE instead=2E Return a 'pac= kage' sexp > >s/packaged/package/ > >> (and-let* ((with-opam (if (member "opam" repo) repo (cons "opam" rep= o))) >> - (opam-file (opam-fetch name with-opam)) >> - (version (assoc-ref opam-file "version")) >> + (opam-file (opam-fetch name with-opam file)) >> (opam-content (assoc-ref opam-file "metadata")) >> - (url-dict (metadata-ref opam-content "url")) >> - (source-url (or (metadata-ref url-dict "src") >> - (metadata-ref url-dict "archive"))) >> + (source (opam->guix-source (metadata-ref opam-content "ur= l"))) >> (requirements (metadata-ref opam-content "depends")) >> (names (dependency-list->names requirements)) >> (dependencies (filter-dependencies names)) >> @@ -344,47 +359,41 @@ (define* (opam->guix-package name #:key (repo 'op= am) version) >> (not (member name '("dune" "jbuilder= ")))) >> native-dependencies)))) >> (let ((use-dune? (member "dune" names))) >> - (call-with-temporary-output-file >> - (lambda (temp port) >> - (and (url-fetch source-url temp) >> - (values >> - `(package >> - (name ,(ocaml-name->guix-name name)) >> - (version ,version) >> - (source >> - (origin >> - (method url-fetch) >> - (uri ,source-url) >> - (sha256 (base32 ,(guix-hash-url temp))))) >> - (build-system ,(if use-dune? >> - 'dune-build-system >> - 'ocaml-build-system)) >> - ,@(if (null? inputs) >> - '() >> - `((propagated-inputs (list ,@inputs)))) >> - ,@(if (null? native-inputs) >> - '() >> - `((native-inputs (list ,@native-inputs)))) >> - ,@(if (equal? name (guix-name->opam-name (ocaml= -name->guix-name name))) >> - '() >> - `((properties >> - ,(list 'quasiquote `((upstream-name =2E= ,name)))))) >> - (home-page ,(metadata-ref opam-content "homepag= e")) >> - (synopsis ,(metadata-ref opam-content "synopsis= ")) >> - (description ,(beautify-description >> - (metadata-ref opam-content "desc= ription"))) >> - (license ,(spdx-string->license >> - (metadata-ref opam-content "license"= )))) >> - (filter >> - (lambda (name) >> - (not (member name '("dune" "jbuilder")))) >> - dependencies)))))))) >> + (values >> + `(package >> + (name ,(and name (ocaml-name->guix-name name))) >> + (version ,(assoc-ref opam-file "version")) >> + (source ,source) >> + (build-system ,(if use-dune? >> + 'dune-build-system >> + 'ocaml-build-system)) >> + ,@(if (null? inputs) >> + '() >> + `((propagated-inputs (list ,@inputs)))) >> + ,@(if (null? native-inputs) >> + '() >> + `((native-inputs (list ,@native-inputs)))) >> + ,@(if (and name (equal? name (guix-name->opam-name (ocam= l-name->guix-name name)))) >> + '() >> + `((properties >> + ,(list 'quasiquote `((upstream-name =2E ,name)))= ))) >> + (home-page ,(metadata-ref opam-content "homepage")) >> + (synopsis ,(metadata-ref opam-content "synopsis")) >> + (description ,(beautify-description >> + (metadata-ref opam-content "description")= )) >> + (license ,(spdx-string->license >> + (metadata-ref opam-content "license")))) >> + (filter >> + (lambda (name) >> + (not (member name '("dune" "jbuilder")))) >> + dependencies))))) >> =20 >> -(define* (opam-recursive-import package-name #:key repo) >> +(define* (opam-recursive-import package-name #:key repo file) >> (recursive-import package-name >> #:repo->guix-package opam->guix-package >> #:guix-name ocaml-name->guix-name >> - #:repo repo)) >> + #:repo repo >> + #:file file)) >> =20 >> (define (guix-name->opam-name name) >> (if (string-prefix? "ocaml-" name) >> diff --git a/guix/import/utils=2Escm b/guix/import/utils=2Escm >> index 1c3cfa3e0b=2E=2Eab35b8a4fc 100644 >> --- a/guix/import/utils=2Escm >> +++ b/guix/import/utils=2Escm >> @@ -470,7 +470,7 @@ (define (topological-sort nodes >> (set-insert (node-name head) visited)))))))) >> =20 >> (define* (recursive-import package-name >> - #:key repo->guix-package guix-name version = repo >> + #:key repo->guix-package guix-name version = repo file >> #:allow-other-keys) >> "Return a list of package expressions for PACKAGE-NAME and all its >> dependencies, sorted in topological order=2E For each package, > >The docstrings should also be updated=2E From unknown Fri Jun 13 11:19:19 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#53828] [PATCH] guix: opam: Allow importing local files. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Feb 2022 13:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53828 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Julien Lepiller , 53828@debbugs.gnu.org Received: via spool by 53828-submit@debbugs.gnu.org id=B53828.164441367728414 (code B ref 53828); Wed, 09 Feb 2022 13:35:01 +0000 Received: (at 53828) by debbugs.gnu.org; 9 Feb 2022 13:34:37 +0000 Received: from localhost ([127.0.0.1]:50221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHn7E-0007OE-Qh for submit@debbugs.gnu.org; Wed, 09 Feb 2022 08:34:37 -0500 Received: from h178-251-242-94.cust.a3fiber.se ([178.251.242.94]:45112 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHn7C-0007Ny-Mq for 53828@debbugs.gnu.org; Wed, 09 Feb 2022 08:34:35 -0500 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yoctocell.xyz; s=mail; t=1644413667; bh=Nfp2sQyD6omxmgUzxidtXObgtYHd09dljafUtZAsYR4=; h=From:To:Subject:In-Reply-To:References:Date; b=jYqbYctwua8hnzOLL7vMcMZqnxFUzPzEKRmdLOWc33bEa68d8m4vaRjdTQskECzN/ K8VXS6eLSL39jJUWUUq0gZc1elUoT7S0GpylLNAlHfGhOnRr8egUR+yN8ghwUUG5T/ JZqsOpOnb81VDgY4/XjMnnU1e1DDhbbVydWp0m1M= In-Reply-To: References: <20220206224130.2220aae9@tachikoma.lepiller.eu> <87k0e713pg.fsf@yoctocell.xyz> Date: Wed, 09 Feb 2022 14:34:25 +0100 Message-ID: <87tud8w4da.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, Julien schrieb am Montag der 07. Februar 2022 um 09:46 +01: >>> +(define (opam->guix-source url-dict) >>> + (let ((source-url (and url-dict >>> + (or (metadata-ref url-dict "src") >>> + (metadata-ref url-dict "archive"))))) >>> + (if source-url >>> + (call-wit [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps 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.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, Julien schrieb am Montag der 07. Februar 2022 um 09:46 +01: >>> +(define (opam->guix-source url-dict) >>> + (let ((source-url (and url-dict >>> + (or (metadata-ref url-dict "src") >>> + (metadata-ref url-dict "archive"))))) >>> + (if source-url >>> + (call-wit [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Julien schrieb am Montag der 07. Februar 2022 um 09:46 +01: >>> +(define (opam->guix-source url-dict) >>> + (let ((source-url (and url-dict >>> + (or (metadata-ref url-dict "src") >>> + (metadata-ref url-dict "archive"))))) >>> + (if source-url >>> + (call-with-temporary-output-file >>> + (lambda (temp port) >>> + (and (url-fetch source-url temp) >>> + `(origin >>> + (method url-fetch) >>> + (uri ,source-url) >>> + (sha256 (base32 ,(guix-hash-url temp))))))) >>> + 'no-source-information))) >> >>I would use =E2=80=98and-let*=E2=80=99 instead of =E2=80=98let=E2=80=99, = and drop the =E2=80=98if=E2=80=99 form. > > That would return #f and make the ocher and-let* in opam->guix-package > fail. Right, I missed the =E2=80=98and-let*=E2=80=99 in =E2=80=98opam->guix-packa= ge=E2=80=99. However, seeing as the =E2=80=98source=E2=80=99 variable is only used in the body of the = =E2=80=98and-let*=E2=80=99, I think it would make sense to not even bind the result of =E2=80=98opam->guix-source=E2=80=99 to any variable, instead using it direc= tly in the =E2=80=98package=E2=80=99 form. `(package =E2=80=A6 (source ,source) =E2=80=A6) becomes `(package =E2=80=A6 (source ,(opam->guix-source (metadata-ref opam-content "url"))) =E2=80=A6) WDYT? --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmIDwuEVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5yJYQALpJEYSpJUAkAn7NtkD2v7qvC2q/ VOXdrxDv6T9hMUE62OVe+Tqfy1PIwCVCFeHDldaHg+GrGONig5bFfSeqN/QpsjGp K4qU2HiA5XUwoDtpXtSBaNgAiJtFQ8FWc95EwPAM1sM1FDDwq31uQDIcaBp8xIiS f8bvOm6RaOJFYvYecWpqhOkfEjkm6hjBKW5BKnhQGis/ItTPlT17m7TFZ5E/BOSu Wi699NBbaXPqk65OSYozMt514cKwED5zNEtDmCKHtmAJX7CQ//0+Zb/cciqysbgH FcjhnaR2/CPfg2lI2xiQrVEaAWHG8Ymzw2bMFtvmMVPxk/OTTt6e570QUuQvXr1l JZV6p1Jn3UB93NpE4EDPhmsKrtMlCPva64bBMdaRwG65+/i/UL82sr909TDZPKM5 FruC+l918rIESBJcEuOOYGHJRb6yomeI6UmkH30++PgwIvJWIxpdwBgUN8XgHEb3 MWWGzsrurbaO4zatPNFC68b5/pkwONfadFXSQyn2osaVXDLzrwRBkjN190YMkJbw gL/KKi99BxWtxd3VE0WVzWhhU8i4dDlRZLtpPfriaSt+W/bwc9ewd6j3+EtrOjlo eDnPUvlk7veRROLHjSkA3a4P7u0eeEQxD/kuICzg915yDmJ04Cee92zJiUgaXFnO 7EjqITOt2RX/hQdK =RitB -----END PGP SIGNATURE----- --=-=-=-- From unknown Fri Jun 13 11:19:19 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#53828] [PATCH v2] import: opam: Allow importing local files. References: <20220206224130.2220aae9@tachikoma.lepiller.eu> In-Reply-To: <20220206224130.2220aae9@tachikoma.lepiller.eu> Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 12 Jun 2022 06:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53828 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53828@debbugs.gnu.org Received: via spool by 53828-submit@debbugs.gnu.org id=B53828.16550155024843 (code B ref 53828); Sun, 12 Jun 2022 06:32:01 +0000 Received: (at 53828) by debbugs.gnu.org; 12 Jun 2022 06:31:42 +0000 Received: from localhost ([127.0.0.1]:54465 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o0H8I-0001Fm-0S for submit@debbugs.gnu.org; Sun, 12 Jun 2022 02:31:41 -0400 Received: from lepiller.eu ([89.234.186.109]:40018) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o0H8G-0001Fc-00 for 53828@debbugs.gnu.org; Sun, 12 Jun 2022 02:31:33 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 497d16a0 for <53828@debbugs.gnu.org>; Sun, 12 Jun 2022 06:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; s=dkim; bh=fYPzzNqWsNZfjWY2zqpk5ZcCRk0VO6Z0/vjA3vWQjd4=; b=Sjw9 ofaXimmDP84eaXGNWV9Piw0OCFCUDulooVWbyX7ka4dilBIMin0WKMTvHJTN2UsQ aHcZmbqEPDMCfOYqzSc4acFsg1orYJfkNFPKB2d3nqf7L3fBuuOBRYHvNjrMLTag 3wIlNKaSXtwukiYI/c6uhTL+BmmPVWbG8F9m0s4XFWqx9aTpoR9aPMq0JEE4Gp4V mh5cF0OS8y+KUpnKMPmIfPdOAS3w+10GO4SaG9RSZROmKxTWmg+7dF0y6J+Gi2L3 dcC3SOD34eX4eBp5I6SiuwGBxxzipP2fcRNj6J6s9Dw4rKSmRornt7xkLaIcxjR2 wOJoNLEAgSy3qCaNNA== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id def212aa (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <53828@debbugs.gnu.org>; Sun, 12 Jun 2022 06:31:28 +0000 (UTC) From: Julien Lepiller Date: Sun, 12 Jun 2022 08:31:21 +0200 Message-Id: <20220612063121.26914-1-julien@lepiller.eu> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) 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: -1.0 (-) * guix/scripts/import/opam.scm (guix-import-opam): Support `--scan-project` flag. * guix/import/opam.scm (opam-scan-projects): New procedure. --- guix/import/opam.scm | 32 ++++++++++++++++++++++++++++++-- guix/scripts/import/opam.scm | 11 +++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/guix/import/opam.scm b/guix/import/opam.scm index b4b5a6eaad..3989dff58e 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -32,9 +32,11 @@ (define-module (guix import opam) #:use-module (srfi srfi-2) #:use-module ((srfi srfi-26) #:select (cut)) #:use-module ((web uri) #:select (string->uri uri->string)) - #:use-module ((guix build utils) #:select (dump-port find-files mkdir-p)) + #:use-module ((guix build utils) #:select (dump-port find-files mkdir-p + delete-file-recursively)) #:use-module (guix build-system) #:use-module (guix build-system ocaml) + #:use-module (guix git) #:use-module (guix http-client) #:use-module (guix ui) #:use-module (guix packages) @@ -48,7 +50,8 @@ (define-module (guix import opam) spdx-string->license url-fetch)) #:use-module ((guix licenses) #:prefix license:) - #:export (opam->guix-package + #:export (opam-scan-projects + opam->guix-package opam-recursive-import %opam-updater @@ -178,6 +181,31 @@ (define* (get-opam-repository #:optional (repo "opam")) ;; Prevent Guile 3 from inlining this procedure so we can mock it in tests. (set! get-opam-repository get-opam-repository) +(define (opam-scan-dir dir) + (let* ((opam-files (find-files dir "\\.opam$")) + (dir (opam-cache-directory dir)) + (packages (string-append dir "/packages"))) + (when (file-exists? dir) + (delete-file-recursively dir)) + (mkdir-p packages) + (for-each + (lambda (package) + (let* ((name (basename package ".opam")) + (version (metadata-ref (get-metadata package) "version")) + (file (string-append packages "/" name "." version "/opam"))) + (mkdir-p (dirname file)) + (copy-file package file))) + opam-files) + dir)) + +(define (opam-scan-project project) + (if (file-exists? project) + (opam-scan-dir project) + (opam-scan-dir (update-cached-checkout project)))) + +(define (opam-scan-projects projects) + (map opam-scan-project projects)) + (define (get-version-and-file path) "Analyse a candidate path and return an list containing information for proper version comparison as well as the source path for metadata." diff --git a/guix/scripts/import/opam.scm b/guix/scripts/import/opam.scm index 834ac34cb0..0b15a81541 100644 --- a/guix/scripts/import/opam.scm +++ b/guix/scripts/import/opam.scm @@ -50,6 +50,10 @@ (define (show-help) --repo import packages from this opam repository (name, URL or local path) can be used more than once")) (display (G_ " + -p, --scan-project import packages from this OCaml project (URL of a + Git repository or local path). Can be used more + than once.")) + (display (G_ " -V, --version display version information and exit")) (newline) (show-bug-report-information)) @@ -69,6 +73,9 @@ (define %options (option '(#\r "recursive") #f #f (lambda (opt name arg result) (alist-cons 'recursive #t result))) + (option '(#\p "scan-project") #t #f + (lambda (opt name arg result) + (alist-cons 'project arg result))) %standard-import-options)) @@ -86,6 +93,10 @@ (define (parse-options) (repo (filter-map (match-lambda (('repo . name) name) (_ #f)) opts)) + (projects (filter-map (match-lambda + (('project . name) name) + (_ #f)) opts)) + (repo (append repo (opam-scan-projects projects))) (args (filter-map (match-lambda (('argument . value) value) -- 2.35.1 From unknown Fri Jun 13 11:19:19 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#53828] [PATCH v2] import: opam: Allow importing local files. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 12 Jun 2022 06:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53828 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53828@debbugs.gnu.org Received: via spool by 53828-submit@debbugs.gnu.org id=B53828.16550158545560 (code B ref 53828); Sun, 12 Jun 2022 06:38:01 +0000 Received: (at 53828) by debbugs.gnu.org; 12 Jun 2022 06:37:34 +0000 Received: from localhost ([127.0.0.1]:54487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o0HE6-0001Rb-7o for submit@debbugs.gnu.org; Sun, 12 Jun 2022 02:37:34 -0400 Received: from lepiller.eu ([89.234.186.109]:40024) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o0HE3-0001RS-SV for 53828@debbugs.gnu.org; Sun, 12 Jun 2022 02:37:32 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 4ef78ea5 for <53828@debbugs.gnu.org>; Sun, 12 Jun 2022 06:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=dkim; bh=daS3FrZUfUFq L5neELYEzP6edzplZCxal163SZA3uyE=; b=CeSAfgKydJ98d1K6ben28mExmu8x EOdjIrb7mbU56qu93omILVUD/7gmplTMu6lKiryCjA49r4tvTeq6bCgLJH4MbIJA 9FeV/Et0TmThkDh+hB/oijc+TOamOC2zJXTgoX2DNZh0M4y/AI4BhOrJOcV1Otzj 1ZM582nu2gmSNlSSIiNbIZhJb7YRlTSZ5HM0VyVTCy3Uf8cEb13I1pZYI3yX4/Om 5O/mzrxE4wUKUwtgyaHb01VcndQcQfrstQcm/4ImaOKgK3F3oTNuoXmHb0qq9GY6 YLpDa50QMtocEv/x0YX2k3z0bPEgcGuViiHny5LUmXJZH2emFwvaBJ6GsQ== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id b5c22065 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <53828@debbugs.gnu.org>; Sun, 12 Jun 2022 06:37:30 +0000 (UTC) Date: Sun, 12 Jun 2022 08:37:28 +0200 From: Julien Lepiller Message-ID: <20220612083728.4f6984e7@sybil.lepiller.eu> In-Reply-To: <20220612063121.26914-1-julien@lepiller.eu> References: <20220206224130.2220aae9@tachikoma.lepiller.eu> <20220612063121.26914-1-julien@lepiller.eu> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) 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: -1.0 (-) As you can see, I've reworked the patch a little. Instead of a special #:file argument to the importer, I simply create an opam repository out of a given "project" (if you have a better name...). A "project" is an upstream source repository, either a local checkout or a remote git repository, that contain .opam files. The new version of the patch scans the project for opam packages and adds them to a local repository. When importing recursively, they become available, so countrary to the previous patch, you can use this for recursive import even when multiple packages are not in the opam repository but in the project (some projects split their code into multiple opam packages, like coq for instance). You can specify --scan-project multiple times, so you can import from dependent repos too. WDYT? :)