From patchwork Fri Sep 20 04:15:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lilah Tascheter X-Patchwork-Id: 68151 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 9113327BBEA; Fri, 20 Sep 2024 05:18:35 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, 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 EC1EF27BBE2 for ; Fri, 20 Sep 2024 05:18:34 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1srV5f-0008Dq-Oy; Fri, 20 Sep 2024 00:17:55 -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 1srV5Y-0008BO-GA for guix-patches@gnu.org; Fri, 20 Sep 2024 00:17:49 -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 1srV5Y-0006Fy-6x; Fri, 20 Sep 2024 00:17:48 -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=GkXQmKfGKePQaC1SQcLmSTKCPVMRu4FhXICXbMjDOng=; b=ZJkiNwQQX+t5CPoCdy2s1oiv7Q7KRi3NvwAxyU9l8qfRpiK1syfRYhdEdoxJywGmKNPb7fggbqqvZSTqAbSAUzhy2NPMViVfQEAzNPY6C6gsqntd93TANvR7Ugp/utAxcuSmfbZIL2R5RGty+JvLfPr5vxzRbXOXDq6QYAb5LoOu8jnTGEaivsmHu8h/IvZrAMpaATD6L9cP4s1F0i7iXTjniVpRqG3DWi845zj+Oc0cYyjRSFvmA5OYjysGjnF2wvyPuWnTgaIImwEd1fs7u9KsQF80YayC22tWsyZTMGu/7rt1pP2PkbIsUOqta4rhDOiLB2CTrdc/Xt7Hd8RmwQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1srV5o-0005TX-9f; Fri, 20 Sep 2024 00:18:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69343] [PATCH v4 04/11] Move epoch->date-string to gnu/system/boot.scm and use it elsewhere. Resent-From: Lilah Tascheter Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 20 Sep 2024 04:18:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69343 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69343@debbugs.gnu.org Cc: Herman Rimm , Felix Lechner , Christopher Baines , Josselin Poiret , Ludovic Court??s , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic Court??s , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 69343-submit@debbugs.gnu.org id=B69343.172680586820926 (code B ref 69343); Fri, 20 Sep 2024 04:18:04 +0000 Received: (at 69343) by debbugs.gnu.org; 20 Sep 2024 04:17:48 +0000 Received: from localhost ([127.0.0.1]:33744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srV5X-0005RL-CH for submit@debbugs.gnu.org; Fri, 20 Sep 2024 00:17:47 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:51944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srV5S-0005QY-I5 for 69343@debbugs.gnu.org; Fri, 20 Sep 2024 00:17:43 -0400 DKIM-Signature: a=rsa-sha256; b=DRfMk84p82UX/K2rmbkOnkdwuIX8muIvBUYGZ4GrCrKNGInGpsxaBf2Ymy/+nUiNghJ7LQRmJSJ0I/3uZdNQIFOZJpdTTFYTDRMTpzvUqTzE30TDBCJb70PcMJ2ZlEIpFHFtlDiXY+UpyjMcuMvP+6lM1iB0zCkZKl+yv7DIQhU/1MrvHWC6ob7a/9KaZxzZvL2Z+Q9ApRP3Twc1JMNzIRDA7p4JhQFk5pEhi1Nmhl7gL3iMjVCgx+Znx7kcl+k7lh0srP/uKRCsSJ1EzSMOLlm2VhwP5EwB2jlO3uae/AJ8h8IHTKQp1KsBxvkRvTHV5YpvRY+tzLld7dfykeY+/Q==; s=purelymail3; d=lunabee.space; v=1; bh=fwzoCc7y6ItU44Puf4gL6wng+1TnmX0zYcUUjQTfsJo=; h=Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=CekFazb7fA3XR71mlpWngRa4CS9SttCb+p2ZuzLutZ5aiflPwK2HdvYhyQrzPl4qLXHY/YXaqbr3omSWFF5cmUyKkfLWNBDN0d67qh8HWyWUaL+hVIPwOjIp9RehJM136sptuDUbUpC/kTNQd3C4z7mMp0uqu4aQxmc29iU8J9hLvJTfdcmB+v/LquT0uHqm55WjNdEcUfeS+6Gg2HtWZV1jQi7iMKodnG8Ifao7E2oAfeKKyMNLSMNzF13/cGXZuxFQsnBNEzMUD5QxF9w/FPo9ORKGovIhyZbuN9aQ7l4YYtq+Q3e0NCyGd5IzuxHggYxvsNLdOHzDmH8f5zEkVw==; s=purelymail3; d=purelymail.com; v=1; bh=fwzoCc7y6ItU44Puf4gL6wng+1TnmX0zYcUUjQTfsJo=; h=Feedback-ID:Received:From:To:Subject:Date; Feedback-ID: 8937:2070:null:purelymail X-Pm-Original-To: 69343@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -100958845; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Fri, 20 Sep 2024 04:17:15 +0000 (UTC) Date: Thu, 19 Sep 2024 23:15:58 -0500 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by Purelymail 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: , X-Patchwork-Original-From: Lilah Tascheter via Guix-patches From: Lilah Tascheter Reply-To: Lilah Tascheter 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: Felix Lechner * guix/scripts/system.scm (profile-boot-parameters): Rename time to epoch to fit new procedure name. (epoch->date-string): Move to... * gnu/system/boot.scm (epoch->date-string): ...here. * gnu/machine/ssh.scm (machine-boot-parameters): Rename time to epoch. (machine-boot-parameters)[boot-parameters]: Use epoch->date-string. Change-Id: I6a5f793567221f81edd7b2d8d9f0f3e801d1b113 --- gnu/machine/ssh.scm | 10 ++++------ gnu/system/boot.scm | 8 ++++++++ guix/scripts/system.scm | 10 ++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 749aa2b6d8..e68e64527e 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -442,10 +442,10 @@ (define (machine-boot-parameters machine) generation)) (boot-parameters-path (string-append system-path "/parameters")) - (time (stat:mtime (lstat system-path)))) + (epoch (stat:mtime (lstat system-path)))) (list generation system-path - time + epoch (read-file boot-parameters-path)))) (reverse (generation-numbers %system-profile))))))) @@ -453,7 +453,7 @@ (define (machine-boot-parameters machine) (return (map (lambda (generation) (match generation - ((generation system-path time serialized-params) + ((generation system-path epoch serialized-params) (let* ((params (call-with-input-string serialized-params read-boot-parameters)) (root (boot-parameters-root-device params)) @@ -464,9 +464,7 @@ (define (machine-boot-parameters machine) (label (string-append label " (#" (number->string generation) ", " - (let ((time (make-time time-utc 0 time))) - (date->string (time-utc->date time) - "~Y-~m-~d ~H:~M")) + (epoch->date-string epoch) ")")) (kernel-arguments (append (bootable-kernel-arguments system-path root version) diff --git a/gnu/system/boot.scm b/gnu/system/boot.scm index df27b8aea4..01e3a965e4 100644 --- a/gnu/system/boot.scm +++ b/gnu/system/boot.scm @@ -45,6 +45,7 @@ (define-module (gnu system boot) #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-19) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (rnrs bytevectors) @@ -70,6 +71,7 @@ (define-module (gnu system boot) read-boot-parameters-file bootable-kernel-arguments + epoch->date-string boot-parameters->menu-entry ensure-not-/dev @@ -296,6 +298,12 @@ (define* (bootable-kernel-arguments system root-device version) #~(string-append (if #$version>0? "gnu.load=" "--load=") #$system "/boot"))))) +(define (epoch->date-string epoch) + "Return a string representing the date for EPOCH seconds." + (let ((time (make-time time-utc 0 epoch))) + (date->string (time-utc->date time) + "~Y-~m-~d ~H:~M"))) + (define (boot-parameters->menu-entry conf) "Return a instance given CONF, a instance." (let* ((kernel (boot-parameters-kernel conf)) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index cb70d36219..b197812e63 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -328,19 +328,13 @@ (define-syntax-rule (unless-file-not-found exp) #f (apply throw args))))) -(define (epoch->date-string epoch) - "Return a string representing the date for EPOCH seconds." - (let ((time (make-time time-utc 0 epoch))) - (date->string (time-utc->date time) - "~Y-~m-~d ~H:~M"))) - (define* (profile-boot-parameters #:optional (profile %system-profile) (numbers (reverse (generation-numbers profile)))) "Return a list of 'boot-parameters' for the generations of PROFILE specified by NUMBERS, which is a list of generation numbers. The list is ordered from the most recent to the oldest profiles." - (define (system->boot-parameters system number time) + (define (system->boot-parameters system number epoch) (unless-file-not-found (let* ((params (read-boot-parameters-file system)) (label (boot-parameters-label params))) @@ -348,7 +342,7 @@ (define* (profile-boot-parameters #:optional (profile %system-profile) (inherit params) (label (string-append label " (#" (number->string number) ", " - (epoch->date-string time) ")")))))) + (epoch->date-string epoch) ")")))))) (let* ((systems (map (cut generation-file-name profile <>) numbers)) (times (map (lambda (system)