ldd-based pseudo-dependency management tool (please read before attack);)
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I guess you could make a shell script to look at other shell scripts, compare every word in it and compile a list of binaries. Sounds way more effort than it would be worth.
Actually in concept that doesn't sound too difficult, but I'm sure it would be hard to get the details and "edge cases" right.
It would also have to be recursive in the event the script calls other scripts. slackpkg is ~500 lines and pkgtool is ~700, I don't think it'd be a huge chore to skim them.
HeHe, I use a patch from RH for bash which will make it list all the bins/scripts called by a script. Very handy indeed -even if it may miss certain constructs. The patch itself is really quite small and non-invasive in that it simply expands the '-n' option to print out the called programs. Any fedora/RH source archive of bash will have the patch in there. I filter/sort the results to get a list of unique calls.
The word "dependency" usually refers to shared objects on which some binary depends.
-noarch packages have no dependencies using this definition, as they include no files in /usr/lib or /usr/lib64.
If you use the word dependency with another meaning, you will have to define it.
Dependency is universally defined thus: if A needs B to function, then B is a dependency for A.
It matters not if A or B are scripts or binaries or shared objects.
Simply put: if you are missing 'sed' or 'awk' then probably 'network-scripts' will not work.
Quote:
Originally Posted by Didier Spaier
If for instance you speak about all programs that a shell script needs to run as intended, you will have to analyze the the script to find what utilities or other programs it runs or calls. If you write a program that does that automatically, please share it with us.
I'm not a programmer and have no skills to build such a tool.
As for analyzing shell scripts to find their dependencies, already did that here.
The OP wants to build a dependency resolver and asked for input.
I was just point out to him that the existing tools and lists do not take into account the dependencies of 'shell script packages' and it would be a good thing if some future tool or list did it.
Just giving input, as asked by the OP
Dependency is universally defined thus: if A needs B to function, then B is a dependency for A.
It matters not if A or B are scripts or binaries or shared objects.
Simply put: if you are missing 'sed' or 'awk' then probably 'network-scripts' will not work.
Generally speaking, yes. But as the OP mentioned in the thread's title "ldd-based", the post you quoted highlights that there are dependencies that ldd can't detect, thus have to be dealt with other tools or methods (if they are in the scope).
Last edited by Didier Spaier; 06-29-2017 at 06:27 AM.
Generally speaking, yes. But as the OP mentioned in the thread's title "ldd-based", the post you quoted highlights that there are dependencies that ldd can't detect, thus have to be dealt with other tools or methods (if they are in the scope).
The biggest issue is that ldd detects too many dependencies, i.e. indirect ones. A binary may be linked to several shared objects, and ldd will also report the shared objects that those link to in turn. If the purpose is to find what might need recompiling after a shared library bumps its version number, you really only want to report the direct dependencies to avoid a lot of needless recompiles.
For this purpose, "readelf -d" is a better source of dependency information than "ldd".
The biggest issue is that ldd detects too many dependencies, i.e. indirect ones. A binary may be linked to several shared objects, and ldd will also report the shared objects that those link to in turn. If the purpose is to find what might need recompiling after a shared library bumps its version number, you really only want to report the direct dependencies to avoid a lot of needless recompiles.
For this purpose, "readelf -d" is a better source of dependency information than "ldd".
Indeed. depfinder uses ldd, but its purpose is to find all packages needed to run the programs included in a given package, thus it has to find the dependencies recursively.
But of course to find which dependencies you need to recompile for a shared library's version bump in -current, readelf -d is better. As an end user I didn't come across a missing dependency so far in a full Slackware installation, so thanks ;-)
Last edited by Didier Spaier; 06-29-2017 at 04:01 PM.
The biggest issue is that ldd detects too many dependencies, i.e. indirect ones. A binary may be linked to several shared objects, and ldd will also report the shared objects that those link to in turn. If the purpose is to find what might need recompiling after a shared library bumps its version number, you really only want to report the direct dependencies to avoid a lot of needless recompiles.
For this purpose, "readelf -d" is a better source of dependency information than "ldd".
and this is why sbbdep does read the elf information plus handling and emulating linker search path correct, including all properties, that ones found in the elf dyn section like rpath dynpath + relative path handling and resolving of the HOME location plus respecting the system properties, to find the used libraries and the alternatives. (plus a hidden option to handle some special cases that developers might have) And having a cache to get those info as fast as possible, and not just tell you what a binary/library needs, but also who is needing a library. self plug done ;-)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.