mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26: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))
|
generation))
|
||||||
(boot-parameters-path (string-append system-path
|
(boot-parameters-path (string-append system-path
|
||||||
"/parameters"))
|
"/parameters"))
|
||||||
(time (stat:mtime (lstat system-path))))
|
(epoch (stat:mtime (lstat system-path))))
|
||||||
(list generation
|
(list generation
|
||||||
system-path
|
system-path
|
||||||
time
|
epoch
|
||||||
(read-file boot-parameters-path))))
|
(read-file boot-parameters-path))))
|
||||||
(reverse (generation-numbers %system-profile)))))))
|
(reverse (generation-numbers %system-profile)))))))
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ (define (read-file path)
|
||||||
(return
|
(return
|
||||||
(map (lambda (generation)
|
(map (lambda (generation)
|
||||||
(match generation
|
(match generation
|
||||||
((generation system-path time serialized-params)
|
((generation system-path epoch serialized-params)
|
||||||
(let* ((params (call-with-input-string serialized-params
|
(let* ((params (call-with-input-string serialized-params
|
||||||
read-boot-parameters))
|
read-boot-parameters))
|
||||||
(root (boot-parameters-root-device params))
|
(root (boot-parameters-root-device params))
|
||||||
|
@ -466,9 +466,7 @@ (define (read-file path)
|
||||||
(label
|
(label
|
||||||
(string-append label " (#"
|
(string-append label " (#"
|
||||||
(number->string generation) ", "
|
(number->string generation) ", "
|
||||||
(let ((time (make-time time-utc 0 time)))
|
(epoch->date-string epoch)
|
||||||
(date->string (time-utc->date time)
|
|
||||||
"~Y-~m-~d ~H:~M"))
|
|
||||||
")"))
|
")"))
|
||||||
(kernel-arguments
|
(kernel-arguments
|
||||||
(append (bootable-kernel-arguments system-path root version)
|
(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 format)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
|
#:use-module (srfi srfi-19)
|
||||||
#:use-module (srfi srfi-34)
|
#:use-module (srfi srfi-34)
|
||||||
#:use-module (srfi srfi-35)
|
#:use-module (srfi srfi-35)
|
||||||
#:use-module (rnrs bytevectors)
|
#:use-module (rnrs bytevectors)
|
||||||
|
@ -64,6 +65,7 @@ (define-module (gnu system boot)
|
||||||
read-boot-parameters-file
|
read-boot-parameters-file
|
||||||
bootable-kernel-arguments
|
bootable-kernel-arguments
|
||||||
|
|
||||||
|
epoch->date-string
|
||||||
boot-parameters->menu-entry
|
boot-parameters->menu-entry
|
||||||
|
|
||||||
ensure-not-/dev
|
ensure-not-/dev
|
||||||
|
@ -290,6 +292,12 @@ (define version>0? (> version 0))
|
||||||
#~(string-append (if #$version>0? "gnu.load=" "--load=")
|
#~(string-append (if #$version>0? "gnu.load=" "--load=")
|
||||||
#$system "/boot")))))
|
#$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)
|
(define (boot-parameters->menu-entry conf)
|
||||||
"Return a <menu-entry> instance given CONF, a <boot-parameters> instance."
|
"Return a <menu-entry> instance given CONF, a <boot-parameters> instance."
|
||||||
(let* ((kernel (boot-parameters-kernel conf))
|
(let* ((kernel (boot-parameters-kernel conf))
|
||||||
|
|
|
@ -328,19 +328,13 @@ (define-syntax-rule (unless-file-not-found exp)
|
||||||
#f
|
#f
|
||||||
(apply throw args)))))
|
(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)
|
(define* (profile-boot-parameters #:optional (profile %system-profile)
|
||||||
(numbers
|
(numbers
|
||||||
(reverse (generation-numbers profile))))
|
(reverse (generation-numbers profile))))
|
||||||
"Return a list of 'boot-parameters' for the generations of PROFILE specified
|
"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
|
by NUMBERS, which is a list of generation numbers. The list is ordered from
|
||||||
the most recent to the oldest profiles."
|
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
|
(unless-file-not-found
|
||||||
(let* ((params (read-boot-parameters-file system))
|
(let* ((params (read-boot-parameters-file system))
|
||||||
(label (boot-parameters-label params)))
|
(label (boot-parameters-label params)))
|
||||||
|
@ -348,7 +342,7 @@ (define (system->boot-parameters system number time)
|
||||||
(inherit params)
|
(inherit params)
|
||||||
(label (string-append label " (#"
|
(label (string-append label " (#"
|
||||||
(number->string number) ", "
|
(number->string number) ", "
|
||||||
(epoch->date-string time) ")"))))))
|
(epoch->date-string epoch) ")"))))))
|
||||||
(let* ((systems (map (cut generation-file-name profile <>)
|
(let* ((systems (map (cut generation-file-name profile <>)
|
||||||
numbers))
|
numbers))
|
||||||
(times (map (lambda (system)
|
(times (map (lambda (system)
|
||||||
|
|
Loading…
Reference in a new issue