From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id aE24I2rZRWS9IAEASxT56A (envelope-from ) for ; Mon, 24 Apr 2023 03:20:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 8Lm+I2rZRWSTlwAA9RJhRA (envelope-from ) for ; Mon, 24 Apr 2023 03:20:42 +0200 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 6C31F47B37 for ; Mon, 24 Apr 2023 03:20:42 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqks8-00009h-OS; Sun, 23 Apr 2023 21:20:05 -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 1pqks7-00009I-0V for guix-patches@gnu.org; Sun, 23 Apr 2023 21:20:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqks6-0006wL-KZ for guix-patches@gnu.org; Sun, 23 Apr 2023 21:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pqks6-0000IL-GN for guix-patches@gnu.org; Sun, 23 Apr 2023 21:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63044] [PATCH 2/4] guix: utils: add `change-file-timestamps-recursively' procedure Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 24 Apr 2023 01:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63044 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63044@debbugs.gnu.org Cc: Brian Cully Received: via spool by 63044-submit@debbugs.gnu.org id=B63044.16822991581028 (code B ref 63044); Mon, 24 Apr 2023 01:20:02 +0000 Received: (at 63044) by debbugs.gnu.org; 24 Apr 2023 01:19:18 +0000 Received: from localhost ([127.0.0.1]:47183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqkrN-0000GQ-SY for submit@debbugs.gnu.org; Sun, 23 Apr 2023 21:19:18 -0400 Received: from coleridge.kublai.com ([166.84.7.167]:63715 helo=mail.spork.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqkrK-0000Fx-WB for 63044@debbugs.gnu.org; Sun, 23 Apr 2023 21:19:16 -0400 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id BD0688B3D; Sun, 23 Apr 2023 21:19:14 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1682299154; bh=3Y4Xzzwrs4g2xJo3BdGXHtJDN/wZjoiNanoPJ/hrwEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZCouj91mc+/K2JPLlvBzVz6yOFbZLjrFedjQXSjH5LIWrmNn6vO1GTaAh1CXjMkwW JJpe7CmdiT3tO0+ghLRdi1Mi4A6dSFSShhr3G3BsC3ap0rZdyPoCCXji8CvmD46zoO 73rnmZp6I9F6KETnadfYa5cKriu0HRJHs+3bsbNQ= Date: Sun, 23 Apr 2023 21:18:57 -0400 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , Reply-to: Brian Cully X-ACL-Warn: , Brian Cully via Guix-patches From: Brian Cully via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1682299242; a=rsa-sha256; cv=none; b=XFWgzBX4hYsBDuE7GTIw3RgHcPW868Gew7NtXu7lo1d8X83+UAwulduPXTInvEsMi8s11w /wrtS7H9nQA9T4qnpUYJBzHtUXJKF1EWC9ypOHFZBtPTyPOG2nI4YfkAR+7brsJGpsnlNB rTKp+WODGzai70j/DmA/hglWUF08HItpVtFbhmfvtoyZs6za0DL+XRB6hVFXOhjzrSnjpl tsnN83ybOik1Wx4mbabMXG+1B9XUNy7zJnIfb4i1TFCoru1anws6WDUAi54Qv+H+2kIIYi 4pjlEZZk6mbBZTSISnVfFd0Wk6N/2mX+JXaeH7LkuyS652EULP6A111ulkvrmA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=spork.org header.s=dkim header.b=ZCouj91m; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1682299242; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Y302cmXHjTgfjfhoNzZAaGD0f+SFqkr/90U07M8RSIc=; b=hR2DGaX6u+ag4ai6LakA+vWfrmEJYaRbT97TFMG0j7QPWMRp4jH1WAP+hH1vYwfG2yBQyK Te2N+lhU1Q3bTcd86Bb7g8EhEUAtCnruA8fSZ+/pl0Bz2fqeHhLcE4DYuP1ndwTgmidiDw ArHz60nXyluwqNxKccyp2PoZMU9JyQPueUuvYUFykY1iW06Cc2omRVIoF9YBKRvBzv2o12 PTkHz00wV3E7W4NY2djwt573VFVRpJYPYp79UDqVq9Wf2KZ3a5L6/dtw6cNjI0WvFUKcoE CbDSj6KZq92RTK0fhSMQEr52Aj3/c5dgbaUji3mwVIAR1B1sYrebq58ASxKOyQ== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=spork.org header.s=dkim header.b=ZCouj91m; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.71 X-Spam-Score: -3.71 X-Migadu-Queue-Id: 6C31F47B37 X-TUID: mnGZBpf8Kzx+ There are some packages which use the zip library in `python-setuptools' which will error and fail to build if it finds files with timestamps before 1980. Create a new procedure which will update the atime and mtime fields of a directory to a date and time specified in UTC. * guix/utils.scm (change-file-timestamps-recursively): new procedure --- guix/utils.scm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/guix/utils.scm b/guix/utils.scm index b9657df292..a6de6a82fb 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -17,6 +17,7 @@ ;;; Copyright © 2022 Denis 'GNUtoo' Carikli ;;; Copyright © 2022 Antero Mejr ;;; Copyright © 2023 Philip McGrath +;;; Copyright © 2023 Brian Cully ;;; ;;; This file is part of GNU Guix. ;;; @@ -42,6 +43,7 @@ (define-module (guix utils) #:use-module (rnrs io ports) ;need 'port-position' etc. #:use-module ((rnrs bytevectors) #:select (bytevector-u8-set!)) #:use-module (guix memoization) + #:use-module (guix modules) #:use-module ((guix build utils) #:select (dump-port mkdir-p delete-file-recursively call-with-temporary-output-file %xz-parallel-args)) @@ -49,6 +51,7 @@ (define-module (guix utils) #:use-module ((guix combinators) #:select (fold2)) #:use-module (guix diagnostics) ;, &error-location, etc. #:use-module (ice-9 format) + #:use-module (ice-9 ftw) #:use-module ((ice-9 iconv) #:prefix iconv:) #:use-module (ice-9 match) #:use-module (ice-9 regex) @@ -134,6 +137,8 @@ (define-module (guix utils) config-directory cache-directory + change-file-timestamps-recursively + readlink* go-to-location edit-expression @@ -156,6 +161,30 @@ (define-module (guix utils) ;;; Environment variables. ;;; +(define (change-file-timestamps-recursively location time) + "Recursively Change the atime and mtime of all files in LOCATION to TIME. + +TIME is specified in ISO 8601 format (YYYY-mm-dd HH:MM:SS) in UTC." + + (define tm (strptime "%F %H:%M:%S %z" (string-append time " +0000"))) + (define epoch-seconds (string->number (strftime "%s" (car tm)))) + + (let loop ((prefix + (substring location + 0 (+ 1 (string-rindex location (cut eq? #\/ <>))))) + (node (file-system-tree location))) + (match node + ((name stat) ; flat file + (when (not (eq? (stat:type stat) 'symlink)) + (utime (string-append prefix name) epoch-seconds epoch-seconds))) + ((name stat children ...) ; directory + (utime (string-append prefix name) epoch-seconds epoch-seconds) + (for-each (lambda (child) + (loop (string-append prefix name + file-name-separator-string) + child)) + children))))) + (define (call-with-environment-variables variables thunk) "Call THUNK with the environment VARIABLES set." (let ((environment (environ))) -- 2.39.2