lddtree.sh: Add an "ldd-mode" for when the command is executed as *ldd #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dracut needs ldd to identify which libraries it needs to pull into the initrd. The regular ldd does not work across architectures though, so it suggests using this gist, which is based on a script from crosstool-ng. I suggested adding this to Gentoo's crossdev but there was little appetite to add yet another ldd implementation.
lddtree.sh almost outputs what we need, the main issue being that it includes the file being examined, even when it is the only file being examined. I decided to add an "ldd-mode" to make the output more like regular ldd when it is executed as *ldd. The intention is to install a symlink to it with crossdev. I had to restructure the code a bit to ensure it was still readable after adding a third output format.
lddtree.sh currently doesn't get installed when the Python implementation is chosen, which would make things awkward for crossdev. I have therefore made Meson install lddtree.sh unconditionally, adding an lddtree symlink pointing to the chosen implementation instead.
Both lddtree implementations enable the auto-root feature by default. This breaks Dracut as it passes regular rooted paths to ldd, meaning that /foo/bin/ls becomes /foo/foo/bin/ls. I don't want to have to create a wrapper to disable this option, and it seems like quite a counter-intuitive feature anyway, so I have now disabled it by default. Hopefully this isn't controversial. I can't see any use of lddtree by packages at build time or runtime.