Hi, On Sun, Sep 07, 2025 at 12:19:58AM +0200, Philip Hands wrote: > <[email protected]> writes: > AFAICS $TMPFILE (configured to be tmpkbd.*) is being used in the (outer) > setupcon script in order to record the commands used in the (initrd) > setupcon that is being written to "$setupdir"/bin/setupcon
Yes. > $TMPFILE is then used to store a list of things that will need to be > copied to the initrd, and that list is then used to create > "$setupdir"/morefiles, but $TMPFILE looks like it ought to be in either > /run or /tmp, and those should be removed by the trap, so if it's ending > up under $setupdir, what is copying it there? >From my analysis, setupcon has a code path, which: - only runs if no /etc/console-setup/cached* exist - and KMAP is not set in config Then it proceeds to use a tempfile (created in /tmp) and call loadkeys with this. Example commands it wants to use for me: kbd_mode -a loadkeys /tmp/tmpkbd.KLgbbu > /dev/null setupcon with --setup-dir at the very end then analyzed all commands it wants to use, and tries to *copy* all mentioned filenames into the initramfs. This happens around line 1371-1376 and in the fileargs function. > Your patch seems to assume that it is being copied in fileargs(), which > seems to imply that the tmpkbd.* filename is being passed as an argument > to one of the run() calls (if I'm reading the script correctly), but I > don't see where that's happening, and I don't yet understand why it's > happening. Indeed this is what happens. I think it only happens as I described above. It's this if-branch: https://salsa.debian.org/installer-team/console-setup/-/blob/a7bea22f15d7927921beef4858e95b4f7f885307/setupcon#L1261 > If that _is_ what's happening, and if there's a good reason for it, then > I would think that the right place to fix the nondeterminism would be in > the run() call that's causing the copy to be made, rather than by > modifying the filename in fileargs(), [..] Agreed. > > Now, this script ('/bin/setupcon') is used in the initrd by the 'keymap' > > initrd script [2]. > > In fact the 'keymap' hook script [3] is what is calling the setupcon script > > with the --setup-dir option. > > > > In my use case, this issue surfaced due to the use of the > > cryptsetup-initramfs package which triggers the run of the 'keymap' hook > > script by setting 'KEYMAP=y' here[4]. > > > > There *maybe*(speculating, not sure) more packages which triggers this > > 'keymap' hook script. > > > > Apologies for this long answer. I hope this gives some context. > > No, that's great, thanks -- anyway, my reply is longer :-/ > > The question that's still bothering me is: > > Does anything within the resulting initrd actually make use of the > 'keymap.*' file, and if so, where? I'm not sure which file you mean now with 'keymap.*'. But all commands that setupcon would run are also copied into the built-setupcon (including some patching of referenced filenames). Chris

