From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id INctDdbWAmIi3wAAgWs5BA (envelope-from ) for ; Tue, 08 Feb 2022 21:47:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 2KOICtbWAmKKDAAA9RJhRA (envelope-from ) for ; Tue, 08 Feb 2022 21:47:18 +0100 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 7890D29E43 for ; Tue, 8 Feb 2022 21:47:17 +0100 (CET) Received: from localhost ([::1]:43210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHXOK-0000kC-Ec for larch@yhetil.org; Tue, 08 Feb 2022 15:47:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHWuB-0000ae-AH for guix-patches@gnu.org; Tue, 08 Feb 2022 15:16:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:54940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHWuB-0007WQ-0B for guix-patches@gnu.org; Tue, 08 Feb 2022 15:16:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHWuA-0002Zz-Oi for guix-patches@gnu.org; Tue, 08 Feb 2022 15:16:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53882] [PATCH 02/24] import: opam: Factor out source import. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 08 Feb 2022 20:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53882 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53882@debbugs.gnu.org Received: via spool by 53882-submit@debbugs.gnu.org id=B53882.16443513059565 (code B ref 53882); Tue, 08 Feb 2022 20:16:02 +0000 Received: (at 53882) by debbugs.gnu.org; 8 Feb 2022 20:15:05 +0000 Received: from localhost ([127.0.0.1]:48772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHWtE-0002Tv-QL for submit@debbugs.gnu.org; Tue, 08 Feb 2022 15:15:05 -0500 Received: from lepiller.eu ([89.234.186.109]:47110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHWtA-0002Sz-9i for 53882@debbugs.gnu.org; Tue, 08 Feb 2022 15:15:01 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id dfa9c805 for <53882@debbugs.gnu.org>; Tue, 8 Feb 2022 20:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=NW/BuvfwAu23TkC40qntIHC3E PDjCeTLtn4+PcWHNws=; b=kcbDyFRE1bAlwny4UJqbIX4fU5sF91XzTeCJycOD/ uwG6Tp6v5X3wldu+ct+2M2BTmWI40RlPSYeU0q6lYyZBwP1JYQ8XCAS4JkygOw/U r8tYdfuOLMCvsyYxqGitvwFlywNxFI0odlPnd/tZTsQyM7nJhBeZJpKiEjYZRNBC L1VmswkNcu2hkMJANKOwAvvA9p1t8DxG4y/QGVuFDKrWTz9vTGPWf4DtdG1WJo8O FKh1sKSHuCoMXzUILxdqGzw0PF+K7E8SFJViNzkiLauvSwxz4oyChyQWdwVqF4tt +MCx0a8EoQNTIhhw99h8rSsNgkqNzjlOBL6ipGhPNj5Sw== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id ab1367bd (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <53882@debbugs.gnu.org>; Tue, 8 Feb 2022 20:14:56 +0000 (UTC) From: Julien Lepiller Date: Tue, 8 Feb 2022 21:14:28 +0100 Message-Id: <81d0041fc5805bbb9a23b4c9e1bc59f5be8d5351.1644350657.git.julien@lepiller.eu> X-Mailer: git-send-email 2.34.0 In-Reply-To: <1dcef02fe1f5f25657c6427d09c43bfc41091050.1644350657.git.julien@lepiller.eu> References: <1dcef02fe1f5f25657c6427d09c43bfc41091050.1644350657.git.julien@lepiller.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644353237; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=a3e1k90EQWGphf1gjw5bO+4vwixFva+BCVEMiSqF8/A=; b=JSKYECbQs9vR4wMxD2R3I9BOvgaF0T6fRXlXFoJnupS5sqvcbmwZ/x+APlzXX2QkkoTBZz 29aaFPTDOlSRX+thiw14L/dcQpiL/aP0k/Lbhx1kAc77md+1ATTJMg4m4xHWgkEXl0bLSY EPw2wZpiX4Yb1oNoCzzIb3InuV+sFyNOOspe1rqpEQAlIVC1lvazbl5diuL/VsumjfhuiD KyMY2gt0wEg1ZRe77T5V3mxebXQ3jI2jkoqd3rb96Gdh7fKZTl944ATtwd2h6qySdwbl+W q2guJ8u4KyQyE9GpF4w5vmBTC3jEF9wDNP7wh/uxLrXN6xa/CBHSMm7ezP3Z+A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644353237; a=rsa-sha256; cv=none; b=pxguS2nmvKL6oaHVKDS8ETEzBSbgRp8+Ke/iCSDzN+FeLvRRXJ+BykjOoQ+Fe6QwtWLQAr 9899t0641SsxmInEnfmBjyFyzLXrBMJGBowmaaPlBFMqKtttda4jr0DBlG1nwU94WK4lIk xogpRpQlyl2pnt08JMXhSSfuBNHwDnbQI8aFq5be7+wulZpbLUBcVWOaNX28Bjr9u2i+FY bbMDtG2LwS7+n/Kx6UFZ3NG2j3HQ2y1TGfYxMFu6LDCpD7kx1SUXtW2/sFj1jfz2QAJFov HA4FlZPt9AqDPNTSQPT4ENxAG5BxthuyQYPAHxS8TlYjGylvnOhTxegB0Intig== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=kcbDyFRE; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=kcbDyFRE; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 7890D29E43 X-Spam-Score: -0.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: l1vGzpjEY0I8 This also ensures a package can be imported even when it does not specify a URL. * guix/import/opam.scm (opam->guix-source): New procedure. (opam->guix-package): Use it. --- guix/import/opam.scm | 81 +++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/guix/import/opam.scm b/guix/import/opam.scm index f51d17dea4..b4b5a6eaad 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -324,6 +324,20 @@ (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-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) version) "Import OPAM package NAME from REPOSITORY (a directory name) or, if REPOSITORY is #f, from the official OPAM repository. Return a 'package' sexp @@ -332,9 +346,7 @@ (define* (opam->guix-package name #:key (repo 'opam) version) (opam-file (opam-fetch name with-opam)) (version (assoc-ref opam-file "version")) (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)) @@ -348,41 +360,34 @@ (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 ,(ocaml-name->guix-name name)) + (version ,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 (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) (recursive-import package-name -- 2.34.0