From patchwork Tue Mar 18 07:24:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40309 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 7ADE227BBE2; Tue, 18 Mar 2025 07:26:48 +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 BE64127BBEA for ; Tue, 18 Mar 2025 07:26:47 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRL1-0007BP-Ck; Tue, 18 Mar 2025 03:26:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuRKz-0007Ar-PM for guix-patches@gnu.org; Tue, 18 Mar 2025 03:26:09 -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 1tuRKz-0000ds-Fx for guix-patches@gnu.org; Tue, 18 Mar 2025 03:26:09 -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=fTJrKeLT9GSPYJTsuUaujgtn6qA4bB0llojftLqgAJM=; b=EVUJTqXOj+a1EfG+9RKPk2BImlgkKkm73hcY4msCIZ1G5Od60culKMrNwmcSiCnzL8ny2BJGVDDzf05XuiC2u9EcGpFHLQAip21iLf21N5mPwIWkzfN9ALXOEaBmQCU0XaZhd//+cn8gWUhiEo0LTlVRj0zx3Yrc61FYn1Uo+tKAhtNrLuGiFa8r5GEIgMzaGOMX+mEpeMVW4BpDRuHmqF9onD5T+9F/UkOpLoW0mngrvHlEUEZuiq58+OBeP5MjWqFuFjPJ6ELev0HHgSsGuogtMEdZ3OXpmYSlmxiWWuEB2f9Nt6FLO4IlfX/JyibBh9WgkxQcnf5yI/NwCA192g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRKu-0004ds-IX; Tue, 18 Mar 2025 03:26:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 01/18] build/cargo: Pass =?utf-8?b?4oCYLS1vZmZsaW5l4oCZ?= to cargo. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:26:04 +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 , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228273817564 (code B ref 77093); Tue, 18 Mar 2025 07:26:04 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:25:38 +0000 Received: from localhost ([127.0.0.1]:35857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRKT-0004Z7-Ul for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:38 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:46470) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKR-0004YQ-1S for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:35 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282733; 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=fTJrKeLT9GSPYJTsuUaujgtn6qA4bB0llojftLqgAJM=; b=b7/g+ibWHvXhpUnpzttbkf6FJYNZVjwxskFtQFXhnCk/cZ86szVVA/dEk0dhOyxL3cJ7le q3ys8+05dw3JaXiPjyZ6a7TBs7ibkP7jt53oUHJlrm5je7vhdHwwI+kJYFsOPo1kCZpj7B GBP4KSyp1U/B9OtRUU32uLQBDV4fU1T9vo3UcBOTU6VUTnLv5BzMkO6ARE35gtWKoMbAZD iam9CwRTvMPLEwc0HWXJg3updFy5IuiLHgyZihDxCmKOLxhw4Lr0OBY7d4VYr5ZkJypyhn bq7wo33+8OAVVylVU0M20bIOK2iF6yFyZrUU7KUHjw8T2ZfEPZ7YeVDcPK2zjQ== Date: Tue, 18 Mar 2025 15:24:14 +0800 Message-ID: <73db5916ba93efd5f30d9e45945a0ccff88c330f.1742281797.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 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 Tue Mar 18 07:24:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40307 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 BF4CE27BBEA; Tue, 18 Mar 2025 07:26:44 +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 3873027BBE2 for ; Tue, 18 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 1tuRL3-0007CJ-Kz; Tue, 18 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 1tuRL1-0007Bg-Qp for guix-patches@gnu.org; Tue, 18 Mar 2025 03:26:11 -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 1tuRL0-0000e0-So for guix-patches@gnu.org; Tue, 18 Mar 2025 03:26:11 -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=tWCnhX4OoBIrcF5cBlDIauVuJiVPteEuBGDYdX+/oyI=; b=TcUALth2KIlnm0vXH3ESbCROjcwi5s00OATMkfb9HgFOS5FlrXOIYY/U/K/AUeDiNiWNuDa652gpusMXjFKWKrpEoi39klKXedhOU2azFSwpIO8KnU0C1wNAoj16ZV3QiKo6v5+u3jPgkm384kL9ZjneoksU9Pm3XkBbFQaWbJfVNhxFBIcwKXCqv5lNZJK7Y0glL6l4R5j4WiC4zYe4f3Gn/mkAKcEuY6XFD2ZykPxG4NO/sayjNeFmM/v0oV7MMRXrMuu/p3Ky+qzAYm6DMrAd1p4/XpejVx74dsheyH+8CMhUpxNUhs1JroY4OmYhCm14i5mhXMoNocA4BlAqEA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRKw-0004eO-IW; Tue, 18 Mar 2025 03:26:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 02/18] build/cargo: Print out all non-empty binary files. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:26:06 +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 , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228275517730 (code B ref 77093); Tue, 18 Mar 2025 07:26:06 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:25:55 +0000 Received: from localhost ([127.0.0.1]:35864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRKk-0004bk-Dz for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:55 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:41554) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKV-0004Z5-6a for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:42 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282737; 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=tWCnhX4OoBIrcF5cBlDIauVuJiVPteEuBGDYdX+/oyI=; b=bT5M1EJ0Yh8tLnpS6Xxth+xzg35c+Tv9/j6VvIIoNOym8HnG4hXH4zSCLDLzGACdX/7uqt lFW//OB1cpXKvFYeoHdjCtngY/dmV2Z6w4tzYFQA6IhKWODuPZotUGq2pSCM7W8zhOsGbr AolCVIWaAGV4yqVJW8v3Q+19+Gfv7WdP+I9+40fCZM0+tiiORmeQbYec102A0S3HlcV0/U 77SpX+dR0dWIE0Uu/+vfZCrFZxqCeRi2esgP8pJH3950/m+9pEJgvlVQocLNjfI++yGd1l gz3vZRhoJz78vnQkRl6skiY2pfE7LtE+HBvW5sNp7SSO3bajBotoRi6K7qfgjg== Date: Tue, 18 Mar 2025 15:24:15 +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 Tue Mar 18 07:24:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40306 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 300A827BBEA; Tue, 18 Mar 2025 07:26:26 +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 8C7BD27BBE2 for ; Tue, 18 Mar 2025 07:26:25 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRL0-0007Az-Tq; Tue, 18 Mar 2025 03:26:10 -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 1tuRKz-0007Ai-5x for guix-patches@gnu.org; Tue, 18 Mar 2025 03:26:09 -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 1tuRKy-0000dk-QO; Tue, 18 Mar 2025 03:26:08 -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=XfpoWRsU1ZYTnjvOxVq/KZehQ1kOyETb6xjxd2Z6avA=; b=sG7n87l0yyU5C77e2BRct/EJzyROi0IWh0IUdC/T9vsnYtBP4m5NyQCL/F0DlvEpB5B1YYLvDRbkwJBwDpdP7mJIBFaduJ19x2C4onQiAY5JNPcL3yylqZtzP8KsFgVfmTtGdgGnq18i7wSOcLok5roEHHG2kX/Ce9+fVI+csyCsGPXgb5YtC94vFsIH2Mg+mt2zEQu5qm+fVcKeKYS60d5nZIjXuD7dlUweDeRoOKfgxpHNDhk10CBpJr/bq+SEC8QYyzGbXRByAbYBavRH/B9KKxK2sYYLyLOIwiz2umwK//KrtdC+1p35YRni48oy8sir2m3JszZnr9OlqKHXqA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRKy-0004et-Jc; Tue, 18 Mar 2025 03:26:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 03/18] build-system: cargo: Support packaging Cargo workspace. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, ludo@gnu.org, maxim.cournoyer@gmail.com, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:26:08 +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 , Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228275617745 (code B ref 77093); Tue, 18 Mar 2025 07:26:08 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:25:56 +0000 Received: from localhost ([127.0.0.1]:35866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRKl-0004bv-BR for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:56 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:41564) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKY-0004Zv-1U for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:46 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282740; 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=XfpoWRsU1ZYTnjvOxVq/KZehQ1kOyETb6xjxd2Z6avA=; b=Aq7LZkUiqkAYTrNBtUUTvhzFMQW/pUO5PyNmAiBRoPXoToPFl9D7mBZKyWx/KaZhl4oq4E FVnHzpIpfhWyJS7AMaN0RWtHvoy9YFBy7ZsIj/Mr4kVNXDRm9IqSdBD27/r5vtCAF92CHe f06JJsQG5QiXvlp5sj2yySfcXsMhBSDxxdjvURT8AZYPtzy6oo60LFWezBbTTflesC5DLl bpNlr0L+tFK5yUR/iCXcmNF1Nc9HDLMWwqovi4kV+qhzXKkV8WiRipapfIXBM7H2zVdOA2 QTAM3orhWPTUff7yCV5gcMNzJJFHfuqI9o/AH7RKFJiBOqnNrSct82gdf31+iA== Date: Tue, 18 Mar 2025 15:24:16 +0800 Message-ID: <0478229ef1b10a866b0c1cc9e33ec5bf27346d37.1742281797.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/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 | 28 ++++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0ca109a214..322512fd36 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 @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..001e9c7adc 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,26 @@ (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)) + ;; Use unstable feature ‘--registry’. + (begin + (setenv "RUSTC_BOOTSTRAP" "1") + (for-each + (lambda (pkg) + (apply invoke "cargo" "package" "--offline" "--package" pkg + "--registry" "crates-io" "-Z" "package-workspace" + cargo-package-flags) + (for-each + (lambda (crate) + (invoke "tar" "xzf" crate "-C" vendor-dir)) + (begin + (delete-file-recursively "target/package/tmp-registry") + (find-files "target/package" "\\.crate$"))) + (patch-cargo-checksums #:vendor-dir vendor-dir)) + cargo-package-crates) + (unsetenv "RUSTC_BOOTSTRAP"))) ;; 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 Tue Mar 18 07:24:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40308 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 D867727BBEC; Tue, 18 Mar 2025 07:26:47 +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 42DA127BBE2 for ; Tue, 18 Mar 2025 07:26:47 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRL5-0007Cx-2p; Tue, 18 Mar 2025 03:26: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 1tuRL3-0007C2-5Q for guix-patches@gnu.org; Tue, 18 Mar 2025 03:26: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 1tuRL2-0000eB-Qu; Tue, 18 Mar 2025 03:26: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=nu5Fq3O3l7S/8mex7Vy7MAjGDCPLGyv+RkJelUXlR28=; b=oHdQvN1Dr/yKxGXKa0P9v6OWzVTqNQRSyy96Yu/uPxB9LnD/+YQmr/j1hTnp+hMGZaesH0scYuJtARzPY7p2kyyM21owEgmtJhZNmHUJ8ylJMpyM1+yxZfg+ieGV44SaAJ5VDztX4veZ97QyjGhTn4+WWLg3Ob6PE9TDAvh+khuNe5ElXFz0/nU9hpfBi7qp7u4tUE6RBHQdzOPbW7m+Ak55fq/+1Qc3kNh+xSvDDkAS0uF+JM0L7W4iaslzcDxnhXkBziRRaT7faCR+Mp7++sZNBvZDpUP5vesUR15bbr1IRKLhvAMWQM80LVq5B65jFGNRZLfVllUQnb1GOahR6Q==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRKz-0004f3-6A; Tue, 18 Mar 2025 03:26:09 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 04/18] build-system: cargo: Support installing Cargo workspace. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, ludo@gnu.org, maxim.cournoyer@gmail.com, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:26:09 +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 , Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228275917781 (code B ref 77093); Tue, 18 Mar 2025 07:26:09 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:25:59 +0000 Received: from localhost ([127.0.0.1]:35868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRKm-0004c9-IV for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:58 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:33298) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKc-0004ae-C9 for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:48 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282744; 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=nu5Fq3O3l7S/8mex7Vy7MAjGDCPLGyv+RkJelUXlR28=; b=F4sxlH9nBKwNh5qRHD0evHgeExCInSZohlxOWf6VUnMSmTkTi9El+0PQ/NkfNeqps082CE lP2omh2VBxSOcOtJPAxD1sHdma4weeCyQ+cGF5M8q9Bml6q7L5b5BLdGYVmqqrwNHZvOJF nYe/aNoRbpDRDLfuF05j3GexF2bOh5x7rCB57MfIBnuNwBCRTQUVNiqkj0XmXvNr8tqPSJ 8MibegZNbzqKZ7isXtz539dQ2yp8Dbf9/8lvqhLBF1VcQf0JJuixt40BMhpyHDrU4/yZMo bUNFgEiU0q2X25tE8ZgdO2JQzYi1OyKdClRjWYqP/a8czRv9kyThb83AmNfI8w== Date: Tue, 18 Mar 2025 15:24:17 +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 322512fd36..c20e1d7f9c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9369,7 +9369,10 @@ Build Systems names of library crates to package in @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"}. +package @code{"pcre2-sys"} first and then @code{"pcre2"}. Parameter +@code{#:cargo-install-paths} (default: @code{''()}) allows specifying +paths of binary crates to install in @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 001e9c7adc..bcee10837e 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -384,6 +384,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")) @@ -398,10 +399,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 Tue Mar 18 07:24:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40311 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 177FC27BBEA; Tue, 18 Mar 2025 07:27:19 +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 C4A2727BBE2 for ; Tue, 18 Mar 2025 07:27:18 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRLv-0007X4-Ln; Tue, 18 Mar 2025 03:27: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 1tuRLt-0007WO-JR for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:05 -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 1tuRLt-0000uf-4q for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:05 -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=HtYEExicQh5Fb/O/ity8W3bnp/kwCs5U25QBUcMnorE=; b=UVdUG6KuI/qPMYgx+1yHHIwuSa54E8TUYXYLVLf1YMm8dHsKZjaD270BerNxnJ5IcdJMXi3Lpi05RQcNG8YpmbwE5N6AinueXSx6zX1V4AEkv3PQskTjBlYsCY4FdNdnoEVMbdWZkqHaVJeTRGTF3FhnyVu+ZVTQdFPtmeGbnBNjRlkjCbSJzuAMiVJ5o1n3qiZhg034JIOcF5qC/W8JmWgJGGd6P6x8+WAOT3GL6bBCd1PaZwFi0/8510s7U4AXjhohzqvN2mw6yltUFcrRhfCNesND5B6fEKc5O+/VfNvfeyG89T9Xse5EmkkKhcD9mZPNpFayfJh2ovH+gNE/UQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRLs-0004o0-R7; Tue, 18 Mar 2025 03:27:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 05/18] build/cargo: Set default value of arguments for build phases. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:27:04 +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 , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228277817989 (code B ref 77093); Tue, 18 Mar 2025 07:27:04 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:18 +0000 Received: from localhost ([127.0.0.1]:35909 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRL7-0004fz-Vj for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:18 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:33306) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKe-0004b6-W7 for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:50 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282747; 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=HtYEExicQh5Fb/O/ity8W3bnp/kwCs5U25QBUcMnorE=; b=VeLmxoWcqHj+rngBLQmpPQSfT/TUN9gW3+nuvCr7iCeHAxwce9Spf5qTthJ+QIE4n+u7BW 4Ey8JLNKBujpO8r5uRA8OHDny6MV1Q48/dAV5sFREum1qo2358ZJHlJ31zEVh7uSt00SRT yJsTGAXEIVz6KZNotczUWWi2k8IFY9zQ5mzfxJ2pzBQceCRhH9Fh1Z0mLdJXd3cSu7mNh6 9WV0+/1GRrSfpDn7YMneqYNTY8+nSvvyIg6ouVk/ef5O2ZI6eMHZ4BH6GwHN/lyRqXDzqg JcKtkXsqkwVmsnv+vXEEGylRsNPqZT7WJ8X2WPlLXLUB6pJlkUPKi1TMpfB5bw== Date: Tue, 18 Mar 2025 15:24:18 +0800 Message-ID: <58d019ff3c92473fc9813ddcbdf6aaee536c60b7.1742281797.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 bcee10837e..fdc9ae89c8 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") @@ -381,9 +382,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 Tue Mar 18 07:24:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40312 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 48B4127BBEA; Tue, 18 Mar 2025 07:27:40 +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 F0F8F27BBE2 for ; Tue, 18 Mar 2025 07:27:39 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRLz-0007Yf-7N; Tue, 18 Mar 2025 03:27:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tuRLw-0007Xa-5f for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:08 -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 1tuRLv-00012F-Np for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:07 -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=oFWeP0nug616Yq+nBssd1YSzuePdivNKyqlL9v/aiAs=; b=olSOCWpHUpXCJ+OUWcFdo8HSP3K2WCxXwpKIm6WRTbIW0tr3CIVl8UgPiqt+0o3ydCuan0GoT+FqwxZgQSqunKSuKqJNSjxm+sY6he3R5x07Cguj3ApQ70kiISntw8glZxBTZzDtXg1iaRsulivuONBSZpZVsgS0FCAANAuazi+drzUpI139yQdZKWhyQrBLqL9pyFQ/av8j52dyuOpBp1fmxFGnfnn6G25Zsjwoqw5sUgkYQLf/5MYgVksyjLUKHAWZZxDUQTpv8QF3daOU+6H11vDqxsibkU5K4Om75wmdcVej1p6ggCAHAV9b35wC4VKkQ/m8zEVJNgS0y4AQhg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRLu-0004oJ-DJ; Tue, 18 Mar 2025 03:27:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 06/18] build/cargo: Don't try to unpack sanity-check.py. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:27:06 +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 , Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228277917999 (code B ref 77093); Tue, 18 Mar 2025 07:27:06 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:19 +0000 Received: from localhost ([127.0.0.1]:35912 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRL9-0004gC-1m for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:19 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:33314) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKi-0004bU-L7 for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:53 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282751; 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=oFWeP0nug616Yq+nBssd1YSzuePdivNKyqlL9v/aiAs=; b=frSJk7D14LrXDEN/fX2KzDOt5xnsvs7PSu28ARYllfXAf84mIa/dwOMVOwDO+n+p9s7vxG /NUmt12AR7Ghyt8eKkXo4GjzhBr5VME4kEX3R3mV+ziNknxywKb90PiZmzneJxrO0rgRIP MifHHbOHG0z/XiwJzIUTz9aIkbZKMF5NNYo3oj+YEezgRU6BEA9aTHKw9+Yy3LiAENmqvg BsQZBoCEO3Vyug7jwpUITTJ6hPj9nINOXSijrcINgfLRyTUJoR5lVRxmkxyGdg46ATlM8O 51PcYni0ALMkppLBB+MIYwnQGwNCeL512781FMIlelyNvK+p/qfdL5yCcVJ9BQ== Date: Tue, 18 Mar 2025 15:24:19 +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 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 fdc9ae89c8..ea00ff3fbe 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 Tue Mar 18 07:24:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40313 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 F023727BBEA; Tue, 18 Mar 2025 07:27:44 +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 1F51127BBE2 for ; Tue, 18 Mar 2025 07:27:44 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRLy-0007YR-32; Tue, 18 Mar 2025 03:27:10 -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 1tuRLw-0007XW-0S for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:08 -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 1tuRLv-00010i-Er for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:07 -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=Eoru8qBkNmnrq/dwzDTiX9NodZUnnbpQ/4ZEgXGajKo=; b=LACcYbqdNJpk4wUlRLM1AQ/6MtQ3Wg9pY5cKnx8poZ8d5y47WIBpHF63DPtE2nbrWnLo+g6WpQL+OT/bHeBJov3F0TXkPa6AfCyxGPZk6zvHnsvymG6buqVo+pZrXVQjahuPL8ecEUIxwKs2vdoD9etXx8Gg0wjG0dEhsoRGbaZL9TxQnFijkOgIF05sWOu3GkTu/bvm9DVcUTDjxj6Ly5yUuKJTnrtNEd38/F0rtALhLLoFSMklRirRIH5zYWzSDWhFkLwjX0B6o8l1hYnjWhpXewnugppKL5Y7U27NuqOWpimvVQpiaKKfRu5whXPoi1A+O2vbPNTboh9JHDXEgw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRLv-0004oY-6P; Tue, 18 Mar 2025 03:27:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 07/18] build/cargo: Support non-workspace directory source inputs. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:27:07 +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 , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228278018006 (code B ref 77093); Tue, 18 Mar 2025 07:27:07 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:20 +0000 Received: from localhost ([127.0.0.1]:35915 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRL9-0004gG-FL for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:19 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:49244) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKm-0004c0-Dh for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:25:58 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282754; 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=Eoru8qBkNmnrq/dwzDTiX9NodZUnnbpQ/4ZEgXGajKo=; b=W91bGfmMPrQ5NzdqeVoVkanARHxEL9GcjKczanCn513fU/Pzogm44EtR4fUGJ1mtdHae6E QijWA9Zzh3S6a5/AyAbik3TXnVmofUJiglSaTzTwbwokVEKZbkYQJiyGBQtXWyjATsy4KA ngSHeV9RolJRKBLy0FN0Cfh4167xwSCJd9sPL3aGlfSesDvTenZRC4deV4s5DMaZAoyt4d 8ZAKsnCYXnSMKg8Vk9YkzftLMWbBS/KqE7MiniS2YZYecH+Wr9xtZ5qqUmxM2/tYaAO4mW 6UvLZYeeWGlle+hwWRQpwRL5SsQC4AjAflOHr88aAM70zvIT0qnF+Ov2kza1LA== Date: Tue, 18 Mar 2025 15:24:20 +0800 Message-ID: <823eafa55e3a10146e0433d099849369395d4771.1742281797.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 ea00ff3fbe..a1c4f556bb 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 Tue Mar 18 07:24:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40310 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 3900127BBEA; Tue, 18 Mar 2025 07:27: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=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 0967427BBE9 for ; Tue, 18 Mar 2025 07:27:12 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRLy-0007Yb-SD; Tue, 18 Mar 2025 03:27:10 -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 1tuRLw-0007Xh-F1 for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:08 -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 1tuRLv-000136-Tj for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:08 -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=JtVpmvUHYhzQ0fAuHdosNIoIUr6sCxjVGkZ4GtLjbU0=; b=ENVPPxdV+y5txgV7fG6uePMEivSOioGd+tfbCnHKYowCpdGx59sIw+HPGJ2+wlD5J9Z8Ww+sAcGeQj5znDq1CrEd5iTESUVkC5u2JrmnqWfjHuG2FfPiO70N2NIofyp0c6eS7oDriJv1cml9wloPQU2dYvLzK1ceSi90pnCq3m/Dc87lwBLymStzV6eFkNxiDmaZKCntm0lB2qCC+IzlWxtfvkHkCXXbYU3l17fIPLNnvMIgqJk0Zj6M52FiBDA1Oa2FuyoqcIp9QejcLr4zqZxGcrxbbkhnGdjEGcowze92wJSjJ9qWaE2pdFVPdFp2iXTk2BomRZ23puvjKtPTBQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRLv-0004oi-Lu; Tue, 18 Mar 2025 03:27:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 08/18] build/cargo: Use system jemalloc. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:27:07 +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 , Efraim Flashner , Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228278018013 (code B ref 77093); Tue, 18 Mar 2025 07:27:07 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:20 +0000 Received: from localhost ([127.0.0.1]:35917 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLA-0004gN-18 for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:20 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:35242) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKq-0004cq-3K for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:01 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282758; 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=JtVpmvUHYhzQ0fAuHdosNIoIUr6sCxjVGkZ4GtLjbU0=; b=IhuuDHNC70TWQ24sQjgHwDabX+Mrvt5YdvXdX9uMA7tu73YVqK/5ERbD6JxTbdRUcyCFXT o/z+vav4a0iEEL/8CGumWAT7w2cpAJ/b3mjEk2GO5RjHj9ZPeJmRITv2+ZBEV79vArQC8+ JJlNAoXWDf8I0ji3pj0mURgatpnj4P3kC/YhXund91PR74rez+XB0GH77ytsXCc9sTqg1o xIozzmwGY/8NZGn3lyiJlFqrdWV2ifz/P/Ff5f203Pq2IxB/K/ixDlPm2liCj2DpimSFQF D8whyOKBmscAtBWKSmfmeU/g0e+dDfEoCYKx5KSsSb0+sGwAooGIO25dKysX/A== Date: Tue, 18 Mar 2025 15:24:21 +0800 Message-ID: <02e5f7ff3d45b516a797c3e68c257748336dbae2.1742281797.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 (configure): Set environment variables to use system jemalloc. Change-Id: Ibb1c025c7354ba2befd2770e3f1ccd785baa06c3 Modified-by: Hilton Chain --- guix/build/cargo-build-system.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index a1c4f556bb..b547421b88 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -248,6 +248,12 @@ (define* (configure #:key inputs (setenv "LIBSSH2_SYS_USE_PKG_CONFIG" "1") (setenv "SODIUM_USE_PKG_CONFIG" "1") (setenv "ZSTD_SYS_USE_PKG_CONFIG" "1") + ;; This flag is needed when not using the bundled jemalloc. + ;; https://github.com/tikv/jemallocator/issues/19 + (setenv "CARGO_FEATURE_UNPREFIXED_MALLOC_ON_SUPPORTED_PLATFORMS" "1") + (when (assoc-ref inputs "jemalloc") + (setenv "JEMALLOC_OVERRIDE" + (string-append (assoc-ref inputs "jemalloc") "/lib/libjemalloc.so"))) (when (assoc-ref inputs "openssl") (setenv "OPENSSL_DIR" (assoc-ref inputs "openssl"))) (when (assoc-ref inputs "gettext") From patchwork Tue Mar 18 07:24:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40314 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 A2C2127BBEA; Tue, 18 Mar 2025 07:27:48 +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 6548227BBE2 for ; Tue, 18 Mar 2025 07:27:48 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRMP-0007fe-Ot; Tue, 18 Mar 2025 03:27:38 -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 1tuRLz-0007Yg-2B for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:11 -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 1tuRLy-0001GT-KK; Tue, 18 Mar 2025 03:27: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=0gATDkYY9+HlIpSIiMsJydmF48/8/FeFvqFI8MW5iOs=; b=ba6GwaNSfP9DIdi6QvMhM8ydI+mfFw7whByCdQC7i66xc2uIOA5YeDimHwiEGbU9UReR54028PSL5CB3qsj/tnzrOis4sklGCJlKgIVCQa1OAimgHdQZ0tnSwEYvrjK6HJ5HSmmGt3MmE20G1FAdX5l1n8qT1PGyLskcLnl2DFW0EWGPCQ73JG5etSxfJKdN+bMGEW8yYWdILaQ5ngRFKV4sRn6BfqMuPCkFPb5pTlVRTcwTQqVa7yIYufiiCsQNQdDvh1vlqj2qDPif5ZKjtlLfP7YTCOQ1qZvUfhmIC86BQQ18zBcUu/QEkTz+fPm3ZsnlpSOvQw86ov0irsK+sw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRLx-0004pJ-GF; Tue, 18 Mar 2025 03:27:09 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 09/18] scripts: import: Document argument for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option in help message. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, 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: Tue, 18 Mar 2025 07:27:09 +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 , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Hilton Chain , 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.174228280918282 (code B ref 77093); Tue, 18 Mar 2025 07:27:09 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:49 +0000 Received: from localhost ([127.0.0.1]:35927 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLb-0004ka-L1 for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:48 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:49384) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKt-0004dY-Rh for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:05 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282762; 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=0gATDkYY9+HlIpSIiMsJydmF48/8/FeFvqFI8MW5iOs=; b=Z8Id8bH3uHeakn/XgrZBY0RiQc0sR+UhzeaAdHmCSSj0fjX3U7hHXPsWVLSKuy5FdHCJvA sVs3DeyVVSBF6px0UqfC2jyiouYmERiQRGkOL2EVEDLWT712V5KdP9NxG9PW8rRPWmqyyQ 2RHAf7uPNmDs+CTNLk1u6F89H1hlYGkBHV/To0axjO7psJ8eVqstGRSRbBBsruhnpEn55j 5Xs/u+JFxcAKFjikskkq8/YfFuQ6go2qDMganbMN03Qg+Le8re1yi8/sHvUPLshDd13VyK WOwduHmUW/4ZivH+C2/G4OVqLGoyEGGysfzl9AnzJv+5eSZiAIpqY9T555khQQ== Date: Tue, 18 Mar 2025 15:24:22 +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 Tue Mar 18 07:24:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40317 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 0CFBF27BBEA; Tue, 18 Mar 2025 07:28: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 CE5E327BBE2 for ; Tue, 18 Mar 2025 07:28:08 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRMf-0007od-Jg; Tue, 18 Mar 2025 03:27:57 -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 1tuRMK-0007eW-NT for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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 1tuRM3-0001Ud-E4; Tue, 18 Mar 2025 03:27: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=q8EtGgJNAcVCCAJm1iKNtDwPxS31GnBy41AJ8jW1jdQ=; b=HTTkxUPZhZURZZdJTlgI1WmnUCjQhkjAU21UJBUsmRef+I8yJK3bOMLBokj9qVirchvbUaA6QaM/mF0usCec33Zt5VIMrMnbZBy+pLxrY8TN7jRHMd6hEPYtD/aHq9YNFW9HOIuUkWfxQKCddXeZ6Meufrg8LpraC4R89++EAbTCcp905ny1MceWhRE6BJmJ27MqGTJnVNe+7pGwLFDEborDYwZDybY4Rf0tg1FOGIi27aqkUYt6mQ5aB7AV4dtWmKT9uaD7b/ePjcX5//ppDDpbd9EufIreKaHPqQETQ+KGuY+p6lZlPRpEWo4VRouNkAaq4eN9y1rCvkVCG1pDmg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRM0-0004pv-CA; Tue, 18 Mar 2025 03:27:12 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 10/18] scripts: import: Add two newlines for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, 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: Tue, 18 Mar 2025 07:27:12 +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 , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Hilton Chain , 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.174228281018308 (code B ref 77093); Tue, 18 Mar 2025 07:27:12 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:50 +0000 Received: from localhost ([127.0.0.1]:35931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLe-0004l7-Ei for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:50 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:60898) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRKx-0004eH-0H for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:08 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282765; 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=q8EtGgJNAcVCCAJm1iKNtDwPxS31GnBy41AJ8jW1jdQ=; b=OjA7pfqCMaKy+OtktgkAcdABZnhPHIF0q3dfH1mYIae3oAQEQ5GT7szzq1PwaDt8Gz71o/ vcraSMatvQdCqVZgU01ETOLP2iMl34asf+hnrAPO/gtkJled5l/yrhxUErl02/VewcPjxq e+IMy5lW/il5WRnNOgP9GXZOnLya3IFgnfjtXNcnJu/mER+DMpMJsymd/ha41RA1B11C+N Afn0R7Jdj9gpphlQqoL9ZdmGMFUMt7lVTVn2Rrvxbe1NICcKw2yimmP8arjV4+fXfMfGcK xvmQffR1lpk2JXiIwz7RYXe2dbZ26PHGW8nmAWWmakVxcul7HCZmCsXfo8GVnQ== Date: Tue, 18 Mar 2025 15:24:23 +0800 Message-ID: <4e38cd180a457bcd8ca56b6a6ad58042cef81014.1742281797.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 Tue Mar 18 07:24:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40320 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 29CC427BBEA; Tue, 18 Mar 2025 07:28:37 +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 92E7827BBE2 for ; Tue, 18 Mar 2025 07:28:36 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRNK-0008EI-HG; Tue, 18 Mar 2025 03:28:35 -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 1tuRML-0007er-BQ for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:37 -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 1tuRM4-0001Uh-3F; Tue, 18 Mar 2025 03:27: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=M8h4BLqf5Sizq/UMmmhN+z7UiKyrXITYFZKJnhlvF90=; b=jSieWWlGR7P8EcB5Cp/gKQGUmJB2lVZgAWNenL9FQgmMbTQEGilddMec6aLtro31s+11PcoDo59HED+AbvUrVyovbLAFVYPDsD82kArgkFBTt1CgUXEUp/A1/ATJUNMn3V3Igxj61FnuPRZT+YzMErVz7QQtVw0MHx5QYzVRjmPHW1KbViYZczbapgTXMZoP+TwTKxwYq6UM1N8TvsAQhGzrVitcvWrB2WbVQIVdY1gv3R7iSIivJTtgXueOmGDjFpJb1xMr1Cki/OyNX9bsnzOkM1teXRLONyE3IhVpsMFnUVAWF9mQmVNAq5KYVBpVzruTvSJX/6a0PkrkJzQb0Q==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRLz-0004pm-3H; Tue, 18 Mar 2025 03:27:11 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 11/18] scripts: import: Support expressions defined by 'define. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, 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: Tue, 18 Mar 2025 07:27:10 +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 , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Hilton Chain , 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.174228281018301 (code B ref 77093); Tue, 18 Mar 2025 07:27:10 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:50 +0000 Received: from localhost ([127.0.0.1]:35929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLc-0004kp-HZ for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:50 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:49398) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRL0-0004fO-Cl for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:10 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282769; 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=+/srC+Epo38ycQfk6D22nsIOCLinapf8wmQlHm5t+vg=; b=UmtSNoWHFTnrTp24la7RmU9XCpsJiYfTB13simxF3whRInNcCy063jnijP9R53SaFlQ43h BX5Y3xW1xFSt1wPTDQkkMHxWMawC79D1KhYfZymv5v+ui0ilAGkgJkudwU0V29Ftg8aqAI 0+FiTBO8ZmTtVxiWR5tI1DZ4dB2yzr2WiUm8RQQyyex0Lvz/Wwhavvlyi05Z7SbBJGvCBI OJ1oYW+iajrJTZfbCZj4Jv2KMZdqXv3MQu/nimPSszdq2wHxlt9GwJqao8b1+bsmc7qNgE yufa+KHuCrO5hbxq1hwqr4e20EaoyOgcdQaW2BuxtgN2yTRkWT6WCkABj+MXyg== Date: Tue, 18 Mar 2025 15:24:24 +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/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 | 20 +++++++++++++++----- guix/utils.scm | 27 +++++++++++++++++++-------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index 58a84d0db7..aaa3d26673 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,20 @@ (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* ((definer? + (cut member + <> + `(,@(if (member importer '("crate")) + '(define) + '()) + define-public))) + (find-and-insert (lambda (expr) (match expr - (('define-public term _ ...) + (((? definer? definer) term _ ...) (let ((source-properties (find-definition-insertion-location - file term))) + file term #:definer definer))) (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..77ec6d992a 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,34 @@ (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 (definer 'define-public) + (pred string=)) + "Search in FILE for a top-level definition defined by DEFINER with defined +term comparing to TERM through PRED. Return the location if PRED returns #t, +or #f otherwise." + (let ((search-term (symbol->string term)) + (definer? (cut eq? definer <>))) (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)) + (((? definer?) 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 (definer 'define-public)) + "Search in FILE for a top-level definition defined by DEFINER with defined +term alphabetically succeeds TERM. Return the location if found, or #f +otherwise." + (find-definition-location file term #:definer definer #:pred string>)) + ;;; ;;; Keyword arguments. From patchwork Tue Mar 18 07:24:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40316 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 8E72827BBEA; Tue, 18 Mar 2025 07:27: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 4F8E827BBE9 for ; Tue, 18 Mar 2025 07:27:59 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRMR-0007jT-H7; Tue, 18 Mar 2025 03:27:40 -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 1tuRMK-0007ec-Q4 for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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 1tuRM3-0001Ue-I5; Tue, 18 Mar 2025 03:27: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=7zUDax8dr2TIcICcWgGAsxmJXQ6OKJhMMpRzidbbTyg=; b=X2JW6TEFpE8E23tQ7yjhdJQkLvt14qy7GttmkbLGP9j85Y1YzoPj+ntQiaDBMAX1SJISHkdQmq+x92YApv98FpXyVYNZvBWGu8B25me8mhSHT48viGAm/AggYQS7vCTm+HBGZQS6RdRspQKNsih3+fkCNZJxG3eA1E2f/gYPbel/FxR3Z0EHriw2IhmF3YRNSoqJuHbmdqAxxWR9o6wZqauiJh7UTYtwuzQPgM71/06NO6IcKEJjBOr9xVoWqHbYhNe+u0VDK8Or1iekxT14e5beQa+X6PKxME4lQMhFrliiAJDY3tDGYqXaj2PIQsbTJJfIXrdyBYCRlttJg4iBWQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRM0-0004q4-RV; Tue, 18 Mar 2025 03:27:12 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 12/18] scripts: import: Pass "--insert" to importers. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, 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: Tue, 18 Mar 2025 07:27:12 +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 , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Hilton Chain , 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.174228281118315 (code B ref 77093); Tue, 18 Mar 2025 07:27:12 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:51 +0000 Received: from localhost ([127.0.0.1]:35933 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLe-0004lF-RN for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:51 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:51942) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRL4-0004fj-KB for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:15 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282773; 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=CNgyHv90mI9Vh7ZD/xKVMWo0WFpglx6Sc5wNnUT5ayI=; b=U23p4hCHt0uVFByDj0ErM+NyiTE66vt+0R3esVq8MMPhesHF5mRcxqYQ6YCsn44bc7komk lMwPHOOf8ueML9/LcFVwEnm2IRU8k4yElZB8aboKXDl0vFUI/jkMU7aILp7gOK+DMSfoy8 4KyP6jiiJQFmHYEXoDgF6ih6saGqD+styXEx1gzGo+xrZbovOkozznuKQIRKeI3CehndMu +dl7AnSohvu//ZVnMSpMtPgwx1kkLnQMaRFYHWL85GDA9peIyWcIyXSt0BR/wn0S6iaegz dhESGopEkwOUGzzCKv1AjN6f51ID0I03z82pBfWWGV46a71r+E1a6tsGcvVwtg== Date: Tue, 18 Mar 2025 15:24:25 +0800 Message-ID: <64fd1ae561f6d188d599c54fe57710caabacf759.1742281797.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 aaa3d26673..1b2c35f3b1 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))))) ;;; @@ -141,7 +147,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 Tue Mar 18 07:24:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40319 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 01D2327BBEA; Tue, 18 Mar 2025 07:28:29 +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 BEFEC27BBE2 for ; Tue, 18 Mar 2025 07:28:28 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRMl-0007t1-8b; Tue, 18 Mar 2025 03:28:01 -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 1tuRMK-0007ee-QA for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:37 -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 1tuRM2-0001UR-Cr; Tue, 18 Mar 2025 03:27: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=5qQlcUDJKcIJRSsAYETyiYSl2VuOHkW+jrIWbdq138k=; b=nuc+InZ2IVP0i/KFgUc01D4zfI9LE2fb6KQJxy++/BxLmqlZB5hnajCUVoarkkfB+8xvej2XatXt3+WRH3QWRIIx/ojyOLe9nLOOyfqFzJuVW02Y2TFwcy3D1MlOOxNUjFiXzRhdWiVB+lUkL1IoB1K5iB4OB/pkRY+cDijy6NAhHfCwu3CCe4l4X7vyLGH8XQG0rPL4K8Z1G8Nd0/yNWSVLcp4HNj2BgXwUfialHdySIwgv1Rp3ZQIaO256zc03uR+ow8fjP4PUr07pPnNAHMjhRUMNSsjPpoGjiduXWf7rg3zmqnQhoEFoKyxixA7So8i/zYsXWuvYMZnnoSvDEA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRM2-0004qQ-12; Tue, 18 Mar 2025 03:27:14 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 13/18] scripts: import: Skip existing definition for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, 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: Tue, 18 Mar 2025 07:27: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: Hilton Chain , Hilton Chain , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Hilton Chain , 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.174228281218332 (code B ref 77093); Tue, 18 Mar 2025 07:27:13 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:52 +0000 Received: from localhost ([127.0.0.1]:35935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLf-0004lN-8r for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:52 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:45406) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRL7-0004fy-QF for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:18 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282776; 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=5qQlcUDJKcIJRSsAYETyiYSl2VuOHkW+jrIWbdq138k=; b=ShrXe/vJRG+8s58sUY0py4enWpGLq3+Sb07jkBahF46m19P95MuG0QfI6wAHmWUBoXjV3D oeFp0nETZLfXmB9lFhN392MzDe8AXVYJKLH/PAZHzMbQVkV9C1c8n22tzMQ7m92JYsTKuH H9VCcK2L412UJ896YHRF8nrKXwrpsBKg21028TZUMCEkXXLK+CinC2fUV76pVOSH+7RLSx g7jvHagqUSlwHHG8X+jSZJ3CS68CwzxhuCJR43TKlOkiuBOKqeLp0ibrOdtOhjtpoox/2M TaBlth5Qpgvd58JqRKhpJkln14ziNtGGwxQ2snl2Hur3hRmI/YUoMwMiHBe8tg== Date: Tue, 18 Mar 2025 15:24:26 +0800 Message-ID: <3ee5a87b5fafdd42516307d25f3dea62144781d4.1742281797.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.scm (guix-import): Skip existing definition for ‘--insert’ option. Change-Id: I2c4242669f974b263a018ab0cf56538bd7c81d06 --- guix/scripts/import.scm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index 1b2c35f3b1..d8e1ed3e6f 100644 --- a/guix/scripts/import.scm +++ b/guix/scripts/import.scm @@ -137,16 +137,18 @@ (define-command (guix-import . args) (lambda (expr) (match expr (((? definer? definer) term _ ...) - (let ((source-properties - (find-definition-insertion-location + ;; Skip existing definition. + (unless (find-definition-location file term #:definer definer) + (let ((source-properties + (find-definition-insertion-location file term #:definer definer))) - (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))))))))) + (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 Tue Mar 18 07:24: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: 40315 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 5B1E827BBE2; Tue, 18 Mar 2025 07:27: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=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 CA70D27BBE9 for ; Tue, 18 Mar 2025 07:27:48 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRMT-0007jq-BC; Tue, 18 Mar 2025 03:27:41 -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 1tuRMK-0007eV-Mh for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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 1tuRM5-0001Um-Lq for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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=s7xZt4cQLBfnnSWkcwL6+4CaT6WsRgs4zxV7rKgM8RE=; b=OrjGj9Dje65tmDcbMpHPg3Dn+IkfWrE1WDGKOzkHdsauQzj99dk0nsvARCCEouLH7K8GmKDpfVsE+Yz0C6z4kqpmGwCgSqtGmVfw2cb93nhQvUD0eZj/fsnAORY/FPpDn4H/FgZSoWo0EFm/9kt2nOLAjZ2xBQNtVu/zgBj6UQ7FnwEynXaHSqp6wQ26eMx1VmK2B0leu9f9XEn/CQv3l4VN4RMu/G2C9gV65BfZBUxfHX69h+A/+jPwh/CF0exbLlSCcnD7tmgtZH9j7hgU2S0tU4PHdOHw7Q8WXF6uotyPL7kE/QcE3IVKKuC7IhVKmF3zj4EH0PBl23TOqY+mwQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRM3-0004qy-Lo; Tue, 18 Mar 2025 03:27:15 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 14/18] import: crate: crate-name->package-name: Move to (guix build-system cargo). Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:27: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 , Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228281318356 (code B ref 77093); Tue, 18 Mar 2025 07:27:15 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:53 +0000 Received: from localhost ([127.0.0.1]:35937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLg-0004ld-4Q for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:53 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:51946) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRLB-0004ga-M4 for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:22 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282780; 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=geOOtBEsBNx2ONmmiPLL/kMPcijDpsDJ3ulRZK3Fa/w=; b=QoSgfQxe8jPxOCzGdRxFZC7CqABcXmrCV2O931V0FaSaosD7lcXjtzGcj3EyBxNPnRB1mk l4hEYrvRNU6EDgGgbt6lQ8lLuVvJBQRLvWPcZmgDlKbzpxFjr2j/7pZ5UszNhmygj/uDcj w09SIdNT/RKta2VPK68cAeD0SvDxFWV9Cm+5dtJj8zfAaMr8OOX4RsuUO/c/IhOKIk4cI+ Pe872gbJI61o5yMzibn7hAyAsKKbD1VnOjNWhe6E7HTfoInYoS/58KnGAJkds/QZG6f3+e 8S9qtXo/z8YJE1qEnFQ1RHKRrY2U2Nmm3HyePNz62Oip8q+OZ79njce66WgWLA== Date: Tue, 18 Mar 2025 15:24:27 +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/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 Tue Mar 18 07:24:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40322 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 375D627BBE2; Tue, 18 Mar 2025 07:28:27 +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 524DA27BBEA for ; Tue, 18 Mar 2025 07:28:25 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRMl-0007p2-4Q; Tue, 18 Mar 2025 03:27:59 -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 1tuRMK-0007eX-PM for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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 1tuRM8-0001VB-1U for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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=E7TeCgPqwH4icNChpfIeEaQGrQC116WRgTGHhGN25w0=; b=oF6eZUlXpSwVcbv5cnqNS+5movoih7r6o1qtive3oNH3nhPaJOKgBq0perw8Byhf+fxJUb6d1DF809I54p2cfFarLh0M5BSg52d2nrMBQYSk20RXO5SSiEJw0/wymSZpj2TeRN301VinVZ+6VujhH2+n52+9v3mOPIqiSVvpr9Y88BMbePpS8vTha5QGdQ6JPQnPXdHOdJemNwwdEP3VSDbdcNg4Sj1pmUZ/w4hxm7NLahYx1GIi+XqiGWdI4XQ0LeXnMizECciBrvTr+eRbLAsw9FAAzb1h0CA7YgdH57M9wBOfbcyrGFvKYBzL4U4SWPbFRtg3mvaOj8MahGsduQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRM5-0004rG-AS; Tue, 18 Mar 2025 03:27:17 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 15/18] build-system: cargo: Add =?utf-8?b?4oCYY2FyZ28taW5wdXRz4oCZLg==?= Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:27:17 +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 , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228281618375 (code B ref 77093); Tue, 18 Mar 2025 07:27:17 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:56 +0000 Received: from localhost ([127.0.0.1]:35939 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLh-0004lw-7F for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:55 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:39294) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRLF-0004h6-Hx for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:27 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282784; 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=cM5fQi5K4lwBJ78ozo82ZN0cgMrgMJeJ69wt4C0ZkjI=; b=ghbKCKSAFK4MEuFnbA37pvPg7pmwqGym4vbGYUPaf04El46EQlwze78RJMbeABo91oyYEL pjIIA0AiWW35Sjgmavvvjet2QBHQpvWMHPMwGzyQAFEBiZuBq0rDEjIBpLXSqGzXOKUAUK AeZR4Tt5MDxFcomZ8tlyV1c4Xoax0Rg5MEriWIk9ob2AnKpf3xrffNUu3cTvZThWQPu8LN KqpCWf12EbF55vpbxZ3DyUbCq1E5zMkD7JqVODO8zH4ZxYYDmihmsFouzhfO4IP1YXSoGG JDuI+oArt3C7wFTeKBXW5xZn0gszfOTO95T9Eq7EczZsU70HQMspG6wfI3+9sA== Date: Tue, 18 Mar 2025 15:24:28 +0800 Message-ID: <03e00920c3108fb1b26f528e64f4ca8d77780baf.1742281797.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/cleanup-crates.sh: New file. * etc/teams/rust/rust-crates.tmpl: New file. Change-Id: I2f2d705a3e376ed3c646f31b824052a2278d4fb3 --- etc/teams/rust/cleanup-crates.sh | 38 +++++++++++++++++++++++++++ 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 | 45 +++++++++++++++++++++++++++++++- guix/import/crate.scm | 2 +- 7 files changed, 198 insertions(+), 2 deletions(-) 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/cleanup-crates.sh b/etc/teams/rust/cleanup-crates.sh new file mode 100755 index 0000000000..cd4c2462b9 --- /dev/null +++ b/etc/teams/rust/cleanup-crates.sh @@ -0,0 +1,38 @@ +#!/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 #:definer '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..47d4f10969 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,46 @@ (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 NAME, resolve input list 'NAME-cargo-inputs' in CRATES-MODULE, return +its copy with #f removed and symbols resolved to variables defined in +SOURCES-MODULE, if the 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: no change. + (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 Tue Mar 18 07:24:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40318 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 1EF4427BBEC; Tue, 18 Mar 2025 07:28:26 +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 4E28427BBE2 for ; Tue, 18 Mar 2025 07:28:25 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRN1-000814-Ku; Tue, 18 Mar 2025 03:28: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 1tuRMK-0007eU-Mc for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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 1tuRM7-0001V8-Vr for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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=XTHL2+Dc8FXC/fJ5wbbmDsUrkjMdqma1fsZgBXba7iQ=; b=duCMzPZNm8NjX8hxJ51bohFZTro+MHmIqPmsRqetcBYPYfBjBxw3djZA4JH/akmtlimSwGMHLe75qO0B88fBBUaDpqPgn1yIfVfoa6LCKBwtlI83+8QHFK13YJ7wL/u/GU9d/Dvgi0yLpx7Rp8SD5J8csKqSHIg/n6L5uWv/pygf7hOc5zosUgT9hG2gffZRSOrnfb4x3ahT1+R8DNI8W1L/f4ucSPe/dxo801YEb75cRRV0AOkKbqRlL73/EFO7xOOGbryDPSHbFeY26hSDFM3NaKejD9DZO/SKNqZYMBZpYx6M0iM5ZYtYZeaGiN9QRgfD2y+aNMDArelk44PGww==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRM5-0004rQ-Pz; Tue, 18 Mar 2025 03:27:17 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 16/18] import: crate: Add Cargo.lock parser. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, divya@subvertising.org, efraim@flashner.co.il, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:27:17 +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 , Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228281918416 (code B ref 77093); Tue, 18 Mar 2025 07:27:17 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:26:59 +0000 Received: from localhost ([127.0.0.1]:35941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLk-0004mJ-1i for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:58 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:39306) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRLK-0004i6-1a for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:32 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282788; 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=cf59W6KffTl6mWAaIPklzAyqdmp+Dj1qOd4/4qF6zPY=; b=hLlVxc9xVcS2+roUwi72g3u6l0rBij5Idy2XgSj/VuCjPDCQ8ZFBw4qtMTv+G8zwRVA3uz 5gO2ALbv6Z2qWvfj0mS+paqlJ/bbOIxXU5/E+tI2DxicSgptbXA30ZsY+DMOoQ3SyISg32 nkoTHAd1CS8n3u3NPk+um0+6hV9UdG+pKd+qD7s7xh/JqyddEKuofH9hoha/+v9AIJX8ws 3KihWjq5E3SCoD82xO4IUann9E6ZtWAZocMExgECaK3uSJ/YlSY1zcR3FjMAS/tJsseSOj 47iOQ9y7Q4gMjrenf9iTc35GXUkbBem54EWIlNkYl6ZP3WPWHWHUhib9MDoCfA== Date: Tue, 18 Mar 2025 15:24:29 +0800 Message-ID: <62e0504e8c284b261d8d59b9b2ce73a64c279e71.1742281797.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. * 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 + guix/import/crate.scm | 78 +++++++++++++++++++++++ guix/import/crate/cargo-lock.scm | 105 +++++++++++++++++++++++++++++++ 3 files changed, 184 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/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 Tue Mar 18 07:24: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: 40321 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 F0F2927BBEA; Tue, 18 Mar 2025 07:28: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=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 4253027BBE2 for ; Tue, 18 Mar 2025 07:28:38 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRNM-0008OR-HD; Tue, 18 Mar 2025 03:28: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 1tuRMK-0007eY-PN for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27: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 1tuRM8-0001VD-MU; Tue, 18 Mar 2025 03:27: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=gECdcOM6niC5sDLVOig/OCCqU3itHV+hZIKHx5csZmo=; b=EhjKLD8W8ZVJyunaHI1b136XtNV6nLODMM8akrWmaMPTnrkz1cLj01UkO4YpnV/HQz6hTGeAHu5bz2sJdZ3OZfE6H3o92hG32yCQKGlFotebIFZyFEoIs4/Dt8/AI6dllFphVApHTavQP7Hcx4oGz+Tt7T48YSJCCYGJO69Pd+VwpySoeazHOQ9pMUsBMSnwf8wVCk06JVxZVcL9QDC889PuhCWfva8T5y9RbopP1RxiCioPYUZhqofBUXrDY/tTmmgVm8BaproAAWWhAbAcn67QTMKxW2VecUmQRr6+rIvBSfve3SXh2m3xf9ujN1Z1A8NNDT3q3qqXVMomhU3PBg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRM6-0004rY-9H; Tue, 18 Mar 2025 03:27:18 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 17/18] import: crate: Add =?utf-8?b?4oCYLS1sb2NrZmlsZeKAmQ==?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, 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: Tue, 18 Mar 2025 07:27: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 , 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: 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 Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228282218450 (code B ref 77093); Tue, 18 Mar 2025 07:27:18 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:27:02 +0000 Received: from localhost ([127.0.0.1]:35943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLm-0004mx-SF for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:27:01 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:45516) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRLO-0004ik-7q for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:36 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282792; 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=tzUPHMCKd4bCn/uzXPa7fW2nAcwVEJtWe9fm8dlRU+w=; b=GWS75zlZYl8Q9y7VbyfJHwAbss9MaXO1qCTFg7H9vxaPpnd1u0BOmzVlUunrroTqH788Ad fcRpXnjRQgrrfI6vTGX9djLe7st7gSZYc3pU91VNan+wJdQhlQs72KDaQOIuBjIIl3lyqv gUqf5qSo+UzJdRIx0uXCrqISo5saBwQbo5tyyhulf9LP0++kllzegDTfS0ekBFRcx4LjdJ RGbzi4ddytBFRuErfLGmXf2XgQ04q6DO6mPepxCPHqOkCZaGreV84ma5GfPA5WwdprnC6f wy0vBB7pPIR/8fU8xTFBQ9BBM1ZJFyPiIk+q/uJUZqk0qzPzJvXNpoQ7dvC/VQ== Date: Tue, 18 Mar 2025 15:24:30 +0800 Message-ID: <9e07061c7a9a4dacaa437acca4d951047c599573.1742281797.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 | 15 ++++++ guix/scripts/import/crate.scm | 58 +++++++++++++++++++---- tests/crate.scm | 88 +++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 10 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index c20e1d7f9c..029c8cf59c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14703,6 +14703,21 @@ 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, importer will ignore other +options and won't output package definitions, instead generating source +definition 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 package's base @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..d46f753f9c 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-utils-" (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 Tue Mar 18 07:24:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40323 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 6D23727BBEA; Tue, 18 Mar 2025 07:28:55 +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 CA15127BBE2 for ; Tue, 18 Mar 2025 07:28:53 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuRNM-0008KM-7o; Tue, 18 Mar 2025 03:28: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 1tuRMK-0007eZ-Q6 for guix-patches@gnu.org; Tue, 18 Mar 2025 03:27:37 -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 1tuRM7-0001Ux-Oq; Tue, 18 Mar 2025 03:27: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=4DlctWhdQ7kh3mOvzpuhsSgzVoTDYuMUyORqz81LUTQ=; b=AK24JRCQhqmHG26tKpXw4GNqTrCGTsjn2Nw5UR4ksusVSkF93l7KThoJwHDBdy+W6rgMopOEMxEZXg3RZgzD/KPunDBgIjc1/AXrXzic3COJm+dKO799A1RD2PmYKUAPjhEQe5AHPVeF7urxkY1H2TO7EXWL+hK9PZa0vg1qr7LkAeAaGsNkjKUNXhyWY/QhBvZJkPFzHa7TZzpbQO5X9IV53IJI5AmUObQBKoFl+bcvmZlvdFoQQo2kWSagO6UAT1mtIdPosQm4t+7cad4pKjVehGJZ526PXBSuF+2kVVNR/KkDH68F+CthxZza46EGX8koVMCySk6wbm0A/WeTWw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuRM6-0004rj-Qc; Tue, 18 Mar 2025 03:27:18 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team 18/18] doc: Document lockfile importer based Rust packaging workflow. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 07:27: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 , Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Hilton Chain , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174228282718506 (code B ref 77093); Tue, 18 Mar 2025 07:27:18 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 07:27:07 +0000 Received: from localhost ([127.0.0.1]:35945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuRLq-0004nd-02 for submit@debbugs.gnu.org; Tue, 18 Mar 2025 03:27:06 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:38534) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuRLR-0004jM-KF for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 03:26:41 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742282796; 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=4DlctWhdQ7kh3mOvzpuhsSgzVoTDYuMUyORqz81LUTQ=; b=TmujlmKG6XUibcfxEuOlkQvt1PBYA3QzMYe3QA2flsg4O6n8SldUhei3B3kSfCJ6Oxz2Ug 9+aRJ8Aepe10s3N0CjMFgiwxR2ubotM9wmsyVgtTb5ufaoPi9SobyK5SMWjl0kNO/t/tdm vC7ZdTEh/NsxEtZgQ6d5DYLevvwwsnyJKFw9EdddiojOKO6iLGXSdVfypni3XyATGpOqHE xLiyznkXiEXsQipKy5TIcGPhf2yGH/k6Hk+4AQ7sQsSD5ZDnXI91mFjoy1QdouboqLoLEf kxmK/bewZWJ87oZP9ueqqi8l2+TFpqkgSgWzf4zwjCuEho5grv7LSX/LPjpeyQ== Date: Tue, 18 Mar 2025 15:24:31 +0800 Message-ID: <7ffcf6a3f50491ea953731444de449dfd7cb8d39.1742281797.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. Change-Id: Ic0c6378cf5f5df97d6f8bdd040b486be62c7bddc --- doc/contributing.texi | 415 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 390 insertions(+), 25 deletions(-) diff --git a/doc/contributing.texi b/doc/contributing.texi index ab4f30d54b..e7c5116a3d 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -1600,34 +1600,399 @@ Rust Crates @subsection Rust Crates @cindex rust -Rust programs standing for themselves are named as any other package, using the -lowercase upstream name. +As currently there's no achievable way to reuse Rust packages as pre-compiled +inputs for other packages at a distribution scale, and our previous approach on +making all Rust dependencies as full packages doesn't cope well with Rust +ecosystem thus causing issues on both contribution and maintenance sides, we +have switched to a different packaging model. + +Rust programs (binary crates) and dependencies (library crates) are treated +separately. We put main efforts into programs and only package Rust +dependencies as sources, utilizing automation with manual focus on unbundling +vendored dependencies. The following paragraphs will explain them and give +several examples. + +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 to 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: -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. +@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, crate, @code{--lockfile=@var{file}}}). + +Imported definitions must be checked and have vendored sources unbundled before +contributing to Guix. Naturally, this module serves as a store for both sources +and unbundling strategies. + +This module is managed by Rust team (@pxref{Teams}) to ensure there's always one +version containing all changes from other branches, so that the maintained +version can be used directly in case of merge conflicts, thus coordination is +required for other committers to modify it. + +Guix source ships template @file{etc/teams/rust/rust-crates.tmpl} and cleanup +script @file{etc/teams/rust/cleanup-crates.sh} for this moudle. + +@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 @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. Examples@: +@code{rust-pipewire-for-niri}, @code{rust-pubgrub-for-uv}. +@end enumerate + +Let's demonstrate the packaging workflow by examples, note that package-specific +issues are not involved here. + +In preparation, we'll adding the following packages to our environment: + +@example +guix shell rust rust:cargo cargo-audit cargo-license +@end example + +Example 1: @code{cargo-audit}, which is published on the crates.io Rust package +repository @uref{https://crates.io, crates.io}. + +@enumerate +@item +We can generate a draft definition via the crates.io importer (@pxref{Invoking +guix import, crate}). 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 + +@code{cargo-inputs} is a procedure defined in @code{guix build-system cargo}, +facilitating dependency modification. @code{'cargo-audit} used here must be a +unique identifier, usually same to the program's variable name. + +@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, +@code{license}}). + +@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, @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 +$ 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 in 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 +point the imported definition to a symbol with the same name. + +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 point to it: + +@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 + +Such modifications are processed by @code{cargo-inputs} procedure. + +@code{cargo-inputs} can also be configured by keywoard arguments +@code{#:crates-module} (default: @code{(gnu packages rust-crates)}, module to +resolve imported definitions) and @code{#:sources-module} (default: @code{(gnu +packages rust-sources)}, module to resolve modified symbols), which are useful +to maintain an independent channel. +@end enumerate + +Example 2: @code{niri}, which is not available on crates.io and depends on +development snapshots (also Cargo workspaces in this example). + +@enumerate +@item +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 +in a known working revision. + +To use our packaged development snapshots, it's also necessary to modify +@file{Cargo.toml} in build environment, the substitution pattern is +package-specific. + +@code{cargo-inputs} returns a list, all list operations apply to it too. + +@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 + +@item +@code{niri} also has Cargo workspace dependencies. When packaging a Cargo +workspace, build 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 +@end enumerate + +Example 3: @code{fish}, which combines two build systems. + +@enumerate +@item +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 +@end enumerate @node Elm Packages