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.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

In 'find_elf()' changed pipecmd to "find * -executable -o name *.so*" because some libs
may not have have their executable flag set, such as an unpacked from an rpm package that
doesn't have the perms set until install time. This change will set off error messages about the files that need corrected permissions.

Also quotes around the "*.so*" for the 'find' call. (It couldn't have worked without it, but somehow this was mis-posted). (corrected feb 21) -rs

-- A tool to read dependencies from all elf executables and libraries in a directory branch.

-- Can be used to check make-based[tm] :-) installations or rpm and deb packages before packing up.

Build Requires:

bash

make

g++

Run Requires:

ldd

find

This is interesting, because I discovered that we can't run ldd in a pipe to read /usr/lib or /usr/bin (openSUSE 11.4). Possibly due to security settings. Try it with the --info flag. It CAN, however read files in directories below /usr/lib (such as /usr/lib/dri on my system).

Seems to work great when used "normally" (to read binary trees in package folders), and it's pretty fast. Here's part of a dump of my /bin deps.

The "external deps" listed are libs loaded at run time that are not resolved in or below the prefix branch (i.e., /bin in this case).

I have installed the code and executable in my sandbox so it's linked into my path and is easy to edit. (see early blog entries re. new.symlink, etc.). And I gave the folder a version number so I can easily see which one is current if this needs any changes later.

/* usage.txt converted with txt2cstr */
const char* usage_str =
"\n"
"Usage: find-deps <branch>\n"
"\n"
" Primary usage is for discovering files needed by a binary package before\n"
" installation/building, etc.\n"
"\n"
" Prints out a list of all libs used by executable files and libs \n"
" found in the directory <branch> (recursive). \n"
"\n"
" Does not list files that are resolved by other files in the same \n"
" branch.\n"
"\n"
" Does not look in any other branches for resolvers.\n"
"\n"
"Switches:\n"
" -i | --info display info about files found\n"
" -v | --version show version\n"
"\n"
"Notes: \n"
"\n"
" 1. Needs linux tools 'find' and 'ldd' to run.\n"
"\n"
" 2. If a symlink points to a non-existent file (as encountered in \n"
" development packages) this will be still be counted as a self-resolved \n"
" dependency.\n"
"\n"
" 3. The error message \"No elf binaries found\" sent to stderr could mean\n"
" that there really aren't any or just that the path doesn't exist.\n"
"\n"
" 4. May not work for system dirs (e.g. /usr/bin, /usr/lib, /lib) due to \n"
" ldd quirks but we can get 'info' on the number of elf files.\n"
"\n"
;

Also needs a type lister like 'new.image' has and some other improvements/reorganizations. It's easier to delete stuff than write stuff though, so this is on the back burner as far as my own needs are concerned.

But that's one bad idea. And it may give you some bad ideas of your own!

:-)

Now we have find-deps.

We'll put it to good use a bit later, if all continues to go well here in blog-land.

Some more interesting stuff you can do once you've got a way to compile this and run it.

Compile the app and run 'strip find-deps' and check the file size after it's stripped. Compare to the -s switch (sent to the linker).

Add the -g3 switch to the compile and run in a good debugger. Find where the ldd pipe errors come from when checking /usr/lib if your system does the same thing as mine. (Same whether you chdir to the folder or not. You'll see what I mean.)

Create a TREE folder containing the directory image of an installation you might want to generate. Probably in TREE/usr/local, for a somewhat safe place if you decide to actually install it later. And 'find-deps TREE'. :-)