From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id QEJnGxuM019CDAAA0tVLHw (envelope-from ) for ; Fri, 11 Dec 2020 15:11:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QBA0FxuM01/WTQAAbx9fmQ (envelope-from ) for ; Fri, 11 Dec 2020 15:11:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E15289403CA for ; Fri, 11 Dec 2020 15:11:22 +0000 (UTC) Received: from localhost ([::1]:34560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knk4n-00066C-Qs for larch@yhetil.org; Fri, 11 Dec 2020 10:11:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knk4U-0005iK-Kd for bug-guix@gnu.org; Fri, 11 Dec 2020 10:11:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:59308) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1knk4U-0001BI-CK for bug-guix@gnu.org; Fri, 11 Dec 2020 10:11:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1knk4U-0007nP-88 for bug-guix@gnu.org; Fri, 11 Dec 2020 10:11:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#44760: [PATCH 10/15] guix system: 'init' copies, resets timestamps, and deduplicates at once. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 11 Dec 2020 15:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44760 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 44760@debbugs.gnu.org Received: via spool by 44760-submit@debbugs.gnu.org id=B44760.160769941329833 (code B ref 44760); Fri, 11 Dec 2020 15:11:02 +0000 Received: (at 44760) by debbugs.gnu.org; 11 Dec 2020 15:10:13 +0000 Received: from localhost ([127.0.0.1]:42602 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1knk3h-0007l0-7J for submit@debbugs.gnu.org; Fri, 11 Dec 2020 10:10:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1knk3f-0007kZ-Jy for 44760@debbugs.gnu.org; Fri, 11 Dec 2020 10:10:11 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47541) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knk3Y-0000dY-Eh; Fri, 11 Dec 2020 10:10:04 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=59326 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1knk3X-0004Vl-0F; Fri, 11 Dec 2020 10:10:03 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 11 Dec 2020 16:09:46 +0100 Message-Id: <20201211150951.18508-1-ludo@gnu.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <87h7pkffzy.fsf@inria.fr> References: <87h7pkffzy.fsf@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 2.20 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: E15289403CA X-Spam-Score: 2.20 X-Migadu-Scanner: scn1.migadu.com X-TUID: hsiHc+gQXk6B Partly fixes . * guix/build/store-copy.scm (copy-store-item): New procedure. (populate-store): Use it instead of the inline 'copy-recursively' call. * guix/scripts/system.scm (copy-item): Likewise. Pass #:reset-timestamps? and #:deduplicate? to 'register-path'. --- guix/build/store-copy.scm | 31 +++++++++++++++++++++---------- guix/scripts/system.scm | 11 ++++++++--- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/guix/build/store-copy.scm b/guix/build/store-copy.scm index 7f0672cd9d..01e1f41870 100644 --- a/guix/build/store-copy.scm +++ b/guix/build/store-copy.scm @@ -38,6 +38,7 @@ file-size closure-size + copy-store-item populate-store)) ;;; Commentary: @@ -242,6 +243,24 @@ permissions. Write verbose output to the LOG port." stat lstat))) +(define* (copy-store-item item target + #:key + (deduplicate? #t) + (log-port (%make-void-port "w"))) + "Copy ITEM, a store item, to the store under TARGET, the target root +directory. When DEDUPLICATE? is true, deduplicate it within TARGET." + (define store + (string-append target (%store-directory))) + + (copy-recursively item (string-append target item) + #:keep-mtime? #t + #:keep-permissions? #t + #:copy-file + (if deduplicate? + (cut copy-file/deduplicate <> <> #:store store) + copy-file) + #:log log-port)) + (define* (populate-store reference-graphs target #:key (deduplicate? #t) @@ -273,16 +292,8 @@ regular files as they are copied to TARGET." (call-with-progress-reporter progress (lambda (report) (for-each (lambda (thing) - (copy-recursively thing - (string-append target thing) - #:keep-mtime? #t - #:keep-permissions? #t - #:copy-file - (if deduplicate? - (cut copy-file/deduplicate <> <> - #:store store) - copy-file) - #:log (%make-void-port "w")) + (copy-store-item thing target + #:deduplicate? deduplicate?) (report)) things))))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index db80e0be8f..c08929066b 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -30,6 +30,7 @@ #:use-module ((guix status) #:select (with-status-verbosity)) #:use-module (guix store) #:autoload (guix store database) (register-path) + #:autoload (guix build store-copy) (copy-store-item) #:use-module (guix describe) #:use-module (guix grafts) #:use-module (guix gexp) @@ -147,8 +148,8 @@ REFERENCES as its set of references." #:directories? #t)) (delete-file-recursively dest)) - (copy-recursively item dest - #:log (%make-void-port "w")) + (copy-store-item item target + #:deduplicate? #t) ;; Register ITEM; as a side-effect, it resets timestamps, etc. ;; Explicitly use "TARGET/var/guix" as the state directory, to avoid @@ -157,7 +158,11 @@ REFERENCES as its set of references." (unless (register-path item #:prefix target #:state-directory state - #:references references) + #:references references + + ;; Those are taken care of by 'copy-store-item'. + #:reset-timestamps? #f + #:deduplicate? #f) (leave (G_ "failed to register '~a' under '~a'~%") item target)))) -- 2.29.2