From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 EHaWCwE4UGJRKwEAgWs5BA (envelope-from ) for ; Fri, 08 Apr 2022 15:26:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id wHtICAE4UGL3WQEAauVa8A (envelope-from ) for ; Fri, 08 Apr 2022 15:26:25 +0200 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 D216B8A4B for ; Fri, 8 Apr 2022 15:26:24 +0200 (CEST) Received: from localhost ([::1]:33076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncod5-0005bt-R0 for larch@yhetil.org; Fri, 08 Apr 2022 09:26:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncoap-0002Mb-6P for guix-patches@gnu.org; Fri, 08 Apr 2022 09:24:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncoao-0001Ps-UT for guix-patches@gnu.org; Fri, 08 Apr 2022 09:24:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ncoao-0007sA-RU for guix-patches@gnu.org; Fri, 08 Apr 2022 09:24:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#53882] [PATCH v2 03/25] import: opam: Factor out source import. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 08 Apr 2022 13:24: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 Cc: Julien Lepiller Received: via spool by 53882-submit@debbugs.gnu.org id=B53882.164942421729991 (code B ref 53882); Fri, 08 Apr 2022 13:24:02 +0000 Received: (at 53882) by debbugs.gnu.org; 8 Apr 2022 13:23:37 +0000 Received: from localhost ([127.0.0.1]:34228 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncoaO-0007nR-Qn for submit@debbugs.gnu.org; Fri, 08 Apr 2022 09:23:37 -0400 Received: from mail-wm1-f49.google.com ([209.85.128.49]:44813) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncoaK-0007lq-OH for 53882@debbugs.gnu.org; Fri, 08 Apr 2022 09:23:33 -0400 Received: by mail-wm1-f49.google.com with SMTP id v20-20020a05600c15d400b0038e9a88aee7so2390202wmf.3 for <53882@debbugs.gnu.org>; Fri, 08 Apr 2022 06:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BUJtkYFdetVaPu6l8TfFFtPl0IRzAI6UAoMdeWnnqFI=; b=GvH3IAxhlMATlgi5aHlpmd0ZIHOM/BUgMiiN4wiMfdJaKHKxGT4JB0+MFwPdiBII2j 2oblEa0waF8HH1z5apw+IPlEUQyWuiOjA64W57yPlftP4LgAsbVzaywr+h/L6n2cCkmM 0cWRYIPR9JK/5RDBRiafEjxjBKop3+GikPrsF2RC0vHWQz2IkxN5kiJqJzbRtJjY+dC/ q+TIdzFC9xjFJ+Enp5Lywi7B6y7IiRCyWNigbv1sxpG0GjBcdyfDs3SKcq8O3alYAIob numzx38HbL3ndnTtj7G2WYFF2pvKO+dqAX81t1boUQlztWEAcGOH1lRLs012a0cYef7H dAtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BUJtkYFdetVaPu6l8TfFFtPl0IRzAI6UAoMdeWnnqFI=; b=FDPjFs4OfEKze5Y8ZuUTnyYPGv5b+nteMpb7VdZlsbu/7S05ChHwlFVDcEjRX76Vd3 yPWscSWPOrFwRRHK/D4Nxf/hYGXfK7NezCIDzR5b894ykt7FL7QPv2EJ9arZCFja6Tx2 tlVLSCxPclbZP/w1RESVaZpg+TxOD1ef+xsHdGxNjuRg7M9+IOH0TLUvso3b3sewygbK OZHfM2Nb+Wgh2Go5emTDHEoEt1856DmLZvpKJ+MsQaothlnhs2/fmLs8CWjBqybCS9AJ Of05qmKV2hqUPEn2XhJjA8YiP0g/e+oBXyuE9Iu94CdySFqUWfyhIk3ceRK+F28bh5dE trOA== X-Gm-Message-State: AOAM530c4cnhmW3Kc+QT/7hJPKsIxMwGngGUkNXdko3D7ma1U61IKzyV LxmPaleW/BprZ+HAtXR/NdQhE0VOHHU= X-Google-Smtp-Source: ABdhPJyokck7FkX40ojzOKikwyETUG0EuB+DQjwkxTI8t8mgv6juS1A94wKKVBPIC4EScvTUfkLwlQ== X-Received: by 2002:a05:600c:d8:b0:38e:785a:2fc7 with SMTP id u24-20020a05600c00d800b0038e785a2fc7mr17019251wmm.59.1649424207151; Fri, 08 Apr 2022 06:23:27 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id z3-20020a1cf403000000b0037d1f4a2201sm10108954wma.21.2022.04.08.06.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 06:23:26 -0700 (PDT) From: zimoun Date: Fri, 8 Apr 2022 15:22:43 +0200 Message-Id: <20220408132305.3301350-3-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220408132305.3301350-1-zimon.toutoune@gmail.com> References: <20220408132305.3301350-1-zimon.toutoune@gmail.com> 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-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1649424384; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=BUJtkYFdetVaPu6l8TfFFtPl0IRzAI6UAoMdeWnnqFI=; b=GrPBR2u1Ygzf77hwJmfCt/1eMkAd6curN/dZdHDNFJZ0lW7SEY7eBC2UL0aTzk260A2S7o m7aJt9pEsQyfOIv369N576Bgdazj76+F1W3CQpI4ytRqO1loFXlXclekfNhBNi50L6ptgX m6GONG4z9iljAvxG7n7Xg2c2f6IoObib3ZRF5T+kSgbjFEWf1TGB8br4tuHGlhdbjQ+IIr E2vSaWPxv7u5ozXG1NBFRmezPjbJ1+fNCWjLaCzDOroGc/Ltym0RJrOC2D9mLl6Qi6E42G YA4CXxe/jhTKx81aO6dYy10db+iyiEQZOwU5eaTBUhLqVMJxNGD5jVo2WeZwEA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649424384; a=rsa-sha256; cv=none; b=R9Nuf23e3c8RvtRJFDDLyz2Ttk5g31dXvvBaH1g8EzJLi+yTIgEvqVI8XlT08k7lm89Si2 xp5bCp+CgeqUKqnZ4mX3ty2BcwhJbCmtstr7Zw07jcF+h7/aZUdUtIEXFa9njqlfIK7Tcx JXhferJ91zcTxO5LnrPbiZBzBK+pRYj6IA1dFqey3J5jmTAgMUPXlC5mMGVlLVZ93d8+Pb F69obaPAYET6ib9jwYRNXWy5FM9x6RUfnI/OEfH8fiGMZnhHhCxoU3Pb599EwMgcIC7V3Q /up92dTlUhvuSg4l8496VDL5kJIUE/CnYGPmB8xC3GKmyYXaq+9IwFNrcaQYKQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=GvH3IAxh; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: 5.13 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=GvH3IAxh; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: D216B8A4B X-Spam-Score: 5.13 X-Migadu-Scanner: scn0.migadu.com X-TUID: +VF74k/3U+25 From: Julien Lepiller 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