From patchwork Sun Oct 6 23:56:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 68657 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 90A0B27BBE9; Mon, 7 Oct 2024 00:57:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 380E527BBE2 for ; Mon, 7 Oct 2024 00:57:07 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxb7S-0004Wi-KJ; Sun, 06 Oct 2024 19:56:58 -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 1sxb7Q-0004Vs-Cu for guix-patches@gnu.org; Sun, 06 Oct 2024 19:56:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxb7Q-0000fm-5J for guix-patches@gnu.org; Sun, 06 Oct 2024 19:56:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=AG9XIGjm55DRINFLg5HtsQoKWF1PtE+l4oF3VDGYA5E=; b=gMWZmVvErlB1YCKYYeMsovwIAB5+BvlCJ2LPAtz1uKmfssEdc0NXyxR+2mbndzY3e3qkIYLHv/PuoOeCnWsjTvrlhEfrKFhNqodouqCJ2auS9bZ+4lK19eeeGbc52vEgSBdGogrny57SFef9tX2EvyUPOt0rWSrgnK7kETXvY659aqNrYt1vXFXcPweM58ug5q5gWWJEB9qHU41LjSMqlnrpJmF/tfRIhUatJWyP20IRrkIC49oQrt4jwfJVOb3tO5H0Rp5rTmNabh5iA9UNmzKAzi/Ya8bAgl2gPbwVrHQUde7X/b89MG9uEk9wGWfqu31D+DL4gWX4LW3l9SwTLA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sxb7W-0001pH-Ch for guix-patches@gnu.org; Sun, 06 Oct 2024 19:57:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70227] [PATCH v2 2/2] guix: import: composer: Implement recursive package refresh. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 06 Oct 2024 23:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70227 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70227@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 70227-submit@debbugs.gnu.org id=B70227.17282589856957 (code B ref 70227); Sun, 06 Oct 2024 23:57:02 +0000 Received: (at 70227) by debbugs.gnu.org; 6 Oct 2024 23:56:25 +0000 Received: from localhost ([127.0.0.1]:42920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxb6u-0001o9-FF for submit@debbugs.gnu.org; Sun, 06 Oct 2024 19:56:24 -0400 Received: from 8.mo575.mail-out.ovh.net ([46.105.74.219]:51145) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxb6r-0001ns-PB for 70227@debbugs.gnu.org; Sun, 06 Oct 2024 19:56:23 -0400 Received: from director4.ghost.mail-out.ovh.net (unknown [10.108.9.32]) by mo575.mail-out.ovh.net (Postfix) with ESMTP id 4XMK1T4hBpz1jYY for <70227@debbugs.gnu.org>; Sun, 6 Oct 2024 23:56:13 +0000 (UTC) Received: from ghost-submission-55b549bf7b-8l4fw (unknown [10.110.101.105]) by director4.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 35F8B1FD15; Sun, 6 Oct 2024 23:56:13 +0000 (UTC) Received: from ngraves.fr ([37.59.142.99]) by ghost-submission-55b549bf7b-8l4fw with ESMTPSA id F6m+AZ0jA2eepj0AKVvujg (envelope-from ); Sun, 06 Oct 2024 23:56:13 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-99G0039c5ccc53-28ec-46b2-934f-50de139b1cd3, A12302D5D8CF0E033BA678025A323BF4FAD59D46) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 86.246.19.221 Date: Mon, 7 Oct 2024 01:56:00 +0200 Message-ID: <20241006235605.24248-2-ngraves@ngraves.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241006235605.24248-1-ngraves@ngraves.fr> References: <20241006235605.24248-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 2566207366645277410 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeftddrvddvkedgvdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepleffjeetueethfefkeffffefvddukeejkefgleduiedthfekvefhiedvhfffgeegnecukfhppeduvdejrddtrddtrddupdekiedrvdegiedrudelrddvvddupdefjedrheelrddugedvrdelleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepjedtvddvjeesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheejhedpmhhouggvpehsmhhtphhouhht DKIM-Signature: a=rsa-sha256; bh=AG9XIGjm55DRINFLg5HtsQoKWF1PtE+l4oF3VDGYA5E=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1728258973; v=1; b=h8ao/QhgNNttOovlut3Y03HvwGkVE6xBizLXbuiMOYpZIV4omStFnmMQdHPGAkMcxPpVs5r/ OUFjvIQdxBi9PsgNATKgRHsU2zkK5+VJZC1q7CFDexF4aDtoP8FfgubKYmngq17b04iUAttdfPp WYgcamcEgmcWKE8SZrxogYKmGXhY6VRON1tgqRTutm4JW6TakhcZizbrgVd29HaxE9Ef/fuzag8 SEXGqfBLUVQqA7o7MdV+SLCJCQhSADBS+20rY3cjahrUOO4nyQaC3CJ6dlbTdM7R6f2zhaexhoD i1c9yeRiH2i/JLRTWWdWUpvlrOLd27lpAaugqMQvo4EDw== 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/import/composer.scm (guix-package->composer-name): Simplify. (composer-fetch): Replace reduce by fold to correct version selection logic. (latest-release): Implement recursive package refresh. Rename to import-release. (import-release): New function, formerly known as latest-release. Change-Id: I8f629b4d1da866f5986d39b4e159f2b44af9ee49 --- guix/import/composer.scm | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/guix/import/composer.scm b/guix/import/composer.scm index 75419ca63e..abc9023be4 100644 --- a/guix/import/composer.scm +++ b/guix/import/composer.scm @@ -19,12 +19,14 @@ (define-module (guix import composer) #:use-module (ice-9 match) #:use-module (json) - #:use-module (guix hash) #:use-module (guix base32) #:use-module (guix build git) #:use-module (guix build utils) #:use-module (guix build-system) #:use-module (guix build-system composer) + #:use-module ((guix diagnostics) #:select (warning)) + #:use-module (guix hash) + #:use-module (guix i18n) #:use-module (guix import json) #:use-module (guix import utils) #:use-module ((guix licenses) #:prefix license:) @@ -113,7 +115,7 @@ (define* (composer-fetch name #:key (version #f)) (if version (assoc-ref packages version) (cdr - (reduce + (fold (lambda (new cur-max) (match new (((? valid-version? version) . tail) @@ -217,13 +219,8 @@ (define (guix-name->composer-name name) (define (guix-package->composer-name package) "Given a Composer PACKAGE built from Packagist, return the name of the package in Packagist." - (let ((upstream-name (assoc-ref - (package-properties package) - 'upstream-name)) - (name (package-name package))) - (if upstream-name - upstream-name - (guix-name->composer-name name)))) + (or (assoc-ref (package-properties package) 'upstream-name) + (guix-name->composer-name (package-name package)))) (define (string->license str) "Convert the string STR into a license object." @@ -243,8 +240,14 @@ (define (php-package? package) (eq? (package-build-system package) composer-build-system) (string-prefix? "php-" (package-name package)))) -(define* (latest-release package #:key (version #f)) - "Return an for the latest release of PACKAGE." +(define (dependency->input dependency type) + (upstream-input + (name dependency) + (downstream-name (php-package-name dependency)) + (type type))) + +(define* (import-release package #:key (version #f)) + "Return an for VERSION or the latest release of PACKAGE." (let* ((php-name (guix-package->composer-name package)) (composer-package (composer-fetch php-name #:version version))) (if composer-package @@ -252,7 +255,12 @@ (define* (latest-release package #:key (version #f)) (package (composer-package-name composer-package)) (version (composer-package-version composer-package)) (urls (list (composer-source-url - (composer-package-source composer-package))))) + (composer-package-source composer-package)))) + (inputs (append + (map (cut dependency->input <> 'regular) + (composer-package-require composer-package)) + (map (cut dependency->input <> 'native) + (composer-package-dev-require composer-package))))) (begin (warning (G_ "failed to parse ~a~%") php-name) #f)))) @@ -262,7 +270,7 @@ (define %composer-updater (name 'composer) (description "Updater for Composer packages") (pred php-package?) - (import latest-release))) + (import import-release))) (define* (composer-recursive-import package-name #:optional version) (recursive-import package-name