I am manually tweaking Debian init scripts in order to optimize the boot time of an embedded device. So far I reduced it by half just with the "low hanging fruits" ie. the smaller scripts that are easy to understand.
Now I am left with a few init scripts that take about 20s to run in total. Based on the experience from the other scripts, I can gain another 5 to 10 seconds here. The problem is those scripts are a bit too hard for me to understand because they source several helper scripts from
/lib/init/ which are difficult to follow (
mount-functions.sh being the first culprit).
In order to make those remaining scripts easier to understand so that I can optimize them, I'd like some way to "pre-process" those init scripts so that whenever they source a file it gets inlined in the script itself (recursively of course), and remove the unused functions to unclutter the code. Is there a tool for this?