LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   What is that command to list dependencies? (https://www.linuxquestions.org/questions/slackware-14/what-is-that-command-to-list-dependencies-4175484070/)

WhiteHotLoveTiger 11-10-2013 01:06 AM

What is that command to list dependencies?
 
I haven't used it in a while, so I've forgotten it, and it's really frustrating me. I know there's a command in Slackware (or maybe it's more general than Slackware, I can't recall) which lists a package's dependencies and indicates which of those are installed.

I've been searching through these forums, docs.slackware.com, & the rest of the web. I'm sure the answer's out there somewhere, but I must be using the wrong search terms.

jtsn 11-10-2013 01:09 AM

Welcome back to Slackware. There are no package dependencies in Slackware, so there can be no command to list them. :-)

WhiteHotLoveTiger 11-10-2013 01:21 AM

hmmmm...
I must be using the wrong terms.

As I think about it more, I'm thinking that maybe it's not specific to Slackware, and maybe it takes only an installed program name as input as lists the libraries it links to? Does that sound more reasonable? I think this might be what it does.

Woodsman 11-10-2013 01:24 AM

Perhaps you are thinking about /usr/bin/ldd?

WhiteHotLoveTiger 11-10-2013 01:27 AM

ah ha! The command I was searching for is ldd !

Thanks Woodsman. :)


On a not-entirely unrelated note, the default Slackware install on linode is terrible in terms of the installed libraries & packages...

a4z 11-10-2013 01:29 AM

if you are looking for info about binary dependencies, try this

https://bitbucket.org/a4z/sbbdep/wiki/Home

WhiteHotLoveTiger 11-10-2013 01:37 AM

a4z, that looks interesting. I wish the examples page was working though. ;)


edit: I now see that there are examples on the main page. This is really cool. Thanks for making it.

a4z 11-10-2013 02:33 AM

hm, have to check what's the problem with the example page is.
the page exists, and it worked, now it stopped working, so possible a bitbucket issue
thank's for the hint, will see what I can do

a4z 11-10-2013 02:49 AM

seems to be a bitbucket issue, bug is already reported
https://bitbucket.org/site/master/is...i-page-getting

a4z 11-11-2013 11:45 PM

bitbucket fixed the issue so the expample page is back
https://bitbucket.org/a4z/sbbdep/wiki/examples

arsivci0 11-12-2013 03:48 AM

From ldd man page:

Quote:

$ objdump -p /path/to/program | grep NEEDED

arsivci0 11-12-2013 03:54 AM

Quote:

Originally Posted by a4z (Post 5061720)
if you are looking for info about binary dependencies, try this

https://bitbucket.org/a4z/sbbdep/wiki/Home

Bookmarked! Thanks.

sebre 11-12-2013 06:18 AM

Quote:

Originally Posted by WhiteHotLoveTiger (Post 5061714)
As I think about it more, I'm thinking that maybe it's not specific to Slackware, and maybe it takes only an installed program name as input as lists the libraries it links to? Does that sound more reasonable? I think this might be what it does.

P.V. recommends "readelf -d", See http://http://www.linuxquestions.org/questions/slackware-14/best-practices-for-mainlining-sanity-installing-and-removing-packages-4175469854/page2.html#post4992159 :

Quote:

Originally Posted by volkerdi (Post 4992159)
IMHO, it's better to use "readelf -d" to check for library dependencies than it is to use "ldd". That way you only see which libraries are directly linked with the binary (and not all the libraries linked to those libraries, etc.)

Using ldd can leave you thinking that there's a lot more stuff to rebuild after an soname bump than there actually is.


a4z 11-12-2013 06:57 AM

readelf is basically what sbbdep does. it uses elfio to explore the binaries
since it caches information it reports the packages and possible alternatives, or reports something as missing if not available
and it tells what programs do need a library/package
it has also a ldd option to use the ldd lookup,
and some other stuff
so in some sense it is like a swiss army knive that brings together some functionality

gnashley 11-12-2013 10:49 AM

The objdump command shown does the same as the readelf command shown. Either of them are much safer than using ldd because using ldd actually executes(tries anyway) the command in order to track what it gets linked to. If the binary in question is malicious then simply having a look with ldd lets it do its thing, whereas reading the ELF header using objdump or readelf makes no attempt to execute the thing.

This is not perfect, but makes a nice replacement to using ldd:
Code:

#!/bin/bash
# Copyright 2009-2013 Gilbert Ashley <amigo@ibiblio.org>
# re-written from an idea by
# Ricardo Garcia Gonzalez.
# His version needed bash-4, awk, cat, cut, grep and tr -plus objdump
# This only needs bash >=3.0 and objdump :-)
# I added the "not found" report
# version 0.1
# version 0.2 added a commented-out alternative method using readelf

if [[ -n $1 ]] ; then
  declare MY_LIBS="$(objdump -p $@ |grep NEEDED)"
  # results look like this:
  #'  NEEDED              libc.so.6'
 
  # Hmm, we can get similar output using:
  # readelf -d $@ |grep '(NEEDED)'
  # which returns something like this:
  #'0x00000001 (NEEDED)                    Shared library: [libc.so.6]'
  # declare MY_LIBS=$(readelf -d $@ |grep '(NEEDED)'|cut -f2 -d'[' |cut -f1 -d ']')
 
 
  # Library directories.
  LIBDIRS=${LD_LIBRARY_PATH//:/ }"/lib$LIBDIRSUFFIX /usr/lib$LIBDIRSUFFIX"
  if [[ -r /etc/ld.so.conf ]] ; then
        while read LINE ; do
                LIBDIRS=${LIBDIRS}" $LINE"
        done < /etc/ld.so.conf
  fi

  #LIBDIRS=${LIBDIRS}${LD_LIBRARY_PATH//:/ }

  for LINE in $(echo $MY_LIBS) ; do
        HAVE_LIB=0
        if [[ $LINE != "NEEDED" ]] ; then
                for LIBDIR in $LIBDIRS ; do
                        if [[ -e "$LIBDIR/$LINE" ]] ; then
                                # don't use '-x' which requires the lib to be executable
                                HAVE_LIB=1
                                echo "$LIBDIR/$LINE"
                                # for an output more like the real ldd:
                                # echo "$LINE => $LIBDIR/$LINE"
                                break
                        else
                                continue
                        fi
                done
                if [[ $HAVE_LIB != 1 ]] ; then
                        echo "$LINE"" not found"
                        # for an output more like the real ldd:
                        # echo "$LINE => not found"
                fi
        fi
  done
fi



All times are GMT -5. The time now is 09:38 AM.