From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id sIm4Ib6dK2cnIwAAqHPOHw:P1 (envelope-from ) for ; Wed, 06 Nov 2024 16:47:58 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id sIm4Ib6dK2cnIwAAqHPOHw (envelope-from ) for ; Wed, 06 Nov 2024 17:47:58 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=qFy9CXU1; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=TUEJpH5x; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1730911677; 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=lhaXXl0p+MgPlfvlM39WN1YJw0D72QdgNb0MQVKS1gU=; b=k/q0USQPfprBKhO+swUOUt0O3nJJsxEYr13jPd7iYOV1CYj86s+aKxUCiBidcA8dneyNXh +/baVy/GM7pskJxGXcaYj0+api/U8FeKFAuTB5nVF8wvHxVUOIIzBjKhaobYoeNFp2evDS cNvB9chrI+RYcaC6Cffa0Dwbw24jR6ROfMRujpmFQp717wOZJ+HHgrpYgf8GVitGKQSpH0 CAg30AAEC6IJxZ/xCWmi+GgsYciuDPKzU6ggS7xpN9dhtC/d6qBRi9D82q+cobpq6iHWDL rVvxm/cqrfiuof/AGNPYF0njgTG4+YFsbkLrBH0JBQEUF5+h7yDpdClL3hDqCw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1730911677; a=rsa-sha256; cv=none; b=h+uIbVG59s4M7AwsShXGyhBG5u8q1JfAQLko+LUFpKNad14AZOiNIYWm4ifXC43KmT4lzx XMa89mUEHoL6XAH4tFTAyBIr1LQ86hy2mxiMCCW9/cgjIybQgMMfb0ipFgbY3V/989NFoH kURULWmtE2QixRNhF/HL5G8wq+MnKyMBK+DbgvBa5MnnaIQYCY24dHbX/gTYb+V3cfTOWg rYCP0y7zHgYw/y8LRv1C2uL4N8rXubYYD+j41e1rfi61F34tSwLKDLzF0MyJwMVT34CRAu laZ0dUOfc/wjB9CWNHW+IOrZs/ePjNkdOTXt+WRZBegCfz6pW3WJPN+e0mRsLw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=qFy9CXU1; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=TUEJpH5x; 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"; dmarc=pass (policy=none) header.from=gnu.org 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 A52396A82 for ; Wed, 06 Nov 2024 17:47:57 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8iAW-0006zu-V5; Wed, 06 Nov 2024 10:42:05 -0500 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 1t8iAV-0006za-7u for guix-patches@gnu.org; Wed, 06 Nov 2024 10:42:03 -0500 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 1t8iAU-0005FR-Vy for guix-patches@gnu.org; Wed, 06 Nov 2024 10:42:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=lhaXXl0p+MgPlfvlM39WN1YJw0D72QdgNb0MQVKS1gU=; b=qFy9CXU1EPwp73LSP0hFXRU4n6jBt3rrjJTxRE3PBBGgDHepdTNaCWaOoDERqmONymbUuuDG/BTm0FnlMTI965aqLC8xanxPNi5nqfsGvX6YjxeikNjCMJyGBVLCnjsGJwlJIwSsMESNDEnhZcPWwftkX5hVZ4JpcZNiiMjOo5U69pjJNt8VcZ2C6z4EBkvUDFFOI0aFgKgQgSEFrb7lQXJRURXi+XbAFRQhurJP0sLcaBAcRWiRoYip7FbkaBUtsjwbN8GpHoFxp4s+45tEyvXSqmZ0uNMq341mp53TnT1eMlERRkPNenNI1L7QFUg4nDc5hq3GJb2IN2+5YDJ2mw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t8iAU-0006LY-Jr for guix-patches@gnu.org; Wed, 06 Nov 2024 10:42:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#73833] [PATCH v2 3/5] guix: import: composer: Improve importer. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Nov 2024 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73833 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Nicolas Graves Cc: 73833@debbugs.gnu.org Received: via spool by 73833-submit@debbugs.gnu.org id=B73833.173090768324351 (code B ref 73833); Wed, 06 Nov 2024 15:42:02 +0000 Received: (at 73833) by debbugs.gnu.org; 6 Nov 2024 15:41:23 +0000 Received: from localhost ([127.0.0.1]:45135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8i9q-0006Kg-U6 for submit@debbugs.gnu.org; Wed, 06 Nov 2024 10:41:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50232) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8i9o-0006KR-9q for 73833@debbugs.gnu.org; Wed, 06 Nov 2024 10:41:21 -0500 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 1t8i9h-0004zJ-AD; Wed, 06 Nov 2024 10:41:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=lhaXXl0p+MgPlfvlM39WN1YJw0D72QdgNb0MQVKS1gU=; b=TUEJpH5xqbegHsChoHNS wkmmznVGL4Zt/7dOYQrcEKEFnvvIidws4vQjLd91xaqT4dW9hoBRJ8aY1VqQ6MhyQ+AVtidRpqH72 ElKTWNcAOZS5v0a0v0W6OqKTbqkPnZAbAv9vR2I6Vy73xFQ+ZDAau+OZwJ9i2YNAmbSZswt73PWpO pYYNMRw0XraovOp4bWDyp9JTqO2u+NAB4XlBmdT/sWjIH6INywH2/tGsMP5/gVpZR3S1nHcUm8Ee9 9lAgCr3Mbl7fcxlfDTnfQZ6Dd3ED5W1UpNcvyPek56G01MtT+gsQmMG9h5ko+w6r0VJBZf6CFGgzN Emwiea90ccVXSg==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: <20241017223308.27941-4-ngraves@ngraves.fr> (Nicolas Graves's message of "Fri, 18 Oct 2024 00:25:59 +0200") References: <20241017223308.27941-1-ngraves@ngraves.fr> <20241017223308.27941-4-ngraves@ngraves.fr> Date: Wed, 06 Nov 2024 16:41:10 +0100 Message-ID: <87r07owesp.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -3.36 X-Spam-Score: -3.36 X-Migadu-Queue-Id: A52396A82 X-Migadu-Scanner: mx13.migadu.com X-TUID: UozJVUTI0mO2 Nicolas Graves skribis: > * guix/import/composer.scm > (%composer-base-url): Move from here... > (%packagist-base-url): ...to here. > (requirements->prefixes): Add variable to read and take advantage of > version info in composer package requirements and... > (json->require): ...use it here. Rewrite of the function. > (composer-source): Add a sanitizer for composer-source-url. > (select-version): Add variable to select the most recent availble > version that is above to a given min-version and... > (composer-fetch): ...use it here. Improve the function. > (make-php-sexp, composer->guix-package): Adapt to requirements being > alists now. > (php-package?): Handle the particular phpunit case. > (dependency->input): Add min-version and max-version information. This > is currently limited to the first dependency suggested by > requirements. > (import-release): Fix git urls case. This is better but still a bit > buggy (refreshing can replace the version by a commit). > > * tests/composer.scm > (%composer-base-url): Move from here... > (%packagist-base-url): ...to here. [...] > -(define %composer-base-url > +(define %packagist-base-url > (make-parameter "https://repo.packagist.org")) It would be best to have this in a separate patch. > +(define (requirements->prefixes str) > + (let* ((processed-str (string-replace-substring str " || " "|")) > + (prefix-strs (string-split processed-str #\|))) > + (filter-map (match-lambda > + ;; SemVer: ^ indicates major+minor match, not a whole = match. > + ((? (cut string-prefix? "^" <>) prefix) > + (let ((pfx (string-drop prefix 1))) > + (if (eq? 2 (string-count prefix #\.)) > + (string-take pfx (string-rindex pfx #\.)) > + pfx))) > + ((? (cut string-suffix? ".*" <>) prefix) > + (string-drop-right prefix 2)) > + (_ #f)) > + prefix-strs))) Please add a docstring and following the coding style for identifiers. > (define-json-mapping make-composer-source composer-sou= rce? > json->composer-source > (type composer-source-type) > - (url composer-source-url) > + (url composer-source-url "url" > + (lambda (uri) > + (if (string-suffix? ".git" uri) > + (string-drop-right uri 4) > + uri))) Is it the right place to change things? I would keep identical to the information available at packagist.org, and post-process the URL only where it=E2=80=99s needed. > +(define* (select-version packages #:key (min-version #f)) > + "Select the most recent available version in the PACKAGES list > +that is above or equal to MIN-VERSION. MIN-VERSION can be incomplete > +(e.g. version-major only)." > + (let* ((points (and min-version (string-count min-version #\.))) > + (min-prefix (and min-version > + (match points > + ((or 0 1) (fix-version min-version)) > + (_ #f))))) > + (cdr > + (fold > + (lambda (new cur-max) > + (match new > + (((? valid-version? version) . tail) > + (let ((valid-version (fix-version version))) > + (if (and (version>? valid-version (fix-version (car cur-max= ))) > + (or (not min-prefix) > + (version-prefix? min-prefix valid-version))) > + (cons* version tail) > + cur-max))) > + (_ cur-max))) No car/cdr please, especially since it=E2=80=99s already using =E2=80=98mat= ch=E2=80=99. > + (let* ((version (fix-version (caadr dependency))) > + (points (and version (string-count version #\.))) > + (max "99")) > + (upstream-input > + (name (car dependency)) > + (downstream-name (php-package-name (car dependency))) > + (type type) > + (min-version (match points > + (0 (string-append version ".0.0")) > + (1 (string-append version ".0")) > + (2 version) > + (_ 'any))) > + (max-version (match points > + (0 (string-append version "." max "." max)) > + (1 (string-append version "." max)) > + (2 version) > + (_ 'any)))))) This thing with =E2=80=98points=E2=80=99 is kinda weird: =E2=80=98version>?= =E2=80=99 works fine even when there=E2=80=99s a different number of points in the arguments. > (define* (import-release package #:key (version #f)) > "Return an for VERSION or the latest release of PACK= AGE." > (let* ((php-name (guix-package->composer-name package)) > - (composer-package (composer-fetch php-name #:version version))) > + (composer-package (composer-fetch php-name #:version version)) > + (new-version new-version-tag > + (latest-git-tag-version package #:version version)= )) > (if composer-package > (upstream-source > (package (composer-package-name composer-package)) > (version (composer-package-version composer-package)) > - (urls (list (composer-source-url > - (composer-package-source composer-package)))) > + (urls > + (let ((source (composer-package-source composer-package))) > + (if (string=3D? (composer-source-type source) "git") > + (git-reference > + (url (composer-source-url source)) > + (commit (or new-version-tag > + (composer-source-reference source)))) > + (list (composer-source-url source))))) This seems to be an unrelated change (supporting fetching source from Git). Could it be separated out? Could you add tests for the new functionality? It=E2=80=99s important to have good test coverage to help maintain importer= s in the long run. Thanks, Ludo=E2=80=99.