1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 13:10:33 +02:00

guix system: Make ‘--save-provenance’ effective for images.

Previously ‘--save-provenance’ would be silently ignored for ‘guix system
image’.

* guix/scripts/system.scm (image-with-provenance): New procedure.
(process-action): In ‘transform’, add case for ‘image?’, and emit a warning in
the default case.

Change-Id: I5020a4b3dacbe7a0820a3c4779b7d86a8133bd60
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #7485
This commit is contained in:
Ludovic Courtès
2026-03-26 09:24:55 +01:00
parent 985715e1e3
commit 95ac807edf

View File

@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014-2024 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014-2024, 2026 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Alex Kost <alezost@gmail.com> ;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich@gmail.com> ;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -1250,6 +1250,14 @@ Some ACTIONS support additional ARGS.\n"))
"switch-generation" "search" "edit" "switch-generation" "search" "edit"
"docker-image" "installer")) "docker-image" "installer"))
(define (image-with-provenance img file)
"Return IMG with provenance information recorded, including FILE, the
operating system or image configuration file."
(image (inherit img)
(operating-system
(operating-system-with-provenance (image-operating-system img)
file))))
(define (process-action action args opts) (define (process-action action args opts)
"Process ACTION, a sub-command, with the arguments are listed in ARGS. "Process ACTION, a sub-command, with the arguments are listed in ARGS.
ACTION must be one of the sub-commands that takes an operating system ACTION must be one of the sub-commands that takes an operating system
@@ -1272,8 +1280,16 @@ resulting from command-line parsing."
(system (assoc-ref opts 'system)) (system (assoc-ref opts 'system))
(target (assoc-ref opts 'target)) (target (assoc-ref opts 'target))
(transform (lambda (obj) (transform (lambda (obj)
(if (and save-provenance? (operating-system? obj)) (if save-provenance?
(operating-system-with-provenance obj file) (cond
((operating-system? obj)
(operating-system-with-provenance obj file))
((image? obj)
(image-with-provenance obj file))
(else
(warning
(G_ "'--save-provenance' has no effect~%"))
obj))
obj))) obj)))
(obj (transform (obj (transform
(ensure-operating-system-or-image (ensure-operating-system-or-image