From 95ac807edf99f6489bd06f9d00632ed8dfc19798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 26 Mar 2026 09:24:55 +0100 Subject: [PATCH] =?UTF-8?q?guix=20system:=20Make=20=E2=80=98--save-provena?= =?UTF-8?q?nce=E2=80=99=20effective=20for=20images.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Merges: #7485 --- guix/scripts/system.scm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 8a56f1cc63..eddc2fc3e3 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014-2024 Ludovic Courtès +;;; Copyright © 2014-2024, 2026 Ludovic Courtès ;;; Copyright © 2016 Alex Kost ;;; Copyright © 2016, 2017, 2018 Chris Marusich ;;; Copyright © 2017, 2019 Mathieu Othacehe @@ -1250,6 +1250,14 @@ Some ACTIONS support additional ARGS.\n")) "switch-generation" "search" "edit" "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) "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 @@ -1272,8 +1280,16 @@ resulting from command-line parsing." (system (assoc-ref opts 'system)) (target (assoc-ref opts 'target)) (transform (lambda (obj) - (if (and save-provenance? (operating-system? obj)) - (operating-system-with-provenance obj file) + (if save-provenance? + (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 (transform (ensure-operating-system-or-image