I'll try to explain what I'm trying to achieve. I have a file of paths that define my tool (all the needed paths to run my tool). I want to create a Dockerfile/Podman-file/Sing-file based on those dependencies so the container will be able to run the tool inside it. I want to find all the RPM packages of those paths. For that I use:
rpm -qf --queryformat "[%{NAME}]" [path]
But this command does not give me all the packages I need. I noticed that if I use
ldd [path] to get all shared libs and then for each lib, run the above RPM command, then I'll get all the needed packages.
So the my algorithm fow now is:
1. Run the above RPM command on the path and find related packages.
2. Run the ldd command on the path to find the shared libs.
3. For each shared lib path, repeat step 1 and step 2 (because shared lib can also have shared libs).
4. Keep track of all the paths that were already and stop once it's empty.
The algorithm works pretty well (until I came across with this special file). That way I will find all the related RPM packages. Now the problems:
1. I want to run step 2 only on dynamic files only (to prevent running ldd on all of the paths and it also solves
/proc/self/fd/1).
2. I'm familiar with the
file command. The problem with that command is that it's output is a syntax-based. Which means that I will have something like
if ($output =~ /dynamically linked/) # do stuff and if some output prints "not dynamically linked", it will be wrong. In other words, what I'm trying to say is that it's syntax-dependent.
Do you think that I need to parse the output of
file command? If so, what would be the best way to do it?
Also
ldconfig -p does not help me here since it gives me all the libs and not that are really being used.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.