Package: initramfs-tools
Version: 0.142

Dear maintainers,

while adapting a workaround for bug 859458 on my systems I noticed a 
redundant-looking "PREREQ" variable + "prereqs" function recommended by the 
INITRAMFS-TOOLS(7) manpage (that code is pasted in multiple places in that 
manpage). See initial details in my message to that bug (the QUESTION part):
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859458#51

Later I checked the INITRAMFS-TOOLS source code:

- The "get_prereq_pairs" function from the "hook-functions" file (that installs 
to "/usr/share/initramfs-tools/hook-functions") calls INITRAMFS scripts with 
the "prereqs" argument. So each script can output a space separated list of 
prereqs names that is then used to order the scripts in the same directory (see 
the "cache_run_scripts" function in that "hook-functions" file).

- I did not find any relevant places in the INITRAMFS-TOOLS source code where 
the "PREREQ" variable or "prereqs" function is used externally (e.g. after 
sourcing INITRAMFS scripts or for searching in the scripts).

So my initial assumption that the uppercase name of the "PREREQ" variable could 
mean that it is used globally/externally somewhere else in the INITRAMFS-TOOLS 
source code was not confirmed (unless I missed something). Same goes for the 
"prereqs" function, so I really do not know why the INITRAMFS-TOOLS(7) manpage 
recommends such redundant source code that most INITRAMFS scripts then follow. 
Some INITRAMFS scripts I looked at however use "PREREQS" instead of "PREREQ" 
variable and some skip the redundant-looking "PREREQ" variable + "prereqs" 
function completely.

After my search + testing I now think that it is sufficient to just use the 
"echo 'PREREQ1 ...'" directly in the case statement (see below). I tested on 
multiple systems (3 laptops with GUI, 3 VMs with GUI 2 VMs without GUI) that my 
INITRAMFS scripts without the redundant "PREREQ" variable + "prereqs" function 
work and my systems boot fine. I also extracted my INITRAMFS with UNMKINITRAMFS 
and checked the "/main/scripts/*/ORDER" files to confirm that all my INITRAMFS 
scripts were correctly ordered.

Thus, I think the INITRAMFS-TOOLS(7) manpage should be updated, so that it 
either explains the purpose of the redundant "PREREQ" variable + "prereqs" 
function or avoids those redundant parts and uses for example just the case 
statement:
case "$1" in
    prereqs)
        echo 'PREREQ1 PREREQ2 PREREQ3 ...'
        exit 0;;
esac

Also if "PREREQ" variable + "prereqs" function really is redundant all affected 
INITRAMFS scripts (= most of them) could be simplified a bit.

Regards,
Jmkr

Reply via email to