From 83f9692a1cdece2e43108fce6e6789e04087db78 Mon Sep 17 00:00:00 2001
From: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com>
Date: Mon, 14 Jul 2025 08:25:28 -0400
Subject: [PATCH] setupcon: Copy temp files into /etc/console-setup with fixed
 name

Currently when using the --setup-dir option, a temp file(tmpkbd.*) is copied
to $SETUPDIR/etc/console-setup, But the filename is random due to use of
mktemp for the temp file creation.

This creates reproducibility issues due to different temp filenames across
multiple builds.

The temp file with the keymap information would be needed in the context of
loading the keymap file in the initrd stage.

Making the file name fixed while copying into $SETUPDIR/etc/console-setup
should not cause problems as the file created from the latest run of setupcon
will be referenced in the $SETUPDIR/bin/setupcon script.

Solves #977877

Signed-off-by: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com>
---
 setupcon | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/setupcon b/setupcon
index b3df2f4..e2a880e 100755
--- a/setupcon
+++ b/setupcon
@@ -1253,6 +1253,9 @@ if [ "$setupdir" ]; then
                         if [ -f "$arg" ]; then
                             f="${arg##*/}"
                             f="${f%.gz}"
+                            if echo "$f" | grep -q "^tmpkbd\."; then
+                                f=$(echo $f | sed 's/\..*//')
+                            fi
                             case "$arg" in
                                 *.gz) zcat "$arg" >"$setupdir/etc/console-setup/$f" ;;
                                 *) cp -a "$arg" "$setupdir/etc/console-setup/$f" ;;
-- 
2.39.5

