mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 22:08:16 -05:00
guix system: "list-generations" displays provenance info.
* guix/scripts/pull.scm (channel-commit-hyperlink): Export. * guix/scripts/system.scm (display-system-generation) [display-channel]: New procedure. Read the "provenance" file of GENERATION and display channel info and the configuration file name when available.
This commit is contained in:
parent
eaabc5e87f
commit
60f4564a63
2 changed files with 48 additions and 2 deletions
|
@ -60,6 +60,7 @@ (define-module (guix scripts pull)
|
||||||
#:use-module (ice-9 format)
|
#:use-module (ice-9 format)
|
||||||
#:export (display-profile-content
|
#:export (display-profile-content
|
||||||
channel-list
|
channel-list
|
||||||
|
channel-commit-hyperlink
|
||||||
with-git-error-handling
|
with-git-error-handling
|
||||||
guix-pull))
|
guix-pull))
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,11 @@ (define-module (guix scripts system)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
#:use-module (guix profiles)
|
#:use-module (guix profiles)
|
||||||
#:use-module (guix scripts)
|
#:use-module (guix scripts)
|
||||||
|
#:use-module (guix channels)
|
||||||
#:use-module (guix scripts build)
|
#:use-module (guix scripts build)
|
||||||
#:autoload (guix scripts package) (delete-generations
|
#:autoload (guix scripts package) (delete-generations
|
||||||
delete-matching-generations)
|
delete-matching-generations)
|
||||||
|
#:autoload (guix scripts pull) (channel-commit-hyperlink)
|
||||||
#:use-module (guix graph)
|
#:use-module (guix graph)
|
||||||
#:use-module (guix scripts graph)
|
#:use-module (guix scripts graph)
|
||||||
#:use-module (guix scripts system reconfigure)
|
#:use-module (guix scripts system reconfigure)
|
||||||
|
@ -456,9 +458,30 @@ (define (shepherd-service-node-type services)
|
||||||
;;; Generations.
|
;;; Generations.
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
(define (sexp->channel sexp)
|
||||||
|
"Return the channel corresponding to SEXP, an sexp as found in the
|
||||||
|
\"provenance\" file produced by 'provenance-service-type'."
|
||||||
|
(match sexp
|
||||||
|
(('channel ('name name)
|
||||||
|
('url url)
|
||||||
|
('branch branch)
|
||||||
|
('commit commit))
|
||||||
|
(channel (name name) (url url)
|
||||||
|
(branch branch) (commit commit)))))
|
||||||
|
|
||||||
(define* (display-system-generation number
|
(define* (display-system-generation number
|
||||||
#:optional (profile %system-profile))
|
#:optional (profile %system-profile))
|
||||||
"Display a summary of system generation NUMBER in a human-readable format."
|
"Display a summary of system generation NUMBER in a human-readable format."
|
||||||
|
(define (display-channel channel)
|
||||||
|
(format #t " ~a:~%" (channel-name channel))
|
||||||
|
(format #t (G_ " repository URL: ~a~%") (channel-url channel))
|
||||||
|
(when (channel-branch channel)
|
||||||
|
(format #t (G_ " branch: ~a~%") (channel-branch channel)))
|
||||||
|
(format #t (G_ " commit: ~a~%")
|
||||||
|
(if (supports-hyperlinks?)
|
||||||
|
(channel-commit-hyperlink channel)
|
||||||
|
(channel-commit channel))))
|
||||||
|
|
||||||
(unless (zero? number)
|
(unless (zero? number)
|
||||||
(let* ((generation (generation-file-name profile number))
|
(let* ((generation (generation-file-name profile number))
|
||||||
(params (read-boot-parameters-file generation))
|
(params (read-boot-parameters-file generation))
|
||||||
|
@ -468,7 +491,13 @@ (define* (display-system-generation number
|
||||||
(root-device (if (bytevector? root)
|
(root-device (if (bytevector? root)
|
||||||
(uuid->string root)
|
(uuid->string root)
|
||||||
root))
|
root))
|
||||||
(kernel (boot-parameters-kernel params)))
|
(kernel (boot-parameters-kernel params))
|
||||||
|
(provenance (catch 'system-error
|
||||||
|
(lambda ()
|
||||||
|
(call-with-input-file
|
||||||
|
(string-append generation "/provenance")
|
||||||
|
read))
|
||||||
|
(const #f))))
|
||||||
(display-generation profile number)
|
(display-generation profile number)
|
||||||
(format #t (G_ " file name: ~a~%") generation)
|
(format #t (G_ " file name: ~a~%") generation)
|
||||||
(format #t (G_ " canonical file name: ~a~%") (readlink* generation))
|
(format #t (G_ " canonical file name: ~a~%") (readlink* generation))
|
||||||
|
@ -495,7 +524,23 @@ (define* (display-system-generation number
|
||||||
(else
|
(else
|
||||||
root-device)))
|
root-device)))
|
||||||
|
|
||||||
(format #t (G_ " kernel: ~a~%") kernel))))
|
(format #t (G_ " kernel: ~a~%") kernel)
|
||||||
|
|
||||||
|
(match provenance
|
||||||
|
(#f #t)
|
||||||
|
(('provenance ('version 0)
|
||||||
|
('channels channels ...)
|
||||||
|
('configuration-file config-file))
|
||||||
|
(unless (null? channels)
|
||||||
|
;; TRANSLATORS: Here "channel" is the same terminology as used in
|
||||||
|
;; "guix describe" and "guix pull --channels".
|
||||||
|
(format #t (G_ " channels:~%"))
|
||||||
|
(for-each display-channel (map sexp->channel channels)))
|
||||||
|
(when config-file
|
||||||
|
(format #t (G_ " configuration file: ~a~%")
|
||||||
|
(if (supports-hyperlinks?)
|
||||||
|
(file-hyperlink config-file)
|
||||||
|
config-file))))))))
|
||||||
|
|
||||||
(define* (list-generations pattern #:optional (profile %system-profile))
|
(define* (list-generations pattern #:optional (profile %system-profile))
|
||||||
"Display in a human-readable format all the system generations matching
|
"Display in a human-readable format all the system generations matching
|
||||||
|
|
Loading…
Reference in a new issue