From patchwork Sun Mar 23 07:23:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40703 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 D7BAD27BBE2; Sun, 23 Mar 2025 07:26:43 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 4EAE127BBEA for ; Sun, 23 Mar 2025 07:26:43 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFih-0008Vo-BI; Sun, 23 Mar 2025 03:26:07 -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 1twFie-0008Qw-2R for guix-patches@gnu.org; Sun, 23 Mar 2025 03:26:04 -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 1twFid-0007Pm-Pa for guix-patches@gnu.org; Sun, 23 Mar 2025 03:26:03 -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=rOqXENQGtdo4LW3H43hqvXpLA4xlwXAqGFQMFIXQIr8=; b=FUIo0WNcWGsmVO9si6DoIkgfRRdHxYpSULfHCqCAxA5y1+hOjcsCJcxUgzIwl79XEDcQNFqTUppJdOaarpfCRvp13fX0pAVpt9I6Jav8jwO0bErW1JnbxOXpFp7RwC33ki968DMTiFneOYuR4RTI7yS5EgepyKupfjfLf7hrLbfv4DLQVTqJxxb5xwa9blE6OI6+sTBqQP5eDvICUncPayU92ESjk1psPSSb8RmjPG7li3yEcPlAD0ezJ344+rQFaLeouKRrxpbc02gZ9F+Z8T6JfSdL7CkNSSkMq77UHZEZtgY1gqu+W4iX4n2TzLIOjOLpyQjHvbzvC64zbWfDcQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFib-0003eG-TQ; Sun, 23 Mar 2025 03:26:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 01/17] build/cargo: Pass =?utf-8?b?4oCYLS1vZmZsaW5l4oCZ?= to cargo. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, efraim@flashner.co.il, maxim.cournoyer@gmail.com, divya@subvertising.org, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Hilton Chain , Efraim Flashner , Maxim Cournoyer , Divya Ranjan Pattanaik , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Efraim Flashner , Maxim Cournoyer , Divya Ranjan Pattanaik , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271471313440 (code B ref 77093); Sun, 23 Mar 2025 07:26:01 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:13 +0000 Received: from localhost ([127.0.0.1]:47255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFho-0003Tr-Lx for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:25:13 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:36306) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFhk-0003RU-GJ for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:25:10 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714706; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=rOqXENQGtdo4LW3H43hqvXpLA4xlwXAqGFQMFIXQIr8=; b=BJDq0GyayHXvKid3un79D2brusr79NzcSD+ltIxZ65xCNlt47U/9ZT09k5xlv8JVyC9qzO 8UxFQz5SZ/hxB4vGMQWeqpO5U1r91BcR66zK3bztnKXdy5peOuTnDZx7IYWlGgOcnZOQ51 5dWE0GKxZB5l4yIn65BoFUgynkUi6I0fj2fOUTCxbA0tRn8CqI65CwNq653D66tyImKHTo zhkPajNNdtUzN8ecvCAs+QciIMSLFa94htcUP17RZqId0o1FuYlrCciSvdUCGhAwEiwQPs DxL1aEO5HtCInIbtT6ONv6sRQ1UUeFYH09FAZh2wcMJuzscpbJeq03xe9zOU0g== Date: Sun, 23 Mar 2025 15:23:05 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This will make error messages more helpful. * guix/build/cargo-build-system.scm (build,check,package,install): Pass ‘--offline’ to cargo. Change-Id: Ic95f603b793319f99c9c1fbce43f773bfc8126c0 --- guix/build/cargo-build-system.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 5ef6b23abd..41f54f42b7 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -246,7 +246,7 @@ (define* (build #:key "Build a given Cargo package." (or skip-build? (apply invoke - `("cargo" "build" + `("cargo" "build" "--offline" ,@(if parallel-build? (list "-j" (number->string (parallel-job-count))) (list "-j" "1")) @@ -264,7 +264,7 @@ (define* (check #:key "Run tests for a given Cargo package." (when tests? (apply invoke - `("cargo" "test" + `("cargo" "test" "--offline" ,@(if parallel-build? (list "-j" (number->string (parallel-job-count))) (list "-j" "1")) @@ -303,7 +303,7 @@ (define* (package #:key ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source (when (file-exists? "Cargo.toml.orig") (delete-file "Cargo.toml.orig")) - (apply invoke `("cargo" "package" ,@cargo-package-flags)) + (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags)) ;; Then unpack the crate, reset the timestamp of all contained files, and ;; repack them. This is necessary to ensure that they are reproducible. @@ -356,7 +356,8 @@ (define* (install #:key ;; otherwise cargo will raise an error. (or skip-build? (not (has-executable-target?)) - (invoke "cargo" "install" "--no-track" "--path" "." "--root" out + (invoke "cargo" "install" "--offline" "--no-track" + "--path" "." "--root" out "--features" (string-join features))) (when install-source? From patchwork Sun Mar 23 07:23:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40700 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 D700D27BBE9; Sun, 23 Mar 2025 07:26:24 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED 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 BC73727BBE2 for ; Sun, 23 Mar 2025 07:26:22 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFie-0008R9-FT; Sun, 23 Mar 2025 03:26:04 -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 1twFid-0008Ql-KS for guix-patches@gnu.org; Sun, 23 Mar 2025 03:26:03 -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 1twFid-0007Pn-3L for guix-patches@gnu.org; Sun, 23 Mar 2025 03:26:03 -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=4dyk8EhTBpU4zaPXLxseyoCZCVCVNbObU/8XSgx1X8g=; b=XTX0pv35UkHnYFu9J4svHFLZIQXvqwmSOx46X/iFCRm6X+IQcWcUNmx9u08dno/fzDORxoE1o9+JWueQmJ/meQSS/2HEQcGolCNPNXH5YOhRbzNMBgjl4Esg694QQKJySbToaD1K3fbPAd77syZjKwJ506m85re6asX7X0to4dRjSu9CvSD2ylN/qIz7KP6a56FQp5kC5SbWtm3sjLl3IsiS7bC0ciJrnuE+CSKc7aY26FaHWTxdxfjbPxNeeDqvDjeuZeqGzyO7jBVKDrNKhRwhSGxFjqPpGmRpBk70oomAnz30XyYYwaGbK1phNabR2cer9A5IQk16ijgDw+icsQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFic-0003eP-Bi; Sun, 23 Mar 2025 03:26:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 02/17] build/cargo: Print out all non-empty binary files. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, efraim@flashner.co.il, maxim.cournoyer@gmail.com, divya@subvertising.org, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Hilton Chain , Efraim Flashner , Maxim Cournoyer , Divya Ranjan Pattanaik , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Efraim Flashner , Maxim Cournoyer , Divya Ranjan Pattanaik , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271472413697 (code B ref 77093); Sun, 23 Mar 2025 07:26:02 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:24 +0000 Received: from localhost ([127.0.0.1]:47263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFhx-0003YQ-BY for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:25:24 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:39440) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFho-0003TU-J3 for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:25:14 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714711; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4dyk8EhTBpU4zaPXLxseyoCZCVCVNbObU/8XSgx1X8g=; b=KsoGJCp/ovpUDNazgqtT7VNkuTjlFZQJEaqWW7o8F7ya2sFO+9f7XebQqbiF5gxauw2t0y rW25hdHAG71zIUR7AyEgGsmAI842bfDNnX8Dgs9E+znkr6m2Loi0lSN3UPjK7DghFKrA8r cd44cPrmSIyCFBPxLi6Mhz2nv/nFWGDaSG4+pTL9k46VWAr4d15bAxalCJbJDX+s9K0sx7 CuibCXyNeX/4rzWTSiizgLzJ4foa2PzjVVQDDQmvv33BGpDsFX/EXDee8731fMRPpxhzkF WlT9Ew6VphQiUysSSH3428KUPnMoQ4igSoh0U+DAuGRpHS3Y14BFqrwSga1e8A== Date: Sun, 23 Mar 2025 15:23:06 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/build/cargo-build-system.scm (%standard-phases): Move 'unpack-rust-crates after 'unpack. Move 'check-for-pregenerated-files after 'configure. (check-for-pregenerated-files): Only check non-empty files. Print out binary files. Run in parallel. Don't fail to keep compatibility for phase order change. Change-Id: I0a332fe843e97687324bd908fa111422a63e475d --- guix/build/cargo-build-system.scm | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 41f54f42b7..58238992b8 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -29,9 +29,11 @@ (define-module (guix build cargo-build-system) #:use-module ((guix build utils) #:hide (delete)) #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) + #:use-module (ice-9 regex) #:use-module (ice-9 ftw) #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (ice-9 threads) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (%standard-phases @@ -111,12 +113,29 @@ (define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys) (define (rust-package? name) (string-prefix? "rust-" name)) -(define* (check-for-pregenerated-files #:rest _) +(define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys) "Check the source code for files which are known to generally be bundled libraries or executables." - (let ((pregenerated-files (find-files "." "\\.(a|dll|dylib|exe|lib)$"))) - (when (not (null-list? pregenerated-files)) - (error "Possible pre-generated files found:" pregenerated-files)))) + (format #t "Searching for binary files...~%") + (let ((known-pattern (make-regexp "\\.(a|dll|dylib|exe|lib)$")) + (empty-file? + (lambda (filename) + (call-with-ascii-input-file filename + (lambda (p) + (eqv? #\0 (read-char p))))))) + (n-par-for-each + (if parallel-build? + (parallel-job-count) + 1) + (lambda (file) + (unless (empty-file? file) + ;; Print out binary files. + (false-if-exception (invoke "grep" "-IL" "." file)) + ;; Warn about known pre-generated files. + ;; Not failing here for compatibility with existing packages. + (when (regexp-exec known-pattern file) + (format #t "error: Possible pre-generated file found: ~a~%" file)))) + (find-files ".")))) (define* (configure #:key inputs target system @@ -380,8 +399,8 @@ (define %standard-phases (replace 'check check) (replace 'install install) (add-after 'build 'package package) - (add-after 'unpack 'check-for-pregenerated-files check-for-pregenerated-files) - (add-after 'check-for-pregenerated-files 'unpack-rust-crates unpack-rust-crates) + (add-after 'unpack 'unpack-rust-crates unpack-rust-crates) + (add-after 'configure 'check-for-pregenerated-files check-for-pregenerated-files) (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums patch-cargo-checksums))) (define* (cargo-build #:key inputs (phases %standard-phases) From patchwork Sun Mar 23 07:23:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40702 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 6D3D327BBEC; Sun, 23 Mar 2025 07:26:43 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 C3AB727BBE2 for ; Sun, 23 Mar 2025 07:26:42 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFin-00006W-BM; Sun, 23 Mar 2025 03:26:13 -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 1twFik-000062-Sp for guix-patches@gnu.org; Sun, 23 Mar 2025 03:26:10 -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 1twFik-0007Sf-F6; Sun, 23 Mar 2025 03:26:10 -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=TsqMeoEPxrWTz5BuoP/adKMehqeUtbJe5HaI+Gmux8I=; b=D7sfMDJkEZXmrqV6qgYNiC4ENhbhHDC4X6XfWtkaIAAWLhQokO3bNQYFgU5sjqPuI2SFAT/Sbm7BB+tRssGdbUaPAjg2QQCKvRsCanz5xtvXnCEk+sfY+GX0Rscjmpn9PHnPLOBinqlnFdni2KENH0rFz6avADFVGZyUMBWiMwU8dJbWtGCQ4cLmJHGXoC6L4Gx9JJ4YHM37FlariWkkMav6aS4lFsjCfaYBi05fD6bykmuFmS83XqvfDs/2e8Ioj+GXY8onEI47H0yQms8/0jxVUkYdteHoioLEwQmxc/+OXvZ0UFmZJZXtLvGAihKXylwFJWvFxV3AAqC5C1k6eg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFid-0003ei-99; Sun, 23 Mar 2025 03:26:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 03/17] build-system: cargo: Support packaging Cargo workspace. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, efraim@flashner.co.il, maxim.cournoyer@gmail.com, divya@subvertising.org, ludo@gnu.org, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:26:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Hilton Chain , Efraim Flashner , Maxim Cournoyer , Divya Ranjan Pattanaik , Ludovic =?utf-8?q?Court?= =?utf-8?q?=C3=A8s?= , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Efraim Flashner , Maxim Cournoyer , Divya Ranjan Pattanaik , Ludovic =?utf-8?q?Court?= =?utf-8?q?=C3=A8s?= , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271473413730 (code B ref 77093); Sun, 23 Mar 2025 07:26:03 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:34 +0000 Received: from localhost ([127.0.0.1]:47267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFi9-0003ZL-4I for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:25:33 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:49662) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFhr-0003W7-Pl for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:25:16 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TsqMeoEPxrWTz5BuoP/adKMehqeUtbJe5HaI+Gmux8I=; b=aeDw6nyUPrFrZPrpctZb53pMuth9AITIhrBcF0naovBEX0r4lkrqptEUAx/FEhnhRgZHJp IQb8s8poY/PghGFCftVoxLftaJu16dJmc+elkCd4UsK1jA0pUKz0tzsXRKDhtqEHGGpwZR PbKSEsSc07Btmsy2Zc2CX/fqfgJy6U9+hW+pujGvrLTihIaSaUgEawXdTis0q6HUk/oDdh ISdTolO6+KCRFGRxXFykHu9BuAi1BrgduklLAzBvExWo5DfB13PQreywYy0ygxSnIczVtl bWzfQtZ67yOT/iWJj/tomq4AdXXceHxLMMdg13+o92HUeECvDNpUk4a9mhW5Jg== Date: Sun, 23 Mar 2025 15:23:07 +0800 Message-ID: <9118bb6e582587547a1d0530d9b4db917cadca6a.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/build-system/cargo.scm (cargo-build,cargo-cross-build) [#:cargo-package-crates]: New argument. * guix/build/cargo-build-system.scm (package): Use it. * doc/guix.texi (Build Systems)[cargo-build-system]: Document it. Change-Id: I45ccd95e90827d47127015cb0bda2d41f792335b --- doc/guix.texi | 7 +++++++ guix/build-system/cargo.scm | 4 ++++ guix/build/cargo-build-system.scm | 21 +++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0ca109a214..0089f9e60f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9363,6 +9363,13 @@ Build Systems the binaries defined by the crate. Unless @code{install-source? #f} is defined it will also install a source crate repository of itself and unpacked sources, to ease in future hacking on rust packages. + +This build system supports cargo workspaces. Parameter +@code{#:cargo-package-crates} (default: @code{''()}) allows specifying names of +library crates to package in the @code{package} phase. Specified crates are +packaged from left to right, in case there's dependency among them. For +example, specifying @code{''("pcre2-sys" "pcre2")} will package +@code{"pcre2-sys"} first and then @code{"pcre2"}. @end defvar @defvar chicken-build-system diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 452f7f78d0..4f6d46e70c 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -94,6 +94,7 @@ (define* (cargo-build name inputs (vendor-dir "guix-vendor") (cargo-build-flags ''("--release")) (cargo-test-flags ''()) + (cargo-package-crates ''()) (cargo-package-flags ''("--no-metadata" "--no-verify")) (features ''()) (skip-build? #f) @@ -122,6 +123,7 @@ (define* (cargo-build name inputs #:vendor-dir #$vendor-dir #:cargo-build-flags #$(sexp->gexp cargo-build-flags) #:cargo-test-flags #$(sexp->gexp cargo-test-flags) + #:cargo-package-crates #$(sexp->gexp cargo-package-crates) #:cargo-package-flags #$(sexp->gexp cargo-package-flags) #:cargo-target #$(cargo-triplet system) #:features #$(sexp->gexp features) @@ -154,6 +156,7 @@ (define* (cargo-cross-build name (vendor-dir "guix-vendor") (cargo-build-flags ''("--release")) (cargo-test-flags ''()) + (cargo-package-crates ''()) (cargo-package-flags ''("--no-metadata" "--no-verify")) (cargo-target (cargo-triplet (or target system))) (features ''()) @@ -185,6 +188,7 @@ (define* (cargo-cross-build name #:vendor-dir #$vendor-dir #:cargo-build-flags #$(sexp->gexp cargo-build-flags) #:cargo-test-flags #$(sexp->gexp cargo-test-flags) + #:cargo-package-crates #$(sexp->gexp cargo-package-crates) #:cargo-package-flags #$(sexp->gexp cargo-package-flags) #:cargo-target #$(cargo-triplet (or target system)) #:features #$(sexp->gexp features) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 58238992b8..51a45b4eab 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -300,11 +300,16 @@ (define* (package #:key source skip-build? install-source? + (cargo-package-crates '()) (cargo-package-flags '("--no-metadata" "--no-verify")) + (vendor-dir "guix-vendor") #:allow-other-keys) "Run 'cargo-package' for a given Cargo package." (if install-source? - (if skip-build? + ;; NOTE: Cargo workspace packaging support: + ;; #:install-source? #t + #:cargo-package-crates. + (if (and (null? cargo-package-crates) + skip-build?) (begin (install-file source "target/package") (with-directory-excursion "target/package" @@ -322,7 +327,19 @@ (define* (package #:key ;;error: invalid inclusion of reserved file name Cargo.toml.orig in package source (when (file-exists? "Cargo.toml.orig") (delete-file "Cargo.toml.orig")) - (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags)) + + (if (null? cargo-package-crates) + (apply invoke `("cargo" "package" "--offline" ,@cargo-package-flags)) + (for-each + (lambda (pkg) + (apply invoke "cargo" "package" "--offline" "--package" pkg + cargo-package-flags) + (for-each + (lambda (crate) + (invoke "tar" "xzf" crate "-C" vendor-dir)) + (find-files "target/package" "\\.crate$")) + (patch-cargo-checksums #:vendor-dir vendor-dir)) + cargo-package-crates)) ;; Then unpack the crate, reset the timestamp of all contained files, and ;; repack them. This is necessary to ensure that they are reproducible. From patchwork Sun Mar 23 07:23:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40704 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 65BD527BBEA; Sun, 23 Mar 2025 07:26:45 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 EF3CB27BBE2 for ; Sun, 23 Mar 2025 07:26:44 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFih-0008WR-OT; Sun, 23 Mar 2025 03:26:07 -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 1twFie-0008R1-9X for guix-patches@gnu.org; Sun, 23 Mar 2025 03:26:04 -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 1twFid-0007Q9-Vv; Sun, 23 Mar 2025 03:26:04 -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=23lhd6o6dULzhofljL9UaScmfBPSTipNmygrpe7uEkk=; b=q4qaqGgon2UueFehDlndLNYpkhBEI13CkgQUglA4/ZdTiZzLq2QmJY6SLTMv2kkMTEw739JySCivH2Nol0uOm/KMz1SJFO9EgUWt88tfs9jsyxttmv6243xHGl8WTBI19AheLlwrm3VgXUEASuVtuWlt1SSPrJaZ9enQg5Rj2LWt4ShGbjt1sVHp/oY+8IUpwswBVvmuQP1zi89CYIuDu+3Y+8jc3lU1c+tglWtBDxOFURjP1du3P1ZhNuJI2vxqI+BLCWSIz6FObruUBPhNYcHEUNDVyvVDOxba9EKsgLueDz4xy2f8c2oWuu0usUjWpmGPafhUU0z6w061FSHytw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFid-0003er-Q8; Sun, 23 Mar 2025 03:26:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 04/17] build-system: cargo: Support installing Cargo workspace. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, efraim@flashner.co.il, maxim.cournoyer@gmail.com, divya@subvertising.org, ludo@gnu.org, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:26:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Hilton Chain , Efraim Flashner , Maxim Cournoyer , Divya Ranjan Pattanaik , Ludovic =?utf-8?q?Court?= =?utf-8?q?=C3=A8s?= , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Efraim Flashner , Maxim Cournoyer , Divya Ranjan Pattanaik , Ludovic =?utf-8?q?Court?= =?utf-8?q?=C3=A8s?= , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271473513745 (code B ref 77093); Sun, 23 Mar 2025 07:26:03 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:25:35 +0000 Received: from localhost ([127.0.0.1]:47269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFi9-0003ZV-TR for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:25:34 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:48142) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFhv-0003XK-5C for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:25:20 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=23lhd6o6dULzhofljL9UaScmfBPSTipNmygrpe7uEkk=; b=Bh5axcsuvPPBy6yGuBZly/qOTqxcL6lWMdcwhEAUD1ZHyWxpKKX5zc1yk42d4TiTMMQfZt Few+0Zl/0qYq6C/xtBjdZ22Yhgf/5rcqtMCmulH0TrNrV3TQ92G9lti2AVK+Ggy5O5U53F TwemPSZFp8vHMZuVoNPQV9DpBqwUM7KC0hyOoGntM1ibG68wy1zPvZwqPjr6B1y37vgcc2 dSY7riBHB7Vzekw/rGYKWMpKyS0zIjZ6pSD5s9p/j6OFOS9KswkK6m32smMH3j9bFNYrlP TQ4IPT5WlRdv7zAymA937JSqCqFG1DvIynRUEmJRQX00Fx/Y2SbV78Nbe9lzCw== Date: Sun, 23 Mar 2025 15:23:08 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches *guix/build-system/cargo.scm (cargo-build,cargo-cross-build) [#:cargo-install-paths]: New argument. * guix/build/cargo-build-system.scm (install): Use it. * doc/guix.texi (Build Systems)[cargo-build-system]: Document it. Change-Id: I74ed1972a5716da05afeac8edb2b0e4b6834bf40 --- doc/guix.texi | 5 ++++- guix/build-system/cargo.scm | 4 ++++ guix/build/cargo-build-system.scm | 17 +++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0089f9e60f..7fa986b4b9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9369,7 +9369,10 @@ Build Systems library crates to package in the @code{package} phase. Specified crates are packaged from left to right, in case there's dependency among them. For example, specifying @code{''("pcre2-sys" "pcre2")} will package -@code{"pcre2-sys"} first and then @code{"pcre2"}. +@code{"pcre2-sys"} first and then @code{"pcre2"}. Parameter +@code{#:cargo-install-paths} (default: @code{''()}) allows specifying paths of +binary crates to install in the @code{install} phase, @code{''("crates/atuin")}, +for example. @end defvar @defvar chicken-build-system diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 4f6d46e70c..4486c706a1 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -96,6 +96,7 @@ (define* (cargo-build name inputs (cargo-test-flags ''()) (cargo-package-crates ''()) (cargo-package-flags ''("--no-metadata" "--no-verify")) + (cargo-install-paths ''()) (features ''()) (skip-build? #f) (parallel-build? #t) @@ -125,6 +126,7 @@ (define* (cargo-build name inputs #:cargo-test-flags #$(sexp->gexp cargo-test-flags) #:cargo-package-crates #$(sexp->gexp cargo-package-crates) #:cargo-package-flags #$(sexp->gexp cargo-package-flags) + #:cargo-install-paths #$(sexp->gexp cargo-install-paths) #:cargo-target #$(cargo-triplet system) #:features #$(sexp->gexp features) #:skip-build? #$skip-build? @@ -158,6 +160,7 @@ (define* (cargo-cross-build name (cargo-test-flags ''()) (cargo-package-crates ''()) (cargo-package-flags ''("--no-metadata" "--no-verify")) + (cargo-install-paths ''()) (cargo-target (cargo-triplet (or target system))) (features ''()) (skip-build? #f) @@ -190,6 +193,7 @@ (define* (cargo-cross-build name #:cargo-test-flags #$(sexp->gexp cargo-test-flags) #:cargo-package-crates #$(sexp->gexp cargo-package-crates) #:cargo-package-flags #$(sexp->gexp cargo-package-flags) + #:cargo-install-paths #$(sexp->gexp cargo-install-paths) #:cargo-target #$(cargo-triplet (or target system)) #:features #$(sexp->gexp features) #:skip-build? #$skip-build? diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 51a45b4eab..67311fc850 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -377,6 +377,7 @@ (define* (install #:key skip-build? install-source? features + (cargo-install-paths '()) #:allow-other-keys) "Install a given Cargo package." (let* ((out (assoc-ref outputs "out")) @@ -391,10 +392,18 @@ (define* (install #:key ;; Only install crates which include binary targets, ;; otherwise cargo will raise an error. (or skip-build? - (not (has-executable-target?)) - (invoke "cargo" "install" "--offline" "--no-track" - "--path" "." "--root" out - "--features" (string-join features))) + ;; NOTE: Cargo workspace installation support: + ;; #:skip-build? #f + #:cargo-install-paths. + (and (null? cargo-install-paths) + (not (has-executable-target?))) + (for-each + (lambda (path) + (invoke "cargo" "install" "--offline" "--no-track" + "--path" path "--root" out + "--features" (string-join features))) + (if (null? cargo-install-paths) + '(".") + cargo-install-paths))) (when install-source? ;; Install crate tarballs and unpacked sources for later use. From patchwork Sun Mar 23 07:28:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40705 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 A7C9B27BBE9; Sun, 23 Mar 2025 07:30:28 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 7C1E027BBE2 for ; Sun, 23 Mar 2025 07:30:28 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFmh-0001LV-Rz; Sun, 23 Mar 2025 03:30:15 -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 1twFme-0001Jf-Fr for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:13 -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 1twFme-0008Td-6J for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:12 -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=7cHC5JaE/yoaTiqjZnZGmW/1emw8eox9nVLO4naCJAM=; b=THSSt1HI/F41eWRDxZZK6XFhUH3KBJ58MqUjS49qbp+9BSGcGGVPhV5Xbn9Q6eZVNOjTjpZYUAeexL8l576zqLiOqA4uOYDrzfrtzNyXkizi53R5qhN3PKVJiANbZRAkWnts/pVmRe3XWnVCnnXxzTv1bkngrN3GLEwaiXd0knbmUnabUdyW6LV1D5gHDT4bh0+cW0mgkFbj/u+slfXXkDG9sgUVj1RX3W/9BnAnOhOFrlSq/67PM0nq+oFvaGKXo2oQmoiUvff2i1cwrjOLp3AVjwDHwtFWR92iVNU6S78R8luFGqaPNNoZParlEE+E4aZb970YIvGUUP4dJ91luw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmd-0004LR-PL; Sun, 23 Mar 2025 03:30:11 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 05/17] build/cargo: Set default value of arguments for build phases. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:11 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271499716334 (code B ref 77093); Sun, 23 Mar 2025 07:30:11 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:57 +0000 Received: from localhost ([127.0.0.1]:47337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmO-0004FG-Ss for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:57 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:34822) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFlv-0004AT-Io for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:29 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714966; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7cHC5JaE/yoaTiqjZnZGmW/1emw8eox9nVLO4naCJAM=; b=ApCgR0mgdF8PWkSEali2i8PUKxS6TdtQD1ZPC256GCtum00Krl1iimHrv3kOgmTQEt2aIk 8S0MNrVJLovo2BV1YSqHrDi16WmYkrkTbRbf8Ul/WJY3pCaSk3WeUEq7JvnYk6W2xAIwMr fX5r6ecvVKlslSmStfl5kD1WyMfNw/ItzAqAGiuxHmWiYM2q+rzeffVJlhAE/VjGryXmpz iFyMZ9kdf5v/Jc3/4ZgcNW1VKP9qXTisHVDXN0xCJGedr2wt0xmyYw5SyOukE1GCZmLzuX TgjTK3p9Hh7U7mbAv3IEIB2QmkQ3qsLN0IXPGyBxyVVfWfhw/+aMyviiF9XYgQ== Date: Sun, 23 Mar 2025 15:28:27 +0800 Message-ID: <6bb7dff08560eab1521f718dde1ee870b41cd323.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This makes it easier to use these phases in other bulid systems. * guix/build/cargo-build-system.scm (unpack-rust-crates,configure,build,package) (install): Set default value of arguments. Change-Id: I1dde1b063d8eee57967903abd2fce94574211a0a --- guix/build/cargo-build-system.scm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 67311fc850..15eda8396c 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -76,7 +76,8 @@ (define (crate-src? path) " | cut -d/ -f2" " | grep -q '^Cargo.toml$'"))))) -(define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys) +(define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor") + #:allow-other-keys) (define (inputs->rust-inputs inputs) "Filter using the label part from INPUTS." (filter (lambda (input) @@ -139,7 +140,7 @@ (define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys) (define* (configure #:key inputs target system - cargo-target + (cargo-target #f) (vendor-dir "guix-vendor") #:allow-other-keys) "Vendor Cargo.toml dependencies as guix inputs." @@ -258,7 +259,7 @@ (define* (patch-cargo-checksums #:key (define* (build #:key parallel-build? - skip-build? + (skip-build? #f) (features '()) (cargo-build-flags '("--release")) #:allow-other-keys) @@ -298,8 +299,8 @@ (define* (check #:key (define* (package #:key source - skip-build? - install-source? + (skip-build? #f) + (install-source? #t) (cargo-package-crates '()) (cargo-package-flags '("--no-metadata" "--no-verify")) (vendor-dir "guix-vendor") @@ -374,9 +375,9 @@ (define* (package #:key (define* (install #:key inputs outputs - skip-build? - install-source? - features + (skip-build? #f) + (install-source? #t) + (features '()) (cargo-install-paths '()) #:allow-other-keys) "Install a given Cargo package." From patchwork Sun Mar 23 07:28:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40711 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 6032327BBEA; Sun, 23 Mar 2025 07:31:00 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 2B06D27BBE2 for ; Sun, 23 Mar 2025 07:31:00 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFmj-0001MG-6U; Sun, 23 Mar 2025 03:30:17 -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 1twFmh-0001Kl-BS for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:15 -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 1twFmh-0008UL-1W for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:15 -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=tG2XNZs5GS0JQumnYtWu0WyDueTXJUyWLXF2tuIKzIg=; b=Qk/63gOSv4sn9TLg2N+BTIUbnkcXR27Oo3hDxxwSJk2gzmIHUqfdMkEAsRyt+xT77XHSUST/7xrOphN2WE4oW2pLtkRvoHs73KLGkjmBUERtlDfn4SVm1NRPCLrqAsWk8QGyCSizUMs10Z1uVNiofIw0ykMWCoHtZ+7MgVm/PmKXrbgKva22nr9Q6bY/7hKsVscsayYKaUBdY81jN2h7kZ1qnVBMnyIq0AALczo0eQl8qpcQPEswMryoLqD4xJqnSBvsnSS6kSfVsdiggpZrU5075ZeF4vPm930f4RfJ1NOmYWuRjltIE7aS1HI4UAjtEmC2KO9Sz29S1B+GcxdZ6g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmf-0004Mi-Tq; Sun, 23 Mar 2025 03:30:13 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 06/17] build/cargo: Don't try to unpack sanity-check.py. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:13 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271499816343 (code B ref 77093); Sun, 23 Mar 2025 07:30:13 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:58 +0000 Received: from localhost ([127.0.0.1]:47339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmP-0004FP-Cu for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:57 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54426) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFlx-0004Ap-Aj for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:30 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tG2XNZs5GS0JQumnYtWu0WyDueTXJUyWLXF2tuIKzIg=; b=hGVxaFxcjYmWBUdoiB1zoGd+Y1gkELx9r8UYHrsvFIA4yhXLp7+Vb0Dkyw9nmCMpjdoa2b WKPub2Y8KInZU6wSe6MlL4ZCwcEcbSAoV2AKOiyFxaoyFaXZUQ2OewXyPJWapvNm/WbdSq dyLavvvfRtvVntve+YYbkzOdoEXq0fy/Ja33KPPXGzLSQPAlBR2mB2GXxUBaqDMARCrecf 3awbBdj0B5h/2cpfIidenxJji6aGf8KWgn0T60RuspdEtlZw2uu5ZjYhGHs1qwiebohf0e eD0YXCoGrhvCbj5ch7mQO+yBlXtgQJCmcDCH19BXj2FjEfzRhSVPwYKqvoRnJA== Date: Sun, 23 Mar 2025 15:28:28 +0800 Message-ID: <66d29a621b80ab17ec6125e9877e365dce174ce0.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: Efraim Flashner * guix/build/cargo-build-system.scm (crate-src?): Also don't try to check python scripts for Cargo.toml. Change-Id: I001a89b83d2e472706b1263007be45d1153c140f --- guix/build/cargo-build-system.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 15eda8396c..f2a7323748 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -64,6 +64,7 @@ (define (crate-src? path) "Check if PATH refers to a crate source, namely a gzipped tarball with a Cargo.toml file present at its root." (and (not (directory-exists? path)) ; not a tarball + (not (string-suffix? "py" path)) ; sanity-check.py ;; First we print out all file names within the tarball to see if it ;; looks like the source of a crate. However, the tarball will include ;; an extra path component which we would like to ignore (since we're From patchwork Sun Mar 23 07:28:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40707 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 A468227BBEA; Sun, 23 Mar 2025 07:30:38 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 14EFC27BBE2 for ; Sun, 23 Mar 2025 07:30:38 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFml-0001NX-N2; Sun, 23 Mar 2025 03:30:19 -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 1twFmj-0001Mp-QN for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:18 -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 1twFmj-0008Ux-Em for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:17 -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=h3Vgf4tjTqkYBWyagpTXL5ZNIhW4KaLaVkwkrFdGnws=; b=Zo3NispkFLOe2dzgr0kPTWd0+9m+EQSjO6RR9TpH4uDQkGQT6KAqLXH5PcyXQ3Ur8yqpvOoXBMojG3ZlWPMZQZQRf6EeN9qVVSgpmVTk1xjbDKW6E8a/9ba8LL7aabavIxERN9pDZX76mMzn7VVFkp4h/nhtcwIdUcgb8ayq0Xo1LbHqPIzWnBfaI45/Qimwtrwt/wo4ifimlU8UCVeLbVjHbtVJGZ6SDaI45tTrB4PJYDCm3ljv8VyWzAsxuY5XHpx7oWtx71LQh/FBB91O3DXxfBZnxQoM4V2QNKed1RTaJqR4T4R9TrBQ2Gmw90mpB+4SvD0FfWePfoZ0kpPurg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmh-0004OG-WA; Sun, 23 Mar 2025 03:30:16 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 07/17] build/cargo: Support non-workspace directory source inputs. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:15 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271499816351 (code B ref 77093); Sun, 23 Mar 2025 07:30:15 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:58 +0000 Received: from localhost ([127.0.0.1]:47341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmQ-0004FY-0k for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:58 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:34824) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFlz-0004BF-7g for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:32 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h3Vgf4tjTqkYBWyagpTXL5ZNIhW4KaLaVkwkrFdGnws=; b=CKmFZltJGcsXqX+jLqACViuNcMfaLg06AKlE2pV9nmG7cw1To/DDON4Dg/JoT44Jp0d0Cu MKbXW11B5iQyTp/H7KtJi3lx9qHkpkk5xH3d2Q60RUQ4fmgbooLubsyz2xYVqFKhX8Ls8g ew4d/5MGBodQinW/8Nv0nrgZ+wsTO9/WtRkIZiQcF4szBDUC2UwBdXDBIT5hpMqipJmEG/ yEugDt+FAhv4Eqc/RPhjfwSNBlZrb9E3Zjq204XEX/EgUKkeKF11UN4TEh932CjcgWVhhI fBLcd2pBpg5IxmTZsWlfND+hFZ/rEiNnsZx+VfU3CG2pPdpGPWaYrxbYz/jSCA== Date: Sun, 23 Mar 2025 15:28:29 +0800 Message-ID: <4c0ba403c7eac57f45425e2372cc7ba5e0c08af5.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/build/cargo-build-system.scm (single-crate?): New procedure. (crate-src?): Support non-workspace directory source inputs. (configure): Likewise. Change-Id: If2bd318b44ed765baec69309f25d320edceee116 --- guix/build/cargo-build-system.scm | 60 ++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index f2a7323748..1012d7f401 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -33,6 +33,7 @@ (define-module (guix build cargo-build-system) #:use-module (ice-9 ftw) #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (ice-9 textual-ports) #:use-module (ice-9 threads) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -60,22 +61,35 @@ (define (has-executable-target?) (bin-dep? (lambda (dep) (find bin? (get-kinds dep))))) (find bin-dep? (manifest-targets)))) +(define (single-crate? dir) + "Check if directory DIR contains 'Cargo.toml' and is not a workspace." + (let ((manifest-file (in-vicinity dir "Cargo.toml"))) + (and (file-exists? manifest-file) + (not (string-contains + (call-with-input-file manifest-file get-string-all) + "[workspace]"))))) + (define (crate-src? path) "Check if PATH refers to a crate source, namely a gzipped tarball with a Cargo.toml file present at its root." - (and (not (directory-exists? path)) ; not a tarball - (not (string-suffix? "py" path)) ; sanity-check.py - ;; First we print out all file names within the tarball to see if it - ;; looks like the source of a crate. However, the tarball will include - ;; an extra path component which we would like to ignore (since we're - ;; interested in checking if a Cargo.toml exists at the root of the - ;; archive, but not nested anywhere else). We do this by cutting up - ;; each output line and only looking at the second component. We then - ;; check if it matches Cargo.toml exactly and short circuit if it does. - (apply invoke (list "sh" "-c" - (string-append "tar -tf " path - " | cut -d/ -f2" - " | grep -q '^Cargo.toml$'"))))) + (if (directory-exists? path) + ;; The build system only handles sources containing single crate. + ;; Workspaces should be packaged into crates (via 'package phase) + ;; and used in inputs. + (single-crate? path) + (and (not (string-suffix? "py" path)) ;sanity-check.py + ;; First we print out all file names within the tarball to see + ;; if it looks like the source of a crate. However, the tarball + ;; will include an extra path component which we would like to + ;; ignore (since we're interested in checking if a Cargo.toml + ;; exists at the root of the archive, but not nested anywhere + ;; else). We do this by cutting up each output line and only + ;; looking at the second component. We then check if it matches + ;; Cargo.toml exactly and short circuit if it does. + (invoke "sh" "-c" + (string-append "tar -tf " path + " | cut -d/ -f2" + " | grep -q '^Cargo.toml$'"))))) (define* (unpack-rust-crates #:key inputs (vendor-dir "guix-vendor") #:allow-other-keys) @@ -159,14 +173,18 @@ (define* (configure #:key inputs (and (crate-src? path) ;; Gracefully handle duplicate inputs (not (file-exists? crate-dir)) - (mkdir-p crate-dir) - ;; Cargo crates are simply gzipped tarballs but with a .crate - ;; extension. We expand the source to a directory name we control - ;; so that we can generate any cargo checksums. - ;; The --strip-components argument is needed to prevent creating - ;; an extra directory within `crate-dir`. - (format #t "Unpacking ~a~%" name) - (invoke "tar" "xf" path "-C" crate-dir "--strip-components" "1"))))) + (if (directory-exists? path) + (copy-recursively path crate-dir) + (begin + (mkdir-p crate-dir) + ;; Cargo crates are simply gzipped tarballs but with a + ;; .crate extension. We expand the source to a directory + ;; name we control so that we can generate any cargo + ;; checksums. The --strip-components argument is needed to + ;; prevent creating an extra directory within `crate-dir`. + (format #t "Unpacking ~a~%" name) + (invoke "tar" "xf" path "-C" crate-dir + "--strip-components" "1"))))))) inputs) ;; For cross-building From patchwork Sun Mar 23 07:28:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40706 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 9B9C827BBE9; Sun, 23 Mar 2025 07:30:32 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED 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 3323927BBE2 for ; Sun, 23 Mar 2025 07:30:31 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFmw-0001Vl-Cf; Sun, 23 Mar 2025 03:30:30 -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 1twFms-0001RQ-Av for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:26 -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 1twFmr-0008WV-S0; Sun, 23 Mar 2025 03:30:26 -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=nZMSP3IJmGH8bvNCHSTc4l/woXGuccB1OsC88I5gVRM=; b=fDs/DFDmSNxE2T1RM0Uj010CoIX+LYW+OyLgme96StG0RoHiOvfcc0kJ4geDLmxMvsp+Nn753I29vRpW2dQ0CMFO3NdqOrcgyC82o3r7mkXpQZADQ08ICHhDQXTZ9f3UrN3D/dxR5DV9f5V++d7zDSSaDwXzt/aFvOBRR9A9/gxXHD919HjGRQ8i4bM89I5jEB/W4GpvlRWS2fxHIPgDJr1dqgiaqI1NFwWPuhbsdeyR+RfQLiqSVBkcutZ8rvULwU4UKlvWiTfrAJ8KTZPcbo9x7GiIX+OEEmaeX9OItn+x9DIBJHg7ratoFPUuTca+DBjFE3J1cqe0YDh/DPo9Dw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmk-0004Ow-Tz; Sun, 23 Mar 2025 03:30:18 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 08/17] scripts: import: Document argument for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option in help message. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:18 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271499916358 (code B ref 77093); Sun, 23 Mar 2025 07:30:18 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:59 +0000 Received: from localhost ([127.0.0.1]:47343 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmQ-0004Fg-JF for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:58 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:48270) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFm1-0004BS-0M for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:33 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714971; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=nZMSP3IJmGH8bvNCHSTc4l/woXGuccB1OsC88I5gVRM=; b=DaVxxs1B31NSYgnxj0tFGgplNkmJbzhJClDUOsHYZxznTVzW6hCnAjx+EYS4ZW1tltMwRi eD/Ykl8Z82EAgs0KobJg/GT4TRnuEiNgZxiR29jOdIASjHIr0UqtT5xvYSV/cTJobHZ+8+ s9I5Kj/ZhcYLchlwVScgTXNamWN3PTc7EB1ESB2CXW4mD1mNIQalc2fm+s25rMyC4p4wki P4wqNrfz+A+g+18eMEX6g8iQLraiUCYpEuQt1elEkdSeJOZiGFqv0XQH6L6DGbGeVEyQJL y+M9Z9OfpQmrpUHWcG+WEu1gTEvMgjrRsbj1SHLGFq7Q5L2RAyIG5Cf0MsLrog== Date: Sun, 23 Mar 2025 15:28:30 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/import.scm (show-help): Add missing ‘FILE’. Change-Id: I540d5feae3fe49c00e9bd6f7a8649ffe0d6e006d --- guix/scripts/import.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index bbf31baa15..4fad329cd3 100644 --- a/guix/scripts/import.scm +++ b/guix/scripts/import.scm @@ -69,7 +69,7 @@ (define (show-help) (display (G_ " -h, --help display this help and exit")) (display (G_ " - -i, --insert insert packages into file alphabetically")) + -i, --insert=FILE insert packages into FILE alphabetically")) (display (G_ " -V, --version display version information and exit")) (newline) From patchwork Sun Mar 23 07:28:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40710 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 A56CD27BBEA; Sun, 23 Mar 2025 07:30:59 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED 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 6C21A27BBE2 for ; Sun, 23 Mar 2025 07:30:59 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFms-0001Qw-AX; Sun, 23 Mar 2025 03:30:26 -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 1twFmp-0001QI-Sk for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:23 -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 1twFmp-0008W7-CH; Sun, 23 Mar 2025 03:30:23 -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=fqhu2l56Odr9Ir4ZOodrxtGElOfLeWWRB8i95e+2gYA=; b=ZGDircIm5nxv+5Fm/1peCjCY/IOIXmeC1aYj/gTAFrRmGzksQqoN2lJtG/XDDCrb2sfyCfZ0/AE9PnkVk7lZNYlaJa63JmFHECfvnyDRlBnn/CPHeBgQ2kznR6kw1bmkASyk1YY7KovLmTOwlaAhNOlzEppVGvSyj1zt8pHwO2iUrrE2EtonJwQvae41TjTpU7ZlD2sA5WkRGA/repQtLtwM+ZcIEbrOhjKsOkBSVV2I5N5woSnyWw5Cm8bGEo5DnoBd1J/MzoNKKvn5wbgoe//OSggr6aLm8yxUyJ3K6+uvyl0E+u8spptEYIjKAedQOz9hTY+iF1zqNz0jgLEV6w==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmn-0004Pc-V0; Sun, 23 Mar 2025 03:30:21 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 09/17] scripts: import: Add two newlines for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:21 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271499916365 (code B ref 77093); Sun, 23 Mar 2025 07:30:21 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:29:59 +0000 Received: from localhost ([127.0.0.1]:47345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmQ-0004Fn-Tp for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:59 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:48276) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFm2-0004Be-Sd for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:35 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714973; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=fqhu2l56Odr9Ir4ZOodrxtGElOfLeWWRB8i95e+2gYA=; b=YX5XDe4TAQCmsiqa/20tQrikMHVKpxLmXgPagxvWbnQYTFfPIeieVJ5jIc6w9mMGeLOVkL hpyRr8dK6yh7NvnqpthmEHn0uSQ20zSDJUUYjYkaSArvvZgWhYyk3Y1JvuzDBVtcDDM/eF U+l7K8/CItkswUYAP1xJYgn4tbOkIitwFI0DJ1XqipbKFk8BAmdXLrxfiFoUpgtmxlL1CO HwFXzltPG1wACNZ/27istn767KCrPgGNo5VtrxPzxbfwTapuR9uPfwMumJo8iCbC1qqlOe sSjV/nWSxDQ7FHgEWoH3COr159gn2G8Rw0UoxQIUF4X2Uk2jpxq0Y6wJdml9Ow== Date: Sun, 23 Mar 2025 15:28:31 +0800 Message-ID: <80044c949ed949f57b3f76190f53e13c139cf442.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches For consistency with ‘insert-expression’. * guix/scripts/import.scm (guix-import): Add two newlines when inserting. Change-Id: I55b45ca137d175fdf6ee5c0bb2b6b1ca8385750d --- guix/scripts/import.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index 4fad329cd3..58a84d0db7 100644 --- a/guix/scripts/import.scm +++ b/guix/scripts/import.scm @@ -129,6 +129,7 @@ (define-command (guix-import . args) (let ((port (open-file file "a"))) (pretty-print-with-comments port expr) (newline port) + (newline port) (close-port port))))))))) (import-as-definitions importer args find-and-insert))) ((importer args ...) From patchwork Sun Mar 23 07:28:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40714 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 97F5027BBEA; Sun, 23 Mar 2025 07:31:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED 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 11E0627BBE2 for ; Sun, 23 Mar 2025 07:31:12 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFn3-0001b6-SY; Sun, 23 Mar 2025 03:30:37 -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 1twFmt-0001RV-FE for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:27 -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 1twFmt-00005A-1y; Sun, 23 Mar 2025 03:30:27 -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=czT8FP4fmhCvvCipLKqanBFPpsXWTXv5dSi/2ifeg3g=; b=oIKpP3KDwCHfMmd6qD1hdVss+HRE5sbTSDQgfS0yAwayej2dSPF8XGdMkaQbWa2h5Um6aFpA0gwjd/0UUZ3hsYMhhIDNSOXalA521iGeh425JAwBsTG7R3BodLYrY+8CknYMIZ2uP2rmopL13EW/2xLyYdD7+Ttc9JqOktifdiJUE4CSNGw5Mz3RZwP1/Fh0CfLPGmpLGhQ2+LLSTV5DRknSVSIBAqJVsrCpwIxA6tzBsIM5OSLxQt1koiSDbjSszdsrxqVpTbIffp66XA6qDVWAyGQUtHVbbu7RSELytyS6dNlNa+n3tFLuMEetHJoLm11VaW5hg4B+AWbU+y7fkg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmq-0004Qg-0w; Sun, 23 Mar 2025 03:30:24 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 10/17] scripts: import: Support expressions defined by 'define. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:23 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271500016375 (code B ref 77093); Sun, 23 Mar 2025 07:30:23 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:00 +0000 Received: from localhost ([127.0.0.1]:47347 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmR-0004Fu-6i for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:59 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54430) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFm5-0004C5-4W for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:38 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p3wLcBT+ZuzStmxt7XCA9mvvWfKLGl3I0jdiYr76vbc=; b=D+TTar/4Q7i7A98/cdw95/la5YMy+qdfsYroy+b20tAQ1xhan2+Z3TPvf9F57GdxPj4DWk +/7ApXXBAc2uyQPAIM8GIdlR9282RDvYLaN1KAlarjH0/zZr31L/0FMbjgrPc6+2USYDoq 3NVUhzWxWPiBNLK0lkKNo1Qr2M7UrzDInEhvBR3k3ymCZ5Ye2jIvR9KW7u3vE9/SUj0Gi4 YHS8LDbi/kqhFxtnBLNf5eftKnCYyrgX4ypxyApHyDjn7u027lkttBYtTjU3II0HxXSXUt mn3PHOyOtqzXAkj9J5tnQ7PIg2vgPa/55VKQBnf1R5wElZkKIXQ7Kj7PrXY7/g== Date: Sun, 23 Mar 2025 15:28:32 +0800 Message-ID: <00ffa2da7f970ea1c54cf3bd36574381cae5fd23.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/utils.scm (find-definition-location): New procedure. (find-definition-insertion-location): Define with it. * guix/scripts/import.scm (import-as-definitions, guix-import): Support expressions defined by 'define. Change-Id: I03118e1a3372028b4f0530964aba871b4a1a4d25 --- guix/scripts/import.scm | 21 +++++++++++++++------ guix/utils.scm | 29 +++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index 58a84d0db7..6f6354928e 100644 --- a/guix/scripts/import.scm +++ b/guix/scripts/import.scm @@ -30,6 +30,7 @@ (define-module (guix scripts import) #:use-module (guix read-print) #:use-module (guix utils) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (ice-9 format) #:use-module (ice-9 match) #:export (%standard-import-options @@ -83,7 +84,8 @@ (define (import-as-definitions importer args proc) ((and expr (or ('package _ ...) ('let _ ...))) (proc (package->definition expr))) - ((and expr ('define-public _ ...)) + ((and expr (or ('define-public _ ...) + ('define _ ...))) (proc expr)) ((expressions ...) (for-each (lambda (expr) @@ -91,7 +93,8 @@ (define (import-as-definitions importer args proc) ((and expr (or ('package _ ...) ('let _ ...))) (proc (package->definition expr))) - ((and expr ('define-public _ ...)) + ((and expr (or ('define-public _ ...) + ('define _ ...))) (proc expr)))) expressions)) (x @@ -117,13 +120,19 @@ (define-command (guix-import . args) (show-version-and-exit "guix import")) ((or ("-i" file importer args ...) ("--insert" file importer args ...)) - (let ((find-and-insert + (let* ((define-prefixes + `(,@(if (member importer '("crate")) + '(define) + '()) + define-public)) + (define-prefix? (cut member <> define-prefixes)) + (find-and-insert (lambda (expr) (match expr - (('define-public term _ ...) + (((? define-prefix? define-prefix) term _ ...) (let ((source-properties - (find-definition-insertion-location - file term))) + (find-definition-insertion-location + file term #:define-prefix define-prefix))) (if source-properties (insert-expression source-properties expr) (let ((port (open-file file "a"))) diff --git a/guix/utils.scm b/guix/utils.scm index c7c23d9d5b..3f85320845 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -154,6 +154,7 @@ (define-module (guix utils) edit-expression delete-expression insert-expression + find-definition-location find-definition-insertion-location filtered-port @@ -520,24 +521,36 @@ (define (insert-expression source-properties expr) (string-append expr "\n\n" str)))) (edit-expression source-properties insert))) -(define (find-definition-insertion-location file term) - "Search in FILE for a top-level public definition whose defined term -alphabetically succeeds TERM. Return the location if found, or #f -otherwise." - (let ((search-term (symbol->string term))) +(define* (find-definition-location file term + #:key (define-prefix 'define-public) + (pred string=)) + "Search in FILE for a top-level definition defined by DEFINE-PREFIX with +defined term comparing to TERM through PRED. Return the location if PRED +returns #t, or #f otherwise." + (let ((search-term (symbol->string term)) + (define-prefix? (cut eq? define-prefix <>))) (call-with-input-file file (lambda (port) (do ((syntax (read-syntax port) (read-syntax port))) ((match (syntax->datum syntax) - (('define-public current-term _ ...) - (string> (symbol->string current-term) - search-term)) + (((? define-prefix?) current-term _ ...) + (pred (symbol->string current-term) + search-term)) ((? eof-object?) #t) (_ #f)) (and (not (eof-object? syntax)) (syntax-source syntax)))))))) +(define* (find-definition-insertion-location file term + #:key + (define-prefix 'define-public)) + "Search in FILE for a top-level definition defined by DEFINE-PREFIX with +defined term alphabetically succeeds TERM. Return the location if found, or #f +otherwise." + (find-definition-location + file term #:define-prefix define-prefix #:pred string>)) + ;;; ;;; Keyword arguments. From patchwork Sun Mar 23 07:28:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40708 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 A7C9227BBEA; Sun, 23 Mar 2025 07:30:51 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED 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 7C32527BBE2 for ; Sun, 23 Mar 2025 07:30:51 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFmw-0001Vj-AZ; Sun, 23 Mar 2025 03:30:30 -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 1twFmt-0001Re-KY for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:27 -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 1twFmt-00005E-9M; Sun, 23 Mar 2025 03:30:27 -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=M4HrlWGLZ3dreItJ0Y4vmoicb+vbPDR/+AW9SX0g268=; b=IkUInJmx3/tDxFt7Rld9y4vOjGeArwIK5B90/gD4xsPLj6l439ZigCjf5ijV+TcipKIkW26S71/OzaCV9jrzeTRDcVY3jyGtujpn+5v4Q6hURDHB3mV1vPQKe43mA2Xllor8FeLrwc24XmUVSzhBHV4hWethnWHiPrrTB1z7ANYvpA+daI942WjtUwoEIpspWMdzCEG5GoD+8+nBOKVa09opUkPsjBUKufKAGSrGJyns73UwLju2osxEG59uRH8GP+sKCAF9X/mqJRqiprKiCWptK+2wtNm3fGhJybfIvYR2UmnAjzlV/rJgHYhYu6ajg/WsRva36H/Whgm//buCeQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmr-0004RB-Ew; Sun, 23 Mar 2025 03:30:25 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 11/17] scripts: import: Pass "--insert" to importers. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:25 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271500016385 (code B ref 77093); Sun, 23 Mar 2025 07:30:25 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:00 +0000 Received: from localhost ([127.0.0.1]:47349 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmR-0004G4-TR for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:30:00 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:48278) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFm7-0004CK-1k for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:39 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714977; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=KhWp5HomxdIJw2k6eeh7hBQ+zY/Mq1YRWj1Fvj0R1go=; b=DglK9qV7ynnb7nB4FXJsewfUIGLyJWFMSliL0xRWcWUvxlgxQdnmpA2Hw+XO0TnqnleYb4 QTxp1Wd/YDsZet3IoHAL1jOV9rUuC+ShT69lOGMLawrjvz9d5b1nIlrKQsdIZJ6HzEhA41 cn+ARbRYdpa90UFQJKOdGZalEDKJL/envdX7GCTSMqzZqZUXYBdFXUR7Zp87gqhlWt3afb KFsyRp6A19vlvdwpbMgUKj7eSY0kfWpIJsOdqkIvt9FRNChqj+8FJu2S57dtYH76dnBJ1D W1zgkX+5ahWEW7riT9LkBv2qcDEHUjFsp3WsDPbR3I3dDArW331V38P8H3lLqQ== Date: Sun, 23 Mar 2025 15:28:33 +0800 Message-ID: <8484c437247c8527b4dea8cdda1f3c43bb981611.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches So that importers can adjust the file before inserting. * guix/scripts/import.scm (%standard-import-options): Add ‘--file-to-insert’. (guix-import): Pass it to importers when ‘--insert’ is set. Change-Id: I8e7a18ee8e0f96d7fc5688a207a7a5390ad2fa30 --- guix/scripts/import.scm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index 6f6354928e..38349bff3a 100644 --- a/guix/scripts/import.scm +++ b/guix/scripts/import.scm @@ -31,6 +31,7 @@ (define-module (guix scripts import) #:use-module (guix utils) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-37) #:use-module (ice-9 format) #:use-module (ice-9 match) #:export (%standard-import-options @@ -41,7 +42,12 @@ (define-module (guix scripts import) ;;; Command line options. ;;; -(define %standard-import-options '()) +(define %standard-import-options + (list + ;; Hidden option for importer-specific file preprocessing. + (option '("file-to-insert") #f #t + (lambda (opt name arg result) + (alist-cons 'file-to-insert arg result))))) ;;; @@ -140,7 +146,10 @@ (define-command (guix-import . args) (newline port) (newline port) (close-port port))))))))) - (import-as-definitions importer args find-and-insert))) + (import-as-definitions importer + (cons (string-append "--file-to-insert=" file) + args) + find-and-insert))) ((importer args ...) (let ((print (lambda (expr) (leave-on-EPIPE From patchwork Sun Mar 23 07:28:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40713 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 ED45627BBE9; Sun, 23 Mar 2025 07:31:09 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED 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 C4E4727BBE2 for ; Sun, 23 Mar 2025 07:31:09 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFmv-0001UU-QP; Sun, 23 Mar 2025 03:30:29 -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 1twFmt-0001RW-Fg for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:27 -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 1twFmt-000056-0Z; Sun, 23 Mar 2025 03:30:27 -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=rrhSfMRParvnEoPsd8PRNLNnCpGJ1AEC4RVTgfshvK8=; b=oBGwPLrBON3lpFPWBdG/eum78KfoMU2wMKwhPsbnPR3wW0B5xUXm/leAJJjEvUTpkZXJdf/gxYoWBzS1+l8tDyoIFCTIPwLv5xWXyqAlnp+oOwJQOcKtgDCG4ynfdz2fygQMSQzfZv1Elg4hruqcHtIbKnTv2VSkItiTwHPVj/bxqqDKLOHJ+/sJBj1Gh1u14XwZNy5omYwgbR1JFzvc3xO7mJsuVLqxR5aqJBnsAocrVixjBSGtJ+3muUOCgK+Ye5iltwXaf/+fhVh2849x09ITu6pD0nAOr0UQnRKFSFQJbqfaYJWI79u02YR8XTTrhF0EVdF1n/6Dh+zhts10PQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFms-0004Rg-3a; Sun, 23 Mar 2025 03:30:26 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 12/17] scripts: import: Skip existing definition for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:26 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271500116395 (code B ref 77093); Sun, 23 Mar 2025 07:30:26 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:01 +0000 Received: from localhost ([127.0.0.1]:47351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmS-0004GE-DE for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:30:00 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:48284) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFm8-0004CY-V9 for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:42 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714979; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=rrhSfMRParvnEoPsd8PRNLNnCpGJ1AEC4RVTgfshvK8=; b=LPnH+aIrc6AAC52yIAYOvvWD8T4BotIa0TG1Ve17I7cZkFtbGs4P57Q5bGAscqWlFyAd2L Xd4cV7RsW5jkeJQkJs2Rz8NtWCEd73hUHRO4dlAX12LNeGGs4sd4GMxth4lgvwzEtk3vO6 8kZ+7gcqro9Cc9y0SioNfgXQyRzkBVLxnSMvgtKx1qANINHgrm9Zxvo7Duvxt9r5PHAmm6 7Ho+YD7Y5jefo+dzw2DRc6O+8gZfq8G/V4HINZVJfxoT2Rrj3ME8Pxcth0hKTxR4+cTZlN lPoL8A7Gf7Q3pbSqNePKkHk543URjjo8oG/zlC75gCHj+OOtMVbqWwTCf1/lCg== Date: Sun, 23 Mar 2025 15:28:34 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/import.scm (guix-import): Skip existing definition for ‘--insert’ option. Change-Id: I2c4242669f974b263a018ab0cf56538bd7c81d06 --- guix/scripts/import.scm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index 38349bff3a..1bddac15c6 100644 --- a/guix/scripts/import.scm +++ b/guix/scripts/import.scm @@ -136,16 +136,19 @@ (define-command (guix-import . args) (lambda (expr) (match expr (((? define-prefix? define-prefix) term _ ...) - (let ((source-properties - (find-definition-insertion-location - file term #:define-prefix define-prefix))) - (if source-properties - (insert-expression source-properties expr) - (let ((port (open-file file "a"))) - (pretty-print-with-comments port expr) - (newline port) - (newline port) - (close-port port))))))))) + ;; Skip existing definition. + (unless (find-definition-location + file term #:define-prefix define-prefix) + (let ((source-properties + (find-definition-insertion-location + file term #:define-prefix define-prefix))) + (if source-properties + (insert-expression source-properties expr) + (let ((port (open-file file "a"))) + (pretty-print-with-comments port expr) + (newline port) + (newline port) + (close-port port)))))))))) (import-as-definitions importer (cons (string-append "--file-to-insert=" file) args) From patchwork Sun Mar 23 07:28:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40715 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 C4F4727BBEA; Sun, 23 Mar 2025 07:31:22 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 3F10A27BBE2 for ; Sun, 23 Mar 2025 07:31:22 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFn3-0001aV-MX; Sun, 23 Mar 2025 03:30:37 -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 1twFmu-0001Tv-62 for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:28 -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 1twFmt-00005l-SU for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:27 -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=TGhCgjPyasQzWWazZ0P/MxkxxiwvTcGZxCgKEYHnGwk=; b=fd0dXkY/twlHEOPL5uP2BHLatBEylFb8zlKhXwKiHO/+/BKArW9BxDsBtTrenVFYbJt47M8jbG+i2r5rhRoMxscvRFPW/v6uc2eXgfjzUZeb8EF/lePZ9Q0EVWwHQSt+AQpuVOAKGfdIOH2oUrhNSDZDjkshpyQBvwVwaGK7hvNffEIkQoOSxs5u6lrhipSa4aoWrHjywkhyNqwf5BTn8QRq+32Bv//JT3QR9yxo25nncXZojx6nY/KY4mzjs1x3g0J/BdS1vi8SwBcmM6vFpLAfx/MC2kzFXUo3dIGmKPkGWn2i5FAt1m0PPHsRjhf97WGUQHdS7YdKmrOR3TjOxQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFms-0004S1-Ph; Sun, 23 Mar 2025 03:30:26 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 13/17] import: crate: crate-name->package-name: Move to (guix build-system cargo). Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:26 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271500216419 (code B ref 77093); Sun, 23 Mar 2025 07:30:26 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:02 +0000 Received: from localhost ([127.0.0.1]:47353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmS-0004GN-V2 for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:30:01 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54524) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFmB-0004D3-3w for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:44 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wekb04LgqEYpO0enGWr410xsI+L8Mevkj8GM+wk2izw=; b=WA3v9qqN0kE60tiPzOECy1X9NzPnnEx3HGN6qhsUAibEWz7gUKwA3Nj8uFvfneVR6NVxW5 9YzruVwK9EoFtMCvn/uTmPVr5jC+56mejnwr9sNmF8GHXOD45TYylFMRlGscc1UtNVvdCy ofZeJnYfRbIDClZnKUkDPe19v6sepd0FiXtc9Rl8oWawuHW55Nk1w0EQMpaHzXYwg1CXX7 PQ92hZUvVrKROjQOsQVZZazGR6C3pFloLoPWjVEA11FqrHQxAicvYKychoFgNbZib9s92Y nowWQH1pj40QGvn46rTzBfhGjA0kb3M/URG9qKwelZ+KgQXDorWueHHhqg0FMw== Date: Sun, 23 Mar 2025 15:28:35 +0800 Message-ID: <3e476eb8a81e416358acc9fc5cfbd6df0605dd21.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/import/crate.scm (crate-name->package-name): Move to... * guix/build-system/cargo.scm (crate-name->package-name): ...here and export. Change-Id: Ie9813179d6c40d159956cc1e2ae59a74dea0a42d --- guix/build-system/cargo.scm | 6 +++++- guix/import/crate.scm | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 4486c706a1..7a07003262 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -44,7 +44,8 @@ (define-module (guix build-system cargo) %crate-base-url crate-url crate-url? - crate-uri)) + crate-uri + crate-name->package-name)) (define %crate-base-url (make-parameter "https://crates.io")) @@ -58,6 +59,9 @@ (define (crate-uri name version) to NAME and VERSION." (string-append crate-url name "/" version "/download")) +(define (crate-name->package-name name) + (downstream-package-name "rust-" name)) + (define (default-rust target) "Return the default Rust package." ;; Lazily resolve the binding to avoid a circular dependency. diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 5a8caeb3e1..14e6e28c5b 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -481,10 +481,6 @@ (define (guix-package->crate-name package) (match parts ((name _ ...) name)))) -(define (crate-name->package-name name) - (downstream-package-name "rust-" name)) - - ;;; ;;; Updater @@ -528,4 +524,3 @@ (define %crate-updater (description "Updater for crates.io packages") (pred crate-package?) (import import-release))) - From patchwork Sun Mar 23 07:28:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40712 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 9C88227BBE2; Sun, 23 Mar 2025 07:31:08 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED 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 91E3927BBE9 for ; Sun, 23 Mar 2025 07:31:07 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFn3-0001bL-T1; Sun, 23 Mar 2025 03:30:37 -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 1twFmu-0001UM-PH for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:29 -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 1twFmu-00006f-F1 for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:28 -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=QktU/N3dJRKHXhCithY2wH09npibGaaWz0bSRpdmKjA=; b=WRb3FNQLYDd5emZda0mTgZmD8tDffpmcLLGn/FPl/ibS/ChNyxvdMwp8MSnfVf7f0PrVgejKx90Q/EgbGbCewSycjrhdup+MWfbALukqJ6bIbS/ch5H16a9kc2L+swz5QSe1B53/BBEGs1q/7OKbD0dskRWAOFXK9M0y9wcyVQXjotJuNwYYfOodY7CBEoYvfLIMK7e0m7fIbPHSHQSRj0+G2OpToRghFHe3fu84/nmabylwzW27RHUnKUo6ZOopEXbzhU0m2vi+L6Ahb9STroXPr7KhJzcDUskkgKyiBtLl2b+G1AQSfzMP/Em2+M1nL9x8wIQP/TTb/0om0pwoUQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmt-0004SF-Ag; Sun, 23 Mar 2025 03:30:27 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 14/17] build-system: cargo: Add =?utf-8?b?4oCYY2FyZ28taW5wdXRz4oCZLg==?= Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:27 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271500516490 (code B ref 77093); Sun, 23 Mar 2025 07:30:27 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:05 +0000 Received: from localhost ([127.0.0.1]:47355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmT-0004Gr-OI for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:30:04 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54540) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFmD-0004Db-E8 for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:47 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714984; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=QK3ReL2BAsFZjCPBVH7S/b7tT3dQsc5umNUoNod7fPw=; b=AjmzaVM+bYz5GvqkuGo+cvCQEO4hIqh3wI+4S2tC7QTvfeaBZhTmmcqHBAVlsVj89h8iwc Uj01FInoEPqJonm/70ujiFZI2rro9tqhNGmDynu598DRSorTjguwDv7ecoKN8LHQzFqkIh 51YmePIzzqNmjeQ4+rz3hAmjfWnOrTKrx2q5TO2/EdQogsOExa4lSarw+K4Lk4PdfkCJJS OEFGiEBSdFeq7efMnaSC2pmSZsuWtfYhUIwPjjXasQeJCEwAu/D1ABlS86Si0+ZiJIme7b 4/gbex1y4enyKSbAJyUR7nc3EjUah0yd9AO4qoO+aoa6y+OILbxn8NYdxUbycg== Date: Sun, 23 Mar 2025 15:28:36 +0800 Message-ID: <8fccd6705884ef7fae492cd6649060544f06bb0b.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/rust-crates.scm: New file. * gnu/packages/rust-sources.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Regisiter them. * guix/build-system/cargo.scm (crate-source,cargo-inputs): New procedures. * guix/import/crate.scm: Hide ‘crate-source’ from (guix build-system cargo). * etc/teams/rust/audit-rust-crates: New file. * etc/teams/rust/cleanup-crates.sh: New file. * etc/teams/rust/rust-crates.tmpl: New file. Change-Id: I2f2d705a3e376ed3c646f31b824052a2278d4fb3 --- etc/teams/rust/audit-rust-crates | 70 ++++++++++++++++++++++++++++++++ etc/teams/rust/cleanup-crates.sh | 37 +++++++++++++++++ etc/teams/rust/rust-crates.tmpl | 42 +++++++++++++++++++ gnu/local.mk | 2 + gnu/packages/rust-crates.scm | 42 +++++++++++++++++++ gnu/packages/rust-sources.scm | 29 +++++++++++++ guix/build-system/cargo.scm | 47 ++++++++++++++++++++- guix/import/crate.scm | 2 +- 8 files changed, 269 insertions(+), 2 deletions(-) create mode 100755 etc/teams/rust/audit-rust-crates create mode 100755 etc/teams/rust/cleanup-crates.sh create mode 100644 etc/teams/rust/rust-crates.tmpl create mode 100644 gnu/packages/rust-crates.scm create mode 100644 gnu/packages/rust-sources.scm diff --git a/etc/teams/rust/audit-rust-crates b/etc/teams/rust/audit-rust-crates new file mode 100755 index 0000000000..d5546fd1e1 --- /dev/null +++ b/etc/teams/rust/audit-rust-crates @@ -0,0 +1,70 @@ +#!/usr/bin/env -S gawk -f +# GNU Guix --- Functional package management for GNU +# Copyright © 2025 Efraim Flashner +# +# This file is part of GNU Guix. +# +# GNU Guix is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GNU Guix is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Guix. If not, see . + +# To run: +# ./etc/teams/rust/audit-rust-crates ./path/to/file.scm +# Prints the output of cargo-audit to the shell. + +# Make sure we have cargo-audit in our PATH +BEGIN { + if (system("which cargo-audit 1> /dev/null")) + exit 1; + # Parse a record at a time. + RS = "\n\n" + cargoAudit = "cargo-audit audit --file -" +} + +# Check the crate-source origin-only inputs +/crate-source/ { + for(i=3; i <= NF-2; i++) { + if($i == "(crate-source") { + cargoLock = cargoLock "[[package]]\nname = " $(i+1) "\nversion = " $(i+2) "\n" + next + } + } +} + +# Check the crates packaged from crates.io tarballs +/crate-uri/ { + for(i=3; i <= NF; i++) { + if($i == "(version") + crateVersion = $(i+1) + if($i == "(crate-uri") + crateName = $(i+1) + } + gsub(/)/, "", crateVersion) + cargoLock = cargoLock "[[package]]\nname = " crateName "\nversion = " crateVersion "\n" +} + +# The xxxx-cargo-input variables have a set style +# TODO: Replace the last dash between the name and the version with a space! +# This doesn't take into account swapping between "-" and "_" so we skip it. +#( $2 ~ /-cargo-inputs/ ) { +# sub(/-cargo-inputs/, "", $2) +# gsub(/)/, "", $0) +# gsub(/rust-/, "", $0) +# #gensub(/([[:alpha:]])-([[:digit:]]+)/, "\\1 \\2", "g", $i) +# print "[[package]]\nname = \"" $2 "\"\nversion = \"1.0.0\"\ndependencies = [" +# for (i = 4; i <= NF; i++) { +# print "\"" $i "\"," +# } +# print "]" +#} + +END { print cargoLock | cargoAudit } diff --git a/etc/teams/rust/cleanup-crates.sh b/etc/teams/rust/cleanup-crates.sh new file mode 100755 index 0000000000..eca37ca00c --- /dev/null +++ b/etc/teams/rust/cleanup-crates.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# GNU Guix --- Functional package management for GNU +# Copyright © 2025 Hilton Chain +# +# This file is part of GNU Guix. +# +# GNU Guix is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GNU Guix is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Guix. If not, see . + +FILE=gnu/packages/rust-crates.scm +PATTERN='^(define rust-' + +grep "$PATTERN" $FILE | cut -d' ' -f2 | while IFS= read -r crate +do + if [ "$(grep -wc "$crate" $FILE)" -eq 1 ]; then + echo "\ +(begin + (use-modules (guix utils)) + (let ((source-properties + (find-definition-location \"$FILE\" '$crate #:define-prefix 'define))) + (and=> source-properties delete-expression)))" | + guix repl -t machine + fi +done + +# Delete extra newlines. +sed --in-place ':a;N;$!ba;s/\n\n\+/\n\n/g' $FILE diff --git a/etc/teams/rust/rust-crates.tmpl b/etc/teams/rust/rust-crates.tmpl new file mode 100644 index 0000000000..98053b7151 --- /dev/null +++ b/etc/teams/rust/rust-crates.tmpl @@ -0,0 +1,42 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2025 Hilton Chain +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages rust-crates) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix git-download) + #:use-module (guix build-system cargo)) + +;;; +;;; This file is managed by ‘guix import’. DO NOT add definitions manually. +;;; + +;;; +;;; Rust dependencies fetched from crates.io and non-workspace development +;;; snapshots. +;;; + +(define qqqq-separator 'begin-of-crates) + +(define ssss-separator 'end-of-crates) + + +;;; +;;; Cargo inputs. +;;; diff --git a/gnu/local.mk b/gnu/local.mk index 02de02e65f..8d8bd6ebbe 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -616,6 +616,8 @@ GNU_SYSTEM_MODULES = \ %D%/packages/rush.scm \ %D%/packages/rust.scm \ %D%/packages/rust-apps.scm \ + %D%/packages/rust-crates.scm \ + %D%/packages/rust-sources.scm \ %D%/packages/samba.scm \ %D%/packages/sagemath.scm \ %D%/packages/sawfish.scm \ diff --git a/gnu/packages/rust-crates.scm b/gnu/packages/rust-crates.scm new file mode 100644 index 0000000000..98053b7151 --- /dev/null +++ b/gnu/packages/rust-crates.scm @@ -0,0 +1,42 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2025 Hilton Chain +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages rust-crates) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix git-download) + #:use-module (guix build-system cargo)) + +;;; +;;; This file is managed by ‘guix import’. DO NOT add definitions manually. +;;; + +;;; +;;; Rust dependencies fetched from crates.io and non-workspace development +;;; snapshots. +;;; + +(define qqqq-separator 'begin-of-crates) + +(define ssss-separator 'end-of-crates) + + +;;; +;;; Cargo inputs. +;;; diff --git a/gnu/packages/rust-sources.scm b/gnu/packages/rust-sources.scm new file mode 100644 index 0000000000..bf9b91a671 --- /dev/null +++ b/gnu/packages/rust-sources.scm @@ -0,0 +1,29 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2025 Hilton Chain +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages rust-sources) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix git-download) + #:use-module (guix build-system cargo)) + +;;; +;;; Cargo workspaces and Rust dependencies requiring external inputs to +;;; unbundle. +;;; diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 7a07003262..bbfa2f933b 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -31,6 +31,7 @@ (define-module (guix build-system cargo) #:use-module (guix gexp) #:use-module (guix monads) #:use-module (guix packages) + #:use-module (guix download) #:use-module (guix platform) #:use-module (guix build-system) #:use-module (guix build-system gnu) @@ -45,7 +46,9 @@ (define-module (guix build-system cargo) crate-url crate-url? crate-uri - crate-name->package-name)) + crate-name->package-name + crate-source + cargo-inputs)) (define %crate-base-url (make-parameter "https://crates.io")) @@ -62,6 +65,48 @@ (define (crate-uri name version) (define (crate-name->package-name name) (downstream-package-name "rust-" name)) +(define* (crate-source name version hash #:key (patches '()) (snippet #f)) + (origin + (method url-fetch) + (uri (crate-uri name version)) + (file-name + (string-append (crate-name->package-name name) "-" version ".tar.gz")) + (sha256 (base32 hash)) + (modules '((guix build utils))) + (patches patches) + (snippet snippet))) + +(define* (cargo-inputs name #:key (crates-module '(gnu packages rust-crates)) + (sources-module '(gnu packages rust-sources))) + + "Given symbol NAME, resolve variable 'NAME-cargo-inputs', an input list, in +CRATES-MODULE, return its copy with #f removed and symbols resolved to +variables defined in SOURCES-MODULE if the input list exists, otherwise return +an empty list." + (let loop ((inputs + (catch #t + (lambda () + (module-ref (resolve-interface crates-module) + (symbol-append name '-cargo-inputs))) + (const '()))) + (result '())) + (if (null? inputs) + result + (match inputs + ((input . rest) + (loop rest + (cond + ;; #f, remove it. + ((not input) + result) + ;; Symbol, resolve it in SOURCES-MODULE. + ((symbol? input) + (cons (module-ref (resolve-interface sources-module) input) + result)) + ;; Else: keep it. + (else + (cons input result))))))))) + (define (default-rust target) "Return the default Rust package." ;; Lazily resolve the binding to avoid a circular dependency. diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 14e6e28c5b..a6f247bbae 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -27,7 +27,7 @@ (define-module (guix import crate) #:use-module (guix base32) - #:use-module (guix build-system cargo) + #:use-module ((guix build-system cargo) #:hide (crate-source)) #:use-module (guix diagnostics) #:use-module (gcrypt hash) #:use-module (guix http-client) From patchwork Sun Mar 23 07:28:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40709 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 AF01327BBE2; Sun, 23 Mar 2025 07:30:58 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 BF5C527BBEA for ; Sun, 23 Mar 2025 07:30:57 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFn2-0001X7-HS; Sun, 23 Mar 2025 03:30:36 -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 1twFmu-0001UL-M5 for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:29 -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 1twFmu-00006Z-9p for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:28 -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=ouv9vwLl4lUf0H6sCyzs76iAhwKUiPvE3S8S+A1iQBM=; b=AjjRfC7D0jdBmw5IpASM2I2Cgu+aTY5syaO0DkZg20/zbu79YweKcI3Vajkojq9dHEywkLjWH1JEsee+rWM2C6ZOlQ69/7dIXaVPxbrEilZHV+Qy/PdqfKEOWIecZRMpGd6tUhyVD9cdIoMebgfSYDM++GiI74mr3ltjnw1+V5yPHv4gT2d6nww5w98c+7rZvMLhsc2KySa/C7b2qwJPb0PWZmlA1+t53j55IYrsgXi5x9tYfyI8YPXKuQ/A5gbj/gWqPV8Tor9t0h4GXHwgwO8kBsrEgQIWadYrgUrd14vAPdRWB8EdSlCjIO09/QzyOYk99sdNa2tI9lRDJz2Fdw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmu-0004SU-3b; Sun, 23 Mar 2025 03:30:28 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 15/17] import: crate: Add Cargo.lock parser. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:28 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Murilo , Hilton Chain , Luis Guilherme Coelho , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271500816613 (code B ref 77093); Sun, 23 Mar 2025 07:30:28 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:08 +0000 Received: from localhost ([127.0.0.1]:47361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmW-0004I0-Oh for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:30:08 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:40058) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFmG-0004Du-8c for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:49 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714987; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=aVHLOZmV4I/qcACy1bMCS4p3weOyVcxLn/v5Effmdss=; b=Cz814f2WlHfmTMNma8tZqVkAG5bA+4Sb7HAqCbVLABqt5M0ltYta9/Hv6LcR7ui1FhyUO7 DeD26FQaRyStjOVtAedQ4IEtdsT3M7M++4zWLvtbNK9S+hd9xp0KACFzdrgRrwDb9bc40D Qx/yXIjrpL0/zckEyHEN1K5hjRtH65Fzi2xA5uSuY6Xpk3gCC3/XVmU7IiA+57YyIZbahi cKf+zCbaMPZTg+q3+Sp1hgFbc5fntgZgutwNvIIK+P6FMGWG/L5hYDM/rDRdZZ1xn0LqeE rAXmYc6w4us/vkBzncQVPbfjWOoKzwlgsAA1/nc8Tqevz9wUQZB8tkKdkcD3Yg== Date: Sun, 23 Mar 2025 15:28:37 +0800 Message-ID: <52f74fa07c2b1671769f33aadd28037732062d79.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/import/crate/cargo-lock.scm: New file. * Makefile.am (MODULES): Regisiter it. * etc/teams.scm (rust)[#:scope]: Add it. * guix/import/crate.scm (cargo-lock->definitions): New procedure. Co-authored-by: Murilo Co-authored-by: Luis Guilherme Coelho Change-Id: I95421e9e2ba11a671b4bc4e1323c6d31a1b012c5 --- Makefile.am | 1 + etc/teams.scm | 1 + guix/import/crate.scm | 78 +++++++++++++++++++++++ guix/import/crate/cargo-lock.scm | 105 +++++++++++++++++++++++++++++++ 4 files changed, 185 insertions(+) create mode 100644 guix/import/crate/cargo-lock.scm diff --git a/Makefile.am b/Makefile.am index 4091a52387..a04e461ea8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -295,6 +295,7 @@ MODULES = \ guix/import/cpan.scm \ guix/import/cran.scm \ guix/import/crate.scm \ + guix/import/crate/cargo-lock.scm \ guix/import/egg.scm \ guix/import/elm.scm \ guix/import/elpa.scm \ diff --git a/etc/teams.scm b/etc/teams.scm index 6bddbd91fa..c4bee8d3d9 100755 --- a/etc/teams.scm +++ b/etc/teams.scm @@ -389,6 +389,7 @@ (define-team rust "guix/build/cargo-utils.scm" "guix/build-system/cargo.scm" "guix/import/crate.scm" + "guix/import/crate/cargo-lock.scm" "guix/scripts/import/crate.scm" "tests/crate.scm"))) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index a6f247bbae..ef3a6d0b4b 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -9,6 +9,9 @@ ;;; Copyright © 2023, 2024 David Elsing ;;; Copyright © 2024 Maxim Cournoyer ;;; Copyright © 2025 Herman Rimm +;;; Copyright © 2024 Murilo +;;; Copyright © 2024-2025 Luis Guilherme Coelho +;;; Copyright © 2025 Hilton Chain ;;; ;;; This file is part of GNU Guix. ;;; @@ -26,12 +29,14 @@ ;;; along with GNU Guix. If not, see . (define-module (guix import crate) + #:use-module (guix base16) #:use-module (guix base32) #:use-module ((guix build-system cargo) #:hide (crate-source)) #:use-module (guix diagnostics) #:use-module (gcrypt hash) #:use-module (guix http-client) #:use-module (guix i18n) + #:use-module (guix import crate cargo-lock) #:use-module (guix import json) #:use-module (guix import utils) #:use-module (guix memoization) @@ -39,9 +44,11 @@ (define-module (guix import crate) #:use-module (guix read-print) #:use-module (guix upstream) #:use-module (guix utils) + #:use-module (guix scripts download) #:use-module (gnu packages) #:use-module (ice-9 match) #:use-module (ice-9 regex) + #:use-module (ice-9 textual-ports) #:use-module (json) #:use-module (srfi srfi-1) #:use-module (srfi srfi-2) @@ -52,6 +59,7 @@ (define-module (guix import crate) guix-package->crate-name string->license crate-recursive-import + cargo-lock->definitions %crate-updater)) @@ -481,6 +489,76 @@ (define (guix-package->crate-name package) (match parts ((name _ ...) name)))) + +;;; +;;; Convert ‘Cargo.lock’ to Guix sources. +;;; + +(define (cargo-lock->definitions lockfile package-name) + "Given LOCKFILE, a 'Cargo.lock' file, convert its content into source +definitions. Return a list of sources and 'PACKAGE-NAME-cargo-inputs', an input +list referencing all imported sources." + (define (crate->definition crate) + (match crate + (('crate + ('crate-name name) + ('crate-version version) + ('crate-source _) + ('crate-checksum checksum)) + `(define + ,(string->symbol + (string-append (crate-name->package-name name) "-" version)) + ,@(if (or (string-suffix? "src" name) + (string-suffix? "sys" name)) + (list (comment ";; TODO: Check bundled sources.\n" #f)) + '()) + (crate-source ,name ,version + ,(bytevector->nix-base32-string + (base16-string->bytevector checksum))))) + ;; Git snapshot. + (('crate + ('crate-name name) + ('crate-version version) + ('crate-source source)) + (begin + (let* ((src (string-split source (char-set #\+ #\? #\#))) + (url (second src)) + (commit (last src)) + (version (string-append version "." (string-take commit 7))) + (checksum + (second + (string-split + (with-output-to-string + (lambda _ + (guix-download "-g" url + (string-append "--commit=" commit)))) + #\newline)))) + `(define + ,(string->symbol + (string-append (crate-name->package-name name) "-" version)) + ,(comment + ";; TODO: Define standalone package if this is a workspace.\n" + #f) + (origin + (method git-fetch) + (uri (git-reference + (url ,url) + (commit ,commit))) + (file-name + (git-file-name ,(crate-name->package-name name) ,version)) + (sha256 (base32 ,checksum))))))) + ;; Workspace member. + (else #f))) + + (let ((definitions + (filter-map crate->definition + (cargo-lock-string->scm + (call-with-input-file lockfile get-string-all))))) + (values definitions + `(define-public + ,(string->symbol (string-append package-name "-cargo-inputs")) + (list ,@(map second definitions)))))) + ;;; ;;; Updater diff --git a/guix/import/crate/cargo-lock.scm b/guix/import/crate/cargo-lock.scm new file mode 100644 index 0000000000..b8a6ab20c0 --- /dev/null +++ b/guix/import/crate/cargo-lock.scm @@ -0,0 +1,105 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2024 Murilo +;;; Copyright © 2024 Luis Guilherme Coelho +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix import crate cargo-lock) + #:use-module (ice-9 peg) + #:export (cargo-lock-string->scm + + crate-name + crate-version + crate-source + crate-checksum + crate-dependencies + cargo-lock)) + +;;; +;;; PEG parser for ‘Cargo.lock’. +;;; + +(define (cargo-lock-string->scm str) + (peg:tree (search-for-pattern cargo-lock str))) + +;; Auxiliar peg patterns +(define-peg-pattern numeric-char body + (range #\0 #\9)) + +(define-peg-pattern lowercase-char body + (range #\a #\z)) + +(define-peg-pattern uppercase-char body + (range #\A #\Z)) + +(define-peg-pattern alphabetic-char body + (or lowercase-char uppercase-char)) + +(define-peg-pattern alphanumeric-char body + (or alphabetic-char numeric-char)) + +;; name +(define-peg-pattern crate-name all + (+ (or "-" alphabetic-char + "_" numeric-char))) + +;; version +(define-peg-pattern non-negative-integer body + (+ numeric-char)) + +(define-peg-pattern crate-version all + (and non-negative-integer "." + non-negative-integer "." + non-negative-integer + (? (+ (or "-" lowercase-char + "." uppercase-char + "+" numeric-char "_"))))) + +;; source +(define-peg-pattern crate-source all + (and (or "registry" "git") + "+https://" + (+ (or "/" "." "?" "=" "-" "#" "_" + alphanumeric-char)))) + +;; checksum +(define-peg-pattern crate-checksum all + (+ (or lowercase-char numeric-char))) + +;; dependency specification +(define-peg-pattern dependency-specification all + (and crate-name (? (and (ignore " ") crate-version)))) + +;; dependencies +(define-peg-pattern crate-dependencies all + (and (ignore "[\n") + (+ (and (ignore " \"") + (capture dependency-specification) + (ignore "\",\n"))) + (ignore "]"))) + +;; crates +(define-peg-pattern crate all + (and (ignore "[[package]]\n") + (ignore "name = \"") (capture crate-name) (ignore "\"\n") + (ignore "version = \"") (capture crate-version) (ignore "\"\n") + (? (and (ignore "source = \"") (capture crate-source) (ignore "\"\n"))) + (? (and (ignore "checksum = \"") (capture crate-checksum) (ignore "\"\n"))) + (? (ignore (and "dependencies = " crate-dependencies "\n"))))) + +;; Cargo.lock +(define-peg-pattern cargo-lock all + (+ (and (ignore "\n") crate))) From patchwork Sun Mar 23 07:28:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40716 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 5E82A27BBEA; Sun, 23 Mar 2025 07:31:33 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED 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 A846C27BBE2 for ; Sun, 23 Mar 2025 07:31:32 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFn5-0001cJ-57; Sun, 23 Mar 2025 03:30:39 -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 1twFmx-0001XA-2X for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:36 -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 1twFmw-00007L-FC; Sun, 23 Mar 2025 03:30:30 -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=NCZbRfIjbdQsYRHffQ3JwLPvp0oN3GvJjdKWqctYL4Q=; b=jQFAe0qzHcw9VRxffBNuS5ZNea6JeWeO5umbi7pPp86lbVjY4SOncfbbbGKSsBkhBTcuuNVJhJppRZd0kw+J3KAZzdd07jNHpW+Mus1ZAnYSutsAXlVtuW1eP8crcqPYpcc9OWNWfiUsyAR4amHFZPWnN5TGyRAl04UQvC7+JSlO22dCJ24INRj2nO2RxEcL++GkipSljqTnBCPV42CEKDs3RcGD6z0dv3DU3ENnMLOL8zr9rduOrQgrxBfIBr3vl4P21T4zqzzrpn+iRUMVx2b/w/ObEJIMGiACew5HZp6MyTKTsevxehNwuDZSZyrrmGrsWQ9ZijQ0kGlegJrQ9w==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFmu-0004Sg-Sg; Sun, 23 Mar 2025 03:30:28 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 16/17] import: crate: Add =?utf-8?b?4oCYLS1sb2NrZmlsZeKAmQ==?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, divya@subvertising.org, efraim@flashner.co.il, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, maxim.cournoyer@gmail.com, zimon.toutoune@gmail.com, steve@futurile.net, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:28 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Christopher Baines , Divya Ranjan Pattanaik , Efraim Flashner , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Steve George , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Divya Ranjan Pattanaik , Efraim Flashner , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Steve George , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271501116701 (code B ref 77093); Sun, 23 Mar 2025 07:30:28 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:11 +0000 Received: from localhost ([127.0.0.1]:47368 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFma-0004Jn-Da for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:30:11 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:40062) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFmI-0004EA-2l for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:50 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714989; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=sLJzYPGfO+QkRVtxgTvXJbYwUKaAeoBjRxGqIariPi0=; b=R6IyhD+OlTa8VCB2/0Pzzddok9Rt6Z7FtSSrY9zHAMtfhWdoVmxpm8QIdK9ibN/AnSSc2m NikQtlly/ro2mtdvRe3719bSSGGW1NqIF8UTz0XMaNcVIJjuGVSUELTRCZLbMHbtFNtTT+ NHuUjg5QgVH9mchnaRYyi6CNiHoTJI9CuT8tWSS5rCy3L+WSdUMbn7g7zgUosgBP9PbfVP niWFsIbe/UujIHy8fYLzsKlLJR6BwSyHyBPF7j7DSZBJgUUnSxHQwHqsEKceGs2TMruVZ6 38X1pswhScvVMc3FSp3Blyk/X2rw6y4DWTVVurGTkTNrjeZIUp6T+e2ngbW9/g== Date: Sun, 23 Mar 2025 15:28:38 +0800 Message-ID: <81adafb3ac10a3b522c2e1949a91351f34216a9e.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/import/crate.scm (%options): Add ‘--lockfile’ option. * guix/scripts/import/crate.scm (show-help): Add it. (guix-import-crate): Use it. * doc/guix.texi (Invoking guix import): Document it. * tests/crate.scm (temp-file): New variable. ("crate-lockfile-import"): New test. Change-Id: I291478e04adf9f2df0bf216425a5e8aeba0bedd9 --- doc/guix.texi | 14 ++++++ guix/scripts/import/crate.scm | 58 +++++++++++++++++++---- tests/crate.scm | 88 +++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 10 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 7fa986b4b9..218c2ba630 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14703,6 +14703,20 @@ Invoking guix import If a crate dependency is not (yet) packaged, make the corresponding input in @code{#:cargo-inputs} or @code{#:cargo-development-inputs} into a comment. +@item --lockfile=@var{file} +@itemx -f @var{file} +When @option{--lockfile} is specified, the importer will ignore other options +and won't output package definitions, instead generating source definitions for +all dependencies in @var{file}, a @file{Cargo.lock} file. For example: + +@example +guix import crate --lockfile=/path/to/Cargo.lock my-package +@end example + +generates sources from @file{/path/to/Cargo.lock} and a list +@code{my-package-cargo-inputs} referencing these sources. The generated list is +intended for the package's @code{inputs}, replacing @code{#:cargo-inputs} and +@code{#:cargo-development-inputs}. @end table @item elm diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm index 723cbb3665..3b536e135a 100644 --- a/guix/scripts/import/crate.scm +++ b/guix/scripts/import/crate.scm @@ -25,11 +25,13 @@ (define-module (guix scripts import crate) #:use-module (guix ui) #:use-module (guix utils) + #:use-module (guix read-print) #:use-module (guix scripts) #:use-module (guix import crate) #:use-module (guix scripts import) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:use-module (ice-9 format) @@ -60,6 +62,9 @@ (define (show-help) sufficient package exists for it")) (newline) (display (G_ " + -f, --lockfile=FILE import dependencies from FILE, a 'Cargo.lock' file")) + (newline) + (display (G_ " -h, --help display this help and exit")) (display (G_ " -V, --version display version information and exit")) @@ -87,6 +92,9 @@ (define %options (option '("mark-missing") #f #f (lambda (opt name arg result) (alist-cons 'mark-missing #t result))) + (option '(#\f "lockfile") #f #t + (lambda (opt name arg result) + (alist-cons 'lockfile arg result))) %standard-import-options)) @@ -101,6 +109,8 @@ (define (guix-import-crate . args) #:build-options? #f)) (let* ((opts (parse-options)) + (lockfile (assoc-ref opts 'lockfile)) + (file-to-insert (assoc-ref opts 'file-to-insert)) (args (filter-map (match-lambda (('argument . value) value) @@ -111,16 +121,44 @@ (define (guix-import-crate . args) (define-values (name version) (package-name->name+version spec)) - (match (if (assoc-ref opts 'recursive) - (crate-recursive-import - name #:version version - #:recursive-dev-dependencies? - (assoc-ref opts 'recursive-dev-dependencies) - #:allow-yanked? (assoc-ref opts 'allow-yanked)) - (crate->guix-package - name #:version version #:include-dev-deps? #t - #:allow-yanked? (assoc-ref opts 'allow-yanked) - #:mark-missing? (assoc-ref opts 'mark-missing))) + (match (cond + ((and=> lockfile + (lambda (file) + (or (file-exists? file) + (leave (G_ "file '~a' does not exist~%") file)))) + (let-values (((crate-definitions input-list) + (cargo-lock->definitions lockfile name))) + (if file-to-insert + ;; Adjusted from ‘--insert’ option of guix-import. + (let ((term (second input-list))) + (begin + ;; Remove existing input list definition. + (and=> (find-definition-location file-to-insert term) + delete-expression) + ;; Insert input list alphabetically. + (or (and=> (find-definition-insertion-location + file-to-insert term) + (cut insert-expression <> input-list)) + (let ((port (open-file file-to-insert "a"))) + (newline port) + (pretty-print-with-comments port input-list) + (newline port) + (newline port) + (close-port port)))) + crate-definitions) + `(,@crate-definitions + ,input-list)))) + ((assoc-ref opts 'recursive) + (crate-recursive-import + name #:version version + #:recursive-dev-dependencies? + (assoc-ref opts 'recursive-dev-dependencies) + #:allow-yanked? (assoc-ref opts 'allow-yanked))) + (else + (crate->guix-package + name #:version version #:include-dev-deps? #t + #:allow-yanked? (assoc-ref opts 'allow-yanked) + #:mark-missing? (assoc-ref opts 'mark-missing)))) ((or #f '()) (leave (G_ "failed to download meta-data for package '~a'~%") (if version diff --git a/tests/crate.scm b/tests/crate.scm index d0dc779cd2..9b7066c3b1 100644 --- a/tests/crate.scm +++ b/tests/crate.scm @@ -34,6 +34,7 @@ (define-module (test-crate) #:use-module (gnu packages) #:use-module (ice-9 iconv) #:use-module (ice-9 match) + #:use-module (srfi srfi-11) #:use-module (srfi srfi-64)) @@ -476,6 +477,9 @@ (define rust-leaf-bob-3.0.2-yanked (description #f) (license #f))) +(define temp-file + (string-append "t-crate-" (number->string (getpid)))) + (test-begin "crate") @@ -1178,4 +1182,88 @@ (define rust-leaf-bob-3.0.2-yanked (x (pk 'fail (pretty-print-with-comments (current-output-port) x) #f))))) + +(test-assert "crate-lockfile-import" + (begin + (call-with-output-file temp-file + (lambda (port) + (display "\ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = \"adler2\" +version = \"2.0.0\" +source = \"registry+https://github.com/rust-lang/crates.io-index\" +checksum = \"512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627\" + +[[package]] +name = \"aho-corasick\" +version = \"1.1.3\" +source = \"registry+https://github.com/rust-lang/crates.io-index\" +checksum = \"8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916\" +dependencies = [ + \"memchr\", +] + +[[package]] +name = \"smithay\" +version = \"0.4.0\" +source = \"git+https://github.com/Smithay/smithay.git?rev=\ +0cd3345c59f7cb139521f267956a1a4e33248393#\ +0cd3345c59f7cb139521f267956a1a4e33248393\" +dependencies = [ + \"appendlist\", +] + +[[package]] +name = \"test\" +version = \"25.2.0\"\n" port))) + (mock + ((guix scripts download) guix-download + (lambda _ + (format #t "~a~%~a~%" + "/gnu/store/in056fyrz6nvy3jpxrxglgj30g0lwniv-smithay-0cd3345" + "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37"))) + (let-values + (((crates-definitions input-list) + (cargo-lock->definitions temp-file "test"))) + (and + (match crates-definitions + (((define 'rust-adler2-2.0.0 + (crate-source + "adler2" "2.0.0" + "09r6drylvgy8vv8k20lnbvwq8gp09h7smfn6h1rxsy15pgh629si")) + (define 'rust-aho-corasick-1.1.3 + (crate-source + "aho-corasick" "1.1.3" + "05mrpkvdgp5d20y2p989f187ry9diliijgwrs254fs9s1m1x6q4f")) + (define 'rust-smithay-0.4.0.0cd3345 + ($ + ";; TODO: Define standalone package if this is a workspace.\n" + #f) + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/Smithay/smithay.git") + (commit "0cd3345c59f7cb139521f267956a1a4e33248393"))) + (file-name (git-file-name "rust-smithay" "0.4.0.0cd3345")) + (sha256 + (base32 + "191h87bpzg0l1ihfb4hmx00b86pfb5mwwc6s8i49al0vigc14l37"))))) + #t) + (x + (pk 'fail (pretty-print-with-comments (current-output-port) x) #f))) + (match input-list + ((define-public 'test-cargo-inputs + (list rust-adler2-2.0.0 + rust-aho-corasick-1.1.3 + rust-smithay-0.4.0.0cd3345)) + #t) + (x + (pk 'fail x #f)))))))) + (test-end "crate") + +(false-if-exception (delete-file temp-file)) From patchwork Sun Mar 23 07:28:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40717 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 09F8F27BBEA; Sun, 23 Mar 2025 07:33:15 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED,URIBL_SBL_A autolearn=ham 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 A3E9C27BBE2 for ; Sun, 23 Mar 2025 07:33:13 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFpQ-00031D-LD; Sun, 23 Mar 2025 03:33:04 -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 1twFpP-000314-5N for guix-patches@gnu.org; Sun, 23 Mar 2025 03:33:03 -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 1twFpO-0000hI-9Z; Sun, 23 Mar 2025 03:33:02 -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=JiNwbKUrl7zsfQSvHZddejGeZQwk+CVEvwtXC14pCdk=; b=YAl/JwECoILp6EdtbYOtDY62gM6BFi5K995yPvl1yDOqq5D53eNPdU9VWe+rx67ZkLF3hZWW2nGvs9UY/+KLJ+3q3+P2mFu37HBFsoqf+6MwHJikSnDkHWr1IxG4WXAJfDEYJayDEEULT1II/uZh7cUFvO7HjCWBh8WymkZf74OFSM5eiL51LLRQGyErKbRg/tEr1jQco1CPe/7+vrKO0Cq2++88T7iq5HEoas2CFaBw6nhv10Y3GculUbccUchDqmrMrzsTJh6lD/URKCfB2IOZ5Qf9otea+TdxvF2ox3rweVjEP3AB0zD4ExhQWt6N+kqC8iOkUEVcWa+O3ClIZQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFpO-0004pp-3W; Sun, 23 Mar 2025 03:33:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 17/17] doc: Document lockfile importer based Rust packaging workflow. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271514318270 (code B ref 77093); Sun, 23 Mar 2025 07:33:02 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:32:23 +0000 Received: from localhost ([127.0.0.1]:47444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFoe-0004jV-HM for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:32:23 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:54550) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFmJ-0004ET-UH for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:55 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JiNwbKUrl7zsfQSvHZddejGeZQwk+CVEvwtXC14pCdk=; b=I39DQxxgZtDTKDE5TR92ggTTyDrG4NieIxzSDs+X/5ae5Cuwn1MaalaJS8EA7iGAdbUYSu wG0E2phwmhWzwj+3qO87rncyVIR40o5wDfTk6tw46p4By6VHWwBpzflGyRGTPbZWNUp9zA 0ZrjMNwY70NiSx0uNE6/m1BXfWOL+iULG2nGK/Zuh+lnWoP9fHVoLd1kqbrdEAL2QFtjzU 4T2iUIcWWl03TIxhsxlXk31HAiHF5Wpdyq+k6fqLdHbIMW6soY8IePC3bKwBqZ7YSqO6ph puDBipMUd130LAjuyEVdGUvkHH6FI9LSOmEIJkclztdYU/kvRyg75OHKZAwlEw== Date: Sun, 23 Mar 2025 15:28:39 +0800 Message-ID: <71cbf5b40992439fd6e7f52daac0b63d61edf1d4.1742713356.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * doc/contributing.texi (Packaging Guidelines)[Rust Crates]: Update documentation. * doc/guix-cookbook.texi (Packaging)[Packaging Workflow]: New section. Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc --- doc/contributing.texi | 91 ++++++++--- doc/guix-cookbook.texi | 352 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 418 insertions(+), 25 deletions(-) diff --git a/doc/contributing.texi b/doc/contributing.texi index ab4f30d54b..17f22390d5 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -1600,34 +1600,75 @@ Rust Crates @subsection Rust Crates @cindex rust -Rust programs standing for themselves are named as any other package, using the -lowercase upstream name. +Rust programs (binary crates) and dependencies (library crates) are treated +separately. We put our main efforts into programs and only package Rust +dependencies as sources, utilizing automation with a manual focus on unbundling +vendored dependencies. The following paragraphs will explain them and give +several examples. -To prevent namespace collisions we prefix all other Rust packages with the -@code{rust-} prefix. The name should be changed to lowercase as appropriate and -dashes should remain in place. +Rust programs are treated like any other package and named using the lowercase +upstream name. When using the Cargo build system (@pxref{Build Systems, +@code{cargo-build-system}}), Rust programs should have @code{#:install-source?} +argument set to @code{#f}, as this argument only makes sense for dependencies. +When the package source is a Cargo workspace, @code{#:cargo-install-paths} must +be set to enable relevant support. + +Rust dependencies are managed in two modules: + +@enumerate +@item +@code{(gnu packages rust-crates)}, storing source definitions imported from Rust +programs' @file{Cargo.lock} via the lockfile importer (@pxref{Invoking guix +import, @code{crate}, @code{--lockfile=@var{file}}}). + +Imported definitions must be checked and have vendored sources unbundled before +being contributed to Guix. This module is managed by the Rust team +(@pxref{Teams}). + +@item +@code{(gnu packages rust-sources)}, storing more complex definitions that need +to be full packages. This includes Rust dependencies requiring external inputs +to unbundle and Cargo workspaces. + +These dependencies should have the @code{#:skip-build?} argument set to +@code{#t}. For Cargo workspaces, @code{#:cargo-package-crates} must be set. + +Since they are added manually, the following naming convention applies: + +To prevent namespace collisions they are named with @code{rust-} prefix. The +name should be changed to lowercase as appropriate and dashes should remain in +place. In the rust ecosystem it is common for multiple incompatible versions of a -package to be used at any given time, so all package definitions should have a -versioned suffix. The versioned suffix is the left-most non-zero digit (and -any leading zeros, of course). This follows the ``caret'' version scheme -intended by Cargo. Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}. - -Because of the difficulty in reusing rust packages as pre-compiled inputs for -other packages the Cargo build system (@pxref{Build Systems, -@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and -@code{cargo-development-inputs} keywords as build system arguments. It would be -helpful to think of these as similar to @code{propagated-inputs} and -@code{native-inputs}. Rust @code{dependencies} and @code{build-dependencies} -should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in -@code{#:cargo-development-inputs}. If a Rust package links to other libraries -then the standard placement in @code{inputs} and the like should be used. - -Care should be taken to ensure the correct version of dependencies are used; to -this end we try to refrain from skipping the tests or using @code{#:skip-build?} -when possible. Of course this is not always possible, as the package may be -developed for a different Operating System, depend on features from the Nightly -Rust compiler, or the test suite may have atrophied since it was released. +package to be used at any given time, so all dependencies should have a +versioned suffix. The versioned suffix is the left-most non-zero digit (and any +leading zeros, of course). This follows the ``caret'' version scheme intended +by Cargo. Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}. + +In practice we are usually packaging development snapshots of Rust dependencies +specifically for some Rust programs, and can't simply identity them by version. +In this case we can use a @code{for-@var{program}} suffix, for example, +@code{rust-pipewire-for-niri} and @code{rust-pubgrub-for-uv}. +@end enumerate + +Rust dependencies are not referenced directly. @code{(guix build-sytem cargo)} +provides a @code{cargo-inputs} procedure to create an input list, in combination +with the lockfile importer. + +@cindex cargo-inputs +@deffn {Procedure} cargo-inputs @var{name} @ + [#:crates-module '(gnu packages rust-crates)] @ + [#:sources-module '(gnu packages rust-sources)] +Given symbol @code{'@var{name}}, resolve variable +@code{@var{name}-cargo-inputs}, an input list, in @var{crates-module}, return +its copy with @code{#f} removed and symbols resolved to variables defined in +@var{sources-module} if the input list exists, otherwise return an empty list. + +@var{name} must be consistent with the one used in lockfile importer invocation. +@end deffn + +For a more detailed packaging workflow, @pxref{Packaging Rust Crates,,, +guix-cookbook, GNU Guix Cookbook}. @node Elm Packages diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index d9b98a2ab3..1f0e5eee54 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -103,6 +103,7 @@ Top Packaging * Packaging Tutorial:: A tutorial on how to add packages to Guix. +* Packaging Workflows:: Real life examples on working with specific build systems. Packaging Tutorial @@ -127,6 +128,16 @@ Top * Automatic update:: * Inheritance:: +Packaging Workflows + +* Packaging Rust Crates:: + +Packaging Rust Crates + +* Common Workflow for Packaging Rust Crates:: +* Development Snapshots and Cargo Workspaces:: +* Rust Programs With Mixed Build Systems:: + System Configuration * Auto-Login to a Specific TTY:: Automatically Login a User to a Specific TTY @@ -514,6 +525,7 @@ Packaging @menu * Packaging Tutorial:: A tutorial on how to add packages to Guix. +* Packaging Workflows:: Real life examples on working with specific build systems. @end menu @node Packaging Tutorial @@ -1593,6 +1605,346 @@ References @uref{https://www.gnu.org/software/guix/guix-ghm-andreas-20130823.pdf, ``GNU Guix: Package without a scheme!''}, by Andreas Enge @end itemize +@node Packaging Workflows +@section Packaging Workflows + +The following sections are real life examples on working with specific build +systems, serving as extensions to the concise packaging guidelines +(@pxref{Packaging Guidelines,,, guix, GNU Guix Reference Manual}). + +@menu +* Packaging Rust Crates:: +@end menu + +@node Packaging Rust Crates +@subsection Packaging Rust Crates + +In preparation, add the following packages to our environment: + +@example +$ guix shell rust rust:cargo cargo-audit cargo-license +@end example + +@menu +* Common Workflow for Packaging Rust Crates:: +* Development Snapshots and Cargo Workspaces:: +* Rust Programs With Mixed Build Systems:: +@end menu + +@node Common Workflow for Packaging Rust Crates +@subsubsection Common Workflow for Packaging Rust Crates + +In this example, we'll package @code{cargo-audit}, which is published on the +@uref{https://crates.io, crates.io} Rust package repository. All its +dependencies are on crates.io as well. + +@enumerate +@item +Since @code{cargo-audit} is available on crates.io, We can generate a draft +definition via the crates.io importer (@pxref{Invoking guix import,,, guix, GNU +Guix Reference Manual}). In the end we'll have the following definiton: + +@lisp +(define-public cargo-audit + (package + (name "cargo-audit") + (version "0.21.2") + (source + (origin + (method url-fetch) + (uri (crate-uri "cargo-audit" version)) + (file-name (string-append name "-" version ".tar.gz")) + (sha256 + (base32 "1a00yqpckkw86zh2hg7ra82c5fx0ird5766dyynimbvqiwg2ps0n")))) + (build-system cargo-build-system) + (arguments (list #:install-source? #f)) + (inputs (cargo-inputs 'cargo-audit)) + (home-page "https://rustsec.org/") + (synopsis "Audit Cargo.lock for crates with security vulnerabilities") + (description + "This package provides a Cargo subcommand, @@command@{cargo audit@}, to +audit @@file@{Cargo.lock@} for crates with security vulnerabilities.") + (license (list license:asl2.0 license:expat)))) +@end lisp + +The symbol used in @code{cargo-inputs}, @code{'cargo-audit} here, must be a +unique identifier, usually matching the variable name of the package. + +@item +Unpack package source and navigate to the unpacked directory, then execute the +following commands: + +@example +$ cargo generate-lockfile +$ cargo audit +$ cargo license +@end example + +@command{cargo generate-lockfile} updates dependencies to compatible versions, +@command{cargo audit} checks known vulnerabilities and @command{cargo license} +checks licenses of all dependencies. + +We must have an acceptable output of @command{cargo audit} and ensure all +dependencies are licensed with our supported licenses (@pxref{Defining +Packages,,, guix, GNU Guix Reference Manual}). + +@item +Import dependencies from previously generated lockfile: + +@example +$ guix import --insert=gnu/packages/rust-crates.scm \ + crate --lockfile=/path/to/Cargo.lock cargo-audit +@end example + +@code{cargo-audit} used here must be consistent with the identifier used for +@code{cargo-inputs}. + +At this stage, package @code{cargo-audit} is buildable. + +@item +Finally we'll unbundle vendored sources. The lockfile importer inserts +@code{TODO:} comments to dependencies with high probability of bundled sources. +@code{cargo-build-system} also performs additional check in its +@code{check-for-pregenerated-files} phase: + +@example +$ ./pre-inst-env guix build cargo-audit +@dots{} +starting phase `check-for-pregenerated-files' +Searching for binary files... +./guix-vendor/rust-addr2line-0.21.0.tar.gz/rustfmt.toml +./guix-vendor/rust-arc-swap-1.7.1.tar.gz/rustfmt.toml +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/dictionary-rust-other +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/lib.rs.zst +./guix-vendor/rust-async-compression-0.4.21.tar.gz/tests/artifacts/long-window-size-lib.rs.zst +@dots{} +@end example + +Although dependencies in @code{(gnu packages rust-crates)} are not exported, we +can still select them via the Guix command-line interface through expression: + +@example +$ guix build --expression='(@@@@ (gnu packages rust-crates) rust-ring-0.17.14)' +@end example + +For most dependencies, a snippet is sufficient: + +@lisp +(define rust-bzip2-sys-0.1.13+1.0.8 + (crate-source "bzip2-sys" "0.1.13+1.0.8" + "056c39pgjh4272bdslv445f5ry64xvb0f7nph3z7860ln8rzynr2" + #:snippet + '(begin + (delete-file-recursively "bzip2-1.0.8") + (delete-file "build.rs") + ;; Inspired by Debian's patch. + (with-output-to-file "build.rs" + (lambda _ + (format #t "fn main() @{~@@ + println!(\"cargo:rustc-link-lib=bz2\");~@@ + @}~%")))))) +@end lisp + +In a more complex case, where unbundling one dependency requires other packages, +we should package the dependency in @code{(gnu packages rust-sources)} first and +reference it by a symbol in the imported definition. + +For example we have defined a @code{rust-ring-0.17} in @code{(gnu packages +rust-sources)}, then the imported definition in @code{(gnu packages +rust-crates)} should be modified to a matching symbol. + +@lisp +(define rust-ring-0.17.14 'rust-ring-0.17) +@end lisp + +When one dependency can be safely removed, modify it to @code{#f}. + +@lisp +(define rust-openssl-src-300.4.2+3.4.1 #f) +@end lisp +@end enumerate + +@node Development Snapshots and Cargo Workspaces +@subsubsection Development Snapshots and Cargo Workspaces + +In this example, we'll package @code{niri}, which depends on development +snapshots (also Cargo workspaces here). + +As we can't ensure compatibility of a development snapshot, before executing +@command{cargo generate-lockfile}, we should modify @file{Cargo.toml} to pin it +to a known working revision. + +To use our packaged development snapshots, it's also necessary to modify +@file{Cargo.toml} in a build phase, with a package-specific substitution +pattern. + +@lisp +(define-public niri + (package + (name "niri") + (version "25.02") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/YaLTeR/niri") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r")))) + (build-system cargo-build-system) + (arguments + (list #:install-source? #f + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'use-guix-vendored-dependencies + (lambda _ + (substitute* "Cargo.toml" + (("# version =.*") + "version = \"*\"") + (("git.*optional") + "version = \"*\", optional") + (("^git = .*") + ""))))))) + (native-inputs + (list pkg-config)) + (inputs + (cons* clang + libdisplay-info + libinput-minimal + libseat + libxkbcommon + mesa + pango + pipewire + wayland + (cargo-inputs 'niri))) + (home-page "https://github.com/YaLTeR/niri") + (synopsis "Scrollable-tiling Wayland compositor") + (description + "Niri is a scrollable-tiling Wayland compositor which arranges windows in a +scrollable format. It is considered stable for daily use and performs most +functions expected of a Wayland compositor.") + (license license:gpl3+))) +@end lisp + +@code{niri} has Cargo workspace dependencies. When packaging a Cargo workspace, +argument @code{#:cargo-package-crates} is required. + +@lisp +(define-public rust-pipewire-for-niri + (let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9") + (revision "0")) + (package + (name "rust-pipewire") + (version (git-version "0.8.0" revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v")))) + (build-system cargo-build-system) + (arguments + (list #:skip-build? #t + #:cargo-package-crates + ''("libspa-sys" "libspa" "pipewire-sys" "pipewire"))) + (inputs (cargo-inputs 'rust-pipewire-for-niri)) + (home-page "https://pipewire.org/") + (synopsis "Rust bindings for PipeWire") + (description "This package provides Rust bindings for PipeWire.") + (license license:expat)))) +@end lisp + +Don't forget to modify all workspace members in @code{(gnu packages +rust-crates)}: + +@lisp +(define rust-pipewire-0.8.0.fd3d8f7 'rust-pipewire-for-niri) +(define rust-pipewire-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri) +@dots{} +(define rust-libspa-0.8.0.fd3d8f7 'rust-pipewire-for-niri) +(define rust-libspa-sys-0.8.0.fd3d8f7 'rust-pipewire-for-niri) +@end lisp + +@node Rust Programs With Mixed Build Systems +@subsubsection Rust Programs With Mixed Build Systems + +In this example, we'll package @code{fish}, which combines two build systems. + +When building Rust packages in other build systems, we need to add @code{rust} +and @code{rust:cargo} to @code{native-inputs}, import and use modules from both +build systems, and apply necessary build phases from @code{cargo-build-system}. + +@lisp +(define-public fish + (package + (name "fish") + (version "4.0.0") + (source + (origin + (method url-fetch) + (uri (string-append "https://github.com/fish-shell/fish-shell/" + "releases/download/" version "/" + "fish-" version ".tar.xz")) + (sha256 + (base32 "1wv9kjwg6ax8m2f85i58l9f9cndshn1f15n8skc68w1mf3cmpnig")))) + (build-system cmake-build-system) + (inputs + (cons* fish-foreign-env ncurses pcre2 + python ;for fish_config and manpage completions + (cargo-inputs 'fish))) + (native-inputs + (list doxygen groff ;for 'fish --help' + pkg-config + procps ;for the test suite + rust + `(,rust "cargo"))) + (arguments + (list #:imported-modules + (append %cargo-build-system-modules + %cmake-build-system-modules) + #:modules + (((guix build cargo-build-system) #:prefix cargo:) + (guix build cmake-build-system) + (guix build utils)) + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'use-guix-vendored-dependencies + (lambda _ + (substitute* "Cargo.toml" + (("git.*tag.*,") + "version = \"*\",")))) + (add-after 'unpack 'prepare-cargo-build-system + (lambda args + (for-each + (lambda (phase) + (format #t "Running cargo phase: ~a~%" phase) + (apply (assoc-ref cargo:%standard-phases phase) + args)) + '(unpack-rust-crates + configure + check-for-pregenerated-files + patch-cargo-checksums))))))) + (synopsis "The friendly interactive shell") + (description + "Fish (friendly interactive shell) is a shell focused on interactive use, +discoverability, and friendliness. Fish has very user-friendly and powerful +tab-completion, including descriptions of every completion, completion of +strings with wildcards, and many completions for specific commands. It also +has extensive and discoverable help. A special @@command@{help@} command gives +access to all the fish documentation in your web browser. Other features +include smart terminal handling based on terminfo, an easy to search history, +and syntax highlighting.") + (home-page "https://fishshell.com/") + (license license:gpl2))) +@end lisp + + @c ********************************************************************* @node System Configuration @chapter System Configuration