LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-21-2004, 01:02 PM   #1
boemitsu
LQ Newbie
 
Registered: Dec 2003
Location: Zurich
Distribution: slackware 9.1, mandrake 9.1
Posts: 17

Rep: Reputation: 0
which lib is in which package ?


hi all

how can i found out (well, besides googling around) which libraray is in which package ?

is there an easy way to do this ?

thx
 
Old 12-21-2004, 01:18 PM   #2
rusty_slacker
Member
 
Registered: Sep 2004
Location: Mars, right next to the UAC base
Distribution: Fedora Core 3/Knoppix 3.4
Posts: 138

Rep: Reputation: 15
if you have kde-utils 3.2, kpackage is good.
 
Old 12-21-2004, 01:19 PM   #3
WMD
Member
 
Registered: Jul 2004
Location: Florida
Distribution: Slackware, Debian
Posts: 484

Rep: Reputation: 30
I love being helpful.

Code:
#!/bin/sh
#*******************************************************************************
# Script by thegeekster of the famed linuxquestions.org
# Name: whichpkg

search_pkgs() {
  name1="/${1}\>"

  find /var/log/packages/* -type f -prune | while read file
  do
    # This makes certain assumptions about where to look, such as
    # ignoring certain directories and files which are easy to figure
    # out where the files came from:
    cat $file | egrep -A5000 'FILE\ LIST:' | egrep -i "${name1}\$"\
      | egrep -v '(FILE\ LIST:|^\./$|\<install/|\<install-sh|\<install\.sh)' \
      | egrep -v '(usr/src/linux|doc/|share/$1)' \
      | while read line
    do
      [ ! -d $file ] && echo "`basename $file`:/$line"
    done
  done

  # Due to a problem of a broken pipe when trying to find any symlinks
  # associated with the file "ln", I had to find a workaround.
  name2="\<${1}\>"
  [ "$1" = "ln" ] && name2="\<ln\>\ [^-rf]"
  [ "$1" = "rm" ] && name2="\<rm\>\ [^-rf]"

  find /var/log/scripts/* -type f -prune | while read file
  do
    cat $file | egrep -i "$name2" \
      | egrep -v '(^#|:| \<rm\ -r\>|\<if\ |\<else\ |>>|\$|\<for\ .*\ in\>|doinst\.sh)' \
      | while read line
    do
      [ ! -z "`echo $line | egrep '\<ln\ -sf' |egrep '\(\ cd'`" ] \
        && echo "`basename $file`:/`echo $line \
        | awk '{ print $3\"/\"$8\"  --linked-to->  \"$7 }'`"
      [ ! -z "`echo $line | egrep '\<mv\ '`" ] \
        && echo "`basename $file`:/`echo $line | sed 's/^.*\(\<mv\ \)/\1/' \
        | awk '{ print $2\"  --renamed-to->  \"$3 }'`"
    done
  done
}

case $1 in
  "" | -h | --help )  # If no argument is given, or -h (--help) is given,
                         # as an argument then show the usage.
    cat << "__EOF__"  | less

Usage: whichpkg FILE1 [ FILE2 ... ]

Finds which Slackware package contains the file supplied on the command
line. A filename must be supplied and more than one filenam may be used
on the command line. For pattern matching, you may use the wildcards *
and ?. For example, to find the files "bzip" and "bzip2", you may use
the pattern "bzip?" to look for both files. The search is case
insensitive (upper- or lowercase is okay). You may also enclose the
search pattern in single quotes (') or double quotes (") to avoid the
shell interpeter from interfering with the search term when using the
wildcard characters.

The output was made to be as easy as possible to read and the output
for each search term is easily identifiable. Each matching line will
look something link this:

    <package_name>:<matched_path>

For symlink matches, the output will look something like this:

    <package_name>:<matched_symlink>  -- linked to->  <real_file>

If a file was renamed when installed, the output will look something
like this:

    <package_name>:<old_filename>  -- renamed to->  <new_filename>

To give you an idea, here's a sample output for the search for the
multiple terms "sh" and "bash":

$ whichpkg sh bash
------------------------------------------------------------------------
Searching for "sh"...

aaa_base-9.1.0-noarch-1:/bin/sh  --linked to->  bash

------------------------------------------------------------------------
------------------------------------------------------------------------
Searching for "bash"...

aaa_base-9.1.0-noarch-1:/bin/sh  --linked to->  bash
bash-2.05b-i486-3:/bin/bash  --renamed to->  bin/bash.old
bash-2.05b-i486-3:/bin/bash2.new  --renamed to->  bin/bash
bash-2.05b-i486-3:/usr/bin/bash  --linked to->  /bin/bash

------------------------------------------------------------------------


HOTE: The searches will take a couple of moments for each term being
      searched and some searches may take longer than others, depending
      on the keyword used. Usually it depends on how many occurrences of
      the keyword is found, which then must be analyzed and filtered.

__EOF__
		;;
  * )
    while [ ! -z "$1" ]
    do
      i="`basename \`echo \"$1\" | sed 's/\./\\./g; s/\*/.*/; s/\?/.?/g'\``"
      echo "------------------------------------------------------------------------"
      echo -e "Searching for \"${1}\"...\n"
      search_pkgs "$i" | sort
      echo -e "\n------------------------------------------------------------------------"
      shift
    done	;;
esac
Just save that to a file, make it executable (chmod +x), and run it.
 
Old 12-21-2004, 01:20 PM   #4
rusty_slacker
Member
 
Registered: Sep 2004
Location: Mars, right next to the UAC base
Distribution: Fedora Core 3/Knoppix 3.4
Posts: 138

Rep: Reputation: 15
hot damn! that is kool.
 
Old 12-21-2004, 04:56 PM   #5
boemitsu
LQ Newbie
 
Registered: Dec 2003
Location: Zurich
Distribution: slackware 9.1, mandrake 9.1
Posts: 17

Original Poster
Rep: Reputation: 0
thx

this is wonderful and works great...!!
 
Old 12-21-2004, 06:00 PM   #6
egag
Senior Member
 
Registered: Jul 2004
Location: Netherlands
Distribution: Slackware
Posts: 2,721

Rep: Reputation: 53
to find for example the package that contains " libproc.so.3.2.1 ", i'd do :


$grep libproc.so.3.2.1 /var/log/packages/*
/var/log/packages/procps-3.2.1-i486-1:lib/libproc.so.3.2.1

isn't that the same as the script does ?

egag
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Foobar.lib Package inescapeableus Linux - Software 2 06-21-2005 06:19 PM
compilation error with alsa-lib package prem0 Red Hat 2 12-09-2004 03:40 PM
kde lib for compiling broken package qwertyuiop Debian 5 10-01-2004 06:31 PM
lib png package Culbert Linux - Software 0 03-16-2003 11:33 AM
How do I upgrade a package or lib without using rpm or pkgtool? purpleburple Linux - General 4 10-16-2002 08:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration