mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-06 23:16:13 -05:00
Move epoch->date-string to gnu/system/boot.scm and use it elsewhere.
* 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
This commit is contained in:
parent
cb491fdcba
commit
42d65fe2eb
3 changed files with 14 additions and 14 deletions
|
@ -444,10 +444,10 @@ (define (read-file path)
|
|||
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)))))))
|
||||
|
||||
|
@ -455,7 +455,7 @@ (define (read-file path)
|
|||
(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))
|
||||
|
@ -466,9 +466,7 @@ (define (read-file path)
|
|||
(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)
|
||||
|
|
|
@ -39,6 +39,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)
|
||||
|
@ -64,6 +65,7 @@ (define-module (gnu system boot)
|
|||
read-boot-parameters-file
|
||||
bootable-kernel-arguments
|
||||
|
||||
epoch->date-string
|
||||
boot-parameters->menu-entry
|
||||
|
||||
ensure-not-/dev
|
||||
|
@ -290,6 +292,12 @@ (define version>0? (> version 0))
|
|||
#~(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 <menu-entry> instance given CONF, a <boot-parameters> instance."
|
||||
(let* ((kernel (boot-parameters-kernel conf))
|
||||
|
|
|
@ -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 (system->boot-parameters system number time)
|
|||
(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)
|
||||
|
|
Loading…
Reference in a new issue