Slax author's Blog (RSS)
30
October2012
How to quickly find dependencies with AWK
When a Slackware package is to be installed in Slax, there are usually some missing dependencies. For example, if you install Pidgin to Slax, and then you try to run /usr/bin/pidgin, you get "error while loading shared libraries", complaining what shared library is required. How to quickly find which other Slackware's package contains it?
In the past I opened MANIFEST.bz2 file in a text editor and searched for the given library name. When found, it was necessary to scroll up many pages to find out which package contains it. But later I learned a bit of awk.
Awk is a language for processing text files. It goes through the text file, line by line, and each time a condition matches, it makes some action. As an example, lets say we're searching for a package which contains libdbus-glib-1.so. A simple one-line awk will give us exactly what we need:
awk '/Package:/ {pkg=$3} /libdbus-glib-1.so/ {print pkg}'
What it does is pretty simple. It goes through the file reads line by line. If a line contains "Package:", it remembers the third field of the line (which is currently the package name we're looking for) and then it reads on. As soon as it finds a line which contains 'libdbus-glib-1.so', it prints the last remembered package in variable 'pkg'. The output is simply what we need:
That's it :)

User comments



Ah, it's not such easy just to use slackpkg. One has to remember to edit config file, uncomment some mirror, run slackpkg update, wait for some stuff to be downloaded, and then (few minutes later) run file-search. OK I'm going to stick with awk ;)

You could use "ldd /usr/bin/pidgin", it'll tell which library is missing and then go for your awk one line script :)

Uouuu ... These tips will help me a lot, I had a headache to resolve dependencies when installing windowmaker and dockapps months ago, I had to search the internet about dependencies, with this tip is much easier, and I do not use slackpkg to search for dependencies, i think learning to solve "in the nail" is more didactic! Thank you all, and thank Tomas for his work, i use Slax in my work, was the first live distro that really met my needs. You have fans in Brasil!

Hey Tomas M
Thank you for following excellent linux practices of having source code and doing everything you learn on the way openly and transparent (How refreshing it is to see people contributing to open source playing by the rules that founded linux) two thumbs up !
I had spent a few days generating all of the dependencies for slackware 14 in a new PACKAGES.TXT and your code snippet is very useful I modded it a little to show all the packages that would be affected by the removal of "cyrus-sasl" since that is something you could verify quickly the result shows all the packages that use
cyrus-sasl cat /iso/PACKAGES.TXT | awk '/PACKAGE NAME:/ {pkg=$3} /cyrus-sasl/ {print pkg}' | sort -u you can
download the file here add
bigbass-porteus.googlecode.com/files/PACKAGES.TXT
----------------------------------------
Another much more basic simple way on a full slackware 14 install it would be useful to do this
cd /var/log/packages grep -r "libsasl2" *
Thank you for a very interesting and informative blog And you have made a lot of good positive progress on SLAX very quickly
Joe



hi tomas,
what do you think if
1.you create script to convert all slackware package (txz) to slax module/bundle, so every package available and downloadable in slax web site
2. for tracking dependency, using awk script like yo create above in this blog.
so, slax will have large module satisfy enought many user needs.
thank
huberta

if you have a large number of packages (100+), depfinder is unbeatable, but it works on slackware binary packages only (tbz2, txz etc)
depfinder.sourceforge.net

@huberta: +1
That is one feature I've used alot in 6.1.2 - getting the official Slackware package from the Slax website. If the module I need is available, I'd rather use that than a random one someone has uploaded.

@tomas:
yeah, that's a one-time-setup that has to be done when you never used slackpkg before. i don't think it's that heavy to achieve :D
the stuff that has to be downloaded is the manifest and related stuff. any other packagemanager on other distributions behave like that naturally.
how do you install/update packages on slackware without slackpkg? downloading them manually and use pkgtools by hand? *shiver* ;)

@Lightning:
On a Slackware install, I agree. Actually I need to do that during Slax development, from inside Slax, thus it vanishes each time I reboot. I would need to either preconfigure it for the Slax itself, or repeat the steps each time I boot fresh Slax (which is 20 times per day) :) Probably it would be worth the effort, yet I'm so lazy ... :)
Actually I'm mostly installing packages by downloading them and using isntallpkg manually, indeed. Old habits, you know ... :)

this could be achieved more easy ;)
slackpkg file-search libdbus-glib-1.so