From patchwork Fri Jan 12 15:24:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain GARBAGE X-Patchwork-Id: 58823 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 8DF5F27BBEA; Fri, 12 Jan 2024 15:25:30 +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=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 9333D27BBE2 for ; Fri, 12 Jan 2024 15:25:29 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOJP8-00052R-Sx; Fri, 12 Jan 2024 10:25:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rOJP6-00050x-Nc for guix-patches@gnu.org; Fri, 12 Jan 2024 10:25:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rOJP6-0005n0-3X for guix-patches@gnu.org; Fri, 12 Jan 2024 10:25:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rOJP3-0001ty-TU for guix-patches@gnu.org; Fri, 12 Jan 2024 10:25:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68406] [PATCH core-updates] guix: build: Expand `copy-recursively'. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 12 Jan 2024 15:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68406 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68406@debbugs.gnu.org Cc: Romain GARBAGE X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17050730707261 (code B ref -1); Fri, 12 Jan 2024 15:25:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Jan 2024 15:24:30 +0000 Received: from localhost ([127.0.0.1]:37233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rOJOX-0001t2-SO for submit@debbugs.gnu.org; Fri, 12 Jan 2024 10:24:30 -0500 Received: from lists.gnu.org ([2001:470:142::17]:54826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rOJOU-0001sl-65 for submit@debbugs.gnu.org; Fri, 12 Jan 2024 10:24:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rOJOQ-0004a6-5I for guix-patches@gnu.org; Fri, 12 Jan 2024 10:24:22 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOJOM-0005bF-Jf for guix-patches@gnu.org; Fri, 12 Jan 2024 10:24:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=l98NbHAIy5j/ngFkhXxrEcMLEvDBm0FT7pI4qJ8HBks=; b=ACj6hQwuENlwr38PZVoi6p1VRkt1SU4eqGq3fvbHJCB9IAjTtQK8FyjC 1A0XkpJ9OinuSeDuzTyk6V0KepUf8bS35qIvmMOUTNpBrN0oJ6vQF+B4t DCFZJWNVg4d8xBQO0y4BOS4y0AhpnvGzDKJuVwGMkjbnZAPZywAbzjiRt k=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; spf=None smtp.helo=postmaster@guix-A102.bordeaux.inria.fr Received-SPF: SoftFail (mail2-relais-roc.national.inria.fr: domain of romain.garbage@inria.fr is inclined to not designate 193.50.110.153 as permitted sender) identity=mailfrom; client-ip=193.50.110.153; receiver=mail2-relais-roc.national.inria.fr; envelope-from="romain.garbage@inria.fr"; x-sender="romain.garbage@inria.fr"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 include:mailout.safebrands.com a:basic-mail.safebrands.com a:basic-mail01.safebrands.com a:basic-mail02.safebrands.com ip4:128.93.142.0/24 ip4:192.134.164.0/24 ip4:128.93.162.160 ip4:89.107.174.7 mx ~all" Received-SPF: None (mail2-relais-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@guix-A102.bordeaux.inria.fr) identity=helo; client-ip=193.50.110.153; receiver=mail2-relais-roc.national.inria.fr; envelope-from="romain.garbage@inria.fr"; x-sender="postmaster@guix-A102.bordeaux.inria.fr"; x-conformance=spf_only X-IronPort-AV: E=Sophos;i="6.04,189,1695679200"; d="scan'208";a="146369993" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.153]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2024 16:24:12 +0100 From: Romain GARBAGE Date: Fri, 12 Jan 2024 16:24:04 +0100 Message-ID: <20240112152407.5691-1-romain.garbage@inria.fr> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=192.134.164.83; envelope-from=romain.garbage@inria.fr; helo=mail2-relais-roc.national.inria.fr X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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/utils.scm (copy-recursively): Add `select?' key. Change-Id: Icfe226164bb88dfede58ae24c15a98db9b696c3b Reviewed-by: Maxim Cournoyer --- guix/build/utils.scm | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 2352a627e9..7567eb9e4d 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -430,32 +430,38 @@ (define* (copy-recursively source destination (log (current-output-port)) (follow-symlinks? #f) (copy-file copy-file) - keep-mtime? keep-permissions?) - "Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS? -is true; otherwise, just preserve them. Call COPY-FILE to copy regular files. -When KEEP-MTIME? is true, keep the modification time of the files in SOURCE on -those of DESTINATION. When KEEP-PERMISSIONS? is true, preserve file -permissions. Write verbose output to the LOG port." + keep-mtime? keep-permissions? + (select? (const #t))) + "Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS? is +true; otherwise, just preserve them. Call COPY-FILE to copy regular files. When +KEEP-MTIME? is true, keep the modification time of the files in SOURCE on those of +DESTINATION. When KEEP-PERMISSIONS? is true, preserve file permissions. Write +verbose output to the LOG port. Call (SELECT? FILE STAT) for each entry in source, +where FILE is the entry's absolute file name and STAT is the result of 'lstat' (or +'stat' if FOLLOW-SYMLINKS? is true); exclude entries for which SELECT? does not +return true." (define strip-source (let ((len (string-length source))) (lambda (file) (substring file len)))) - (file-system-fold (const #t) ; enter? + (file-system-fold (lambda (file stat result) ; enter? + (select? file stat)) (lambda (file stat result) ; leaf (let ((dest (string-append destination (strip-source file)))) - (format log "`~a' -> `~a'~%" file dest) - (case (stat:type stat) - ((symlink) - (let ((target (readlink file))) - (symlink target dest))) - (else - (copy-file file dest) - (when keep-permissions? - (chmod dest (stat:perms stat))))) - (when keep-mtime? - (set-file-time dest stat)))) + (when (select? file stat) + (format log "`~a' -> `~a'~%" file dest) + (case (stat:type stat) + ((symlink) + (let ((target (readlink file))) + (symlink target dest))) + (else + (copy-file file dest) + (when keep-permissions? + (chmod dest (stat:perms stat))))) + (when keep-mtime? + (set-file-time dest stat))))) (lambda (dir stat result) ; down (let ((target (string-append destination (strip-source dir))))