From 1c812994bdc2d989f60fc5e4845bf8a7c0516ba4 Mon Sep 17 00:00:00 2001
From: Adithya Balakumar <adithya.balakumar@toshiba-tsip.com>
Date: Thu, 13 Feb 2025 01:22:34 -0500
Subject: [PATCH] setupcon: Copy temp files into /etc/console-setup with fixed
 name

Currently temp file is copied to /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.

Attempt to solve this by copying the temp file into /etc/console-setup
with a fixed file name

Solves #977877

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

diff --git a/setupcon b/setupcon
index b3df2f4..798404e 100755
--- a/setupcon
+++ b/setupcon
@@ -1253,11 +1253,13 @@ if [ "$setupdir" ]; then
                         if [ -f "$arg" ]; then
                             f="${arg##*/}"
                             f="${f%.gz}"
+                            filename=$(echo $f | sed 's/\..*//')
+                            dest_filename=$filename.fixed
                             case "$arg" in
-                                *.gz) zcat "$arg" >"$setupdir/etc/console-setup/$f" ;;
-                                *) cp -a "$arg" "$setupdir/etc/console-setup/$f" ;;
+                                *.gz) zcat "$arg" >"$setupdir/etc/console-setup/$dest_filename" ;;
+                                *) cp -a "$arg" "$setupdir/etc/console-setup/$dest_filename" ;;
                             esac
-                            printf "%s" "/etc/console-setup/$f" \
+                            printf "%s" "/etc/console-setup/$dest_filename" \
                                 | sed "s/'/\'\\\\\'\'/g"
                         else
                             printf "%s" "$arg" \
-- 
2.39.5

