From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id GOl2BcRBZmRgdQAASxT56A (envelope-from ) for ; Thu, 18 May 2023 17:18:28 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mGNzBMRBZmSepwAAG6o9tA (envelope-from ) for ; Thu, 18 May 2023 17:18:28 +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 9DC38C1B2 for ; Thu, 18 May 2023 17:18:27 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzfON-0004j9-Iw; Thu, 18 May 2023 11:18:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzfOG-0004ew-Kj for guix-patches@gnu.org; Thu, 18 May 2023 11:18:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzfOG-0002AM-C4 for guix-patches@gnu.org; Thu, 18 May 2023 11:18:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pzfOG-0005Y0-5x for guix-patches@gnu.org; Thu, 18 May 2023 11:18:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63571] [PATCH 12/14] import: cpan: Represent dependencies as records. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 18 May 2023 15:18:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63571 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63571@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63571-submit@debbugs.gnu.org id=B63571.168442303121187 (code B ref 63571); Thu, 18 May 2023 15:18:04 +0000 Received: (at 63571) by debbugs.gnu.org; 18 May 2023 15:17:11 +0000 Received: from localhost ([127.0.0.1]:54168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzfNP-0005Va-1y for submit@debbugs.gnu.org; Thu, 18 May 2023 11:17:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzfN2-0005Qt-G7 for 63571@debbugs.gnu.org; Thu, 18 May 2023 11:16:52 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzfMx-0001wH-9y; Thu, 18 May 2023 11:16:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=qFFHT6l8XAKZCoiV9Q/KxA8PSqy/ofNEYETzd9HlyYM=; b=lyzYf7b6P3/vJxYnWGwU wv2FAAp6G90m3Gc2wfqmaW9cjMgprDfz18GnfbIZhbwuYomx6CgA7Ucs1QceIrpsZjqmCWBIAOcVh facZUlzLut5GbVJN3hQZTzwFPCq/NrVdVvqO9EgUdQrHsxoQCv5VcD9KaVDVAB+wdIV7j1yb/5F38 rz8zKGEpTwJyyVhJAqNYc7li6ZJxFx4pzpT3xsOazZAWOcO9PVcHAc0NKJCfdgbNNUfU/6G4VJT1X ZMtWhmOMMwwFFuaEuSvt/RqW0NBApVeYR87rY5QgKl1M5dF3g36dfw9cbFII6ZjNhmD/Un4bPo/tN hqbTMcp3sKd0Mg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzfMw-0007G6-TS; Thu, 18 May 2023 11:16:43 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Thu, 18 May 2023 17:16:20 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; =?UTF-8?Q?charset=3D=1B[6~?= 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1684423107; a=rsa-sha256; cv=none; b=F4CKbhXaeojstZv5lu9kBqFKxuvjLwb7XOjQrXh0mSUFSDbImQizWyuHpmJfEQwiyTb1nK XcnuauX9zS50/mTrKD+whmGgkp1YlbZFYFBOyAzVhrgeM1viHgf+TmEhHX3TLBPS2INMm7 zAN3fdxPYtjhgxUQ+zhMmuOoyFKHMHwjcOwHulTpgQgjU7Z9uNiGj641hJ9fY1ZXEsouXY kukxTzV/RWyKD2SC88nyo35BQDybdkElz4Vc5DqZYYG6eVWJuxKQf0R6Qf2Ws7zIqB2J68 dzYlfdbwCEVDHjtu6Sy50XB9BnTSLUO+iHdHKVu6sT+wwH8S9Mzo89GPN/BScA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=lyzYf7b6; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1684423107; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=qFFHT6l8XAKZCoiV9Q/KxA8PSqy/ofNEYETzd9HlyYM=; b=aNj3vjRvjCAF0OeiCBFClRJvJayIWXuRhCwiKEUt6zW70sdu7yGtnjSZk2fkkHxpekU069 lKUgqLbv9cSrMIFNUNt6mt4OZ6B8mkXp59lcgT8ZpHf+MWpAHFTkI0Xd/k642jyWJznCnn PPrQR5zvJZB6FgG1HD4u1knPIMU6XKUyLpZFhOarbZioPclc7NNsdo4CrUGGjSFWcEC4Lh OIS+3RePpvOIFjzmRPvW/3LuyH2KU9zlFE025zQXD+j9L+i5wv/ER4Ps4hHKfP39eVqK3I 1mUzhiLfFOC56Bds5Xt8sBxtfhWvVnlDWoJ047QD+TSVb6l6APRsaHQwZF8Jxg== X-Migadu-Spam-Score: -3.99 X-Spam-Score: -3.99 X-Migadu-Queue-Id: 9DC38C1B2 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=lyzYf7b6; dmarc=pass (policy=none) header.from=gnu.org; 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-TUID: 8K7Ehp5QZfLH * guix/import/cpan.scm (cpan-name->downstream-name) (cran-dependency->upstream-input, cran-module-inputs): New procedures. (cpan-module->sexp)[guix-name, convert-inputs]: Remove. [maybe-inputs]: Adjust to deal with . Use 'cpan-name->downstream-name' instead of 'guix-name'. Add call to 'cpan-module-inputs' and adjust calls to 'maybe-inputs'. No longer emit input labels. * tests/cpan.scm ("cpan->guix-package"): Adjust test accordingly. --- guix/import/cpan.scm | 98 +++++++++++++++++++++++++------------------- tests/cpan.scm | 7 +--- 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm index d7f300777e..b6587d6821 100644 --- a/guix/import/cpan.scm +++ b/guix/import/cpan.scm @@ -3,7 +3,7 @@ ;;; Copyright © 2015 Mark H Weaver ;;; Copyright © 2016 Alex Sassmannshausen ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice -;;; Copyright © 2020, 2021 Ludovic Courtès +;;; Copyright © 2020, 2021, 2023 Ludovic Courtès ;;; Copyright © 2022 Hartmut Goebel ;;; ;;; This file is part of GNU Guix. @@ -222,56 +222,73 @@ (define core-module? first perl-version last)))) (loop))))))))))) +(define (cpan-name->downstream-name name) + "Return the Guix package name corresponding to NAME." + (if (string-prefix? "perl-" name) + (string-downcase name) + (string-append "perl-" (string-downcase name)))) + +(define (cran-dependency->upstream-input dependency) + "Return the corresponding to DEPENDENCY, or #f if +DEPENDENCY denotes an implicit or otherwise unnecessary dependency." + (match (cpan-dependency-module dependency) + ("perl" #f) ;implicit dependency + (module + (let ((type (match (cpan-dependency-phase dependency) + ((or 'configure 'build 'test) + ;; "runtime" may also be needed here. See + ;; https://metacpan.org/pod/CPAN::Meta::Spec#Phases, + ;; which says they are required during + ;; building. We have not yet had a need for + ;; cross-compiled Perl modules, however, so + ;; we leave it out. + 'native) + ('runtime + 'propagated) + (_ + #f)))) + (and type + (not (core-module? module)) ;expensive call! + (upstream-input + (name (module->dist-name module)) + (downstream-name (cpan-name->downstream-name name)) + (type type))))))) + +(define (cpan-module-inputs release) + "Return the list of for dependencies of RELEASE, a +." + (define (upstream-inputupstream-input + (cpan-release-dependencies release))) + upstream-inputsexp release) "Return the 'package' s-expression for a CPAN module from the release data in RELEASE, a record." (define name (cpan-release-distribution release)) - (define (guix-name name) - (if (string-prefix? "perl-" name) - (string-downcase name) - (string-append "perl-" (string-downcase name)))) - (define version (cpan-release-version release)) (define source-url (cpan-source-url release)) - (define (convert-inputs phases) - ;; Convert phase dependencies into a list of name/variable pairs. - (match (filter-map (lambda (dependency) - (and (memq (cpan-dependency-phase dependency) - phases) - (cpan-dependency-module dependency))) - (cpan-release-dependencies release)) - ((inputs ...) - (sort - (delete-duplicates - ;; Listed dependencies may include core modules. Filter those out. - (filter-map (match-lambda - ("perl" #f) ;implicit dependency - ((? core-module?) #f) - (module - (let ((name (guix-name (module->dist-name module)))) - (list name - (list 'unquote (string->symbol name)))))) - inputs)) - (lambda args - (match args - (((a _ ...) (b _ ...)) - (stringsymbol + upstream-input-downstream-name) + inputs))))))) (let ((tarball (with-store store - (download-to-store store source-url)))) + (download-to-store store source-url))) + (inputs (cpan-module-inputs release))) `(package - (name ,(guix-name name)) + (name ,(cpan-name->downstream-name name)) (version ,version) (source (origin (method url-fetch) @@ -281,14 +298,11 @@ (define (cpan-module->sexp release) ,(bytevector->nix-base32-string (file-sha256 tarball)))))) (build-system perl-build-system) ,@(maybe-inputs 'native-inputs - ;; "runtime" may also be needed here. See - ;; https://metacpan.org/pod/CPAN::Meta::Spec#Phases, - ;; which says they are required during building. We - ;; have not yet had a need for cross-compiled perl - ;; modules, however, so we leave it out. - (convert-inputs '(configure build test))) + (filter (upstream-input-type-predicate 'native) + inputs)) ,@(maybe-inputs 'propagated-inputs - (convert-inputs '(runtime))) + (filter (upstream-input-type-predicate 'propagated) + inputs)) (home-page ,(cpan-home name)) (synopsis ,(cpan-release-abstract release)) (description fill-in-yourself!) diff --git a/tests/cpan.scm b/tests/cpan.scm index bbcd108e12..c9dd6d36de 100644 --- a/tests/cpan.scm +++ b/tests/cpan.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Eric Bavier ;;; Copyright © 2016 Alex Sassmannshausen -;;; Copyright © 2020 Ludovic Courtès +;;; Copyright © 2020, 2023 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -64,7 +64,6 @@ (define test-source (test-begin "cpan") (test-assert "cpan->guix-package" - ;; Replace network resources with sample data. (with-http-server `((200 ,test-json) (200 ,test-source) (200 "{ \"distribution\" : \"Test-Script\" }")) @@ -82,9 +81,7 @@ (define test-source ('base32 (? string? hash))))) ('build-system 'perl-build-system) - ('propagated-inputs - ('quasiquote - (("perl-test-script" ('unquote 'perl-test-script))))) + ('propagated-inputs ('list 'perl-test-script)) ('home-page "https://metacpan.org/release/Foo-Bar") ('synopsis "Fizzle Fuzz") ('description 'fill-in-yourself!) -- 2.40.1