#!/bin/sh
#This is the core wrapper which attempts to find
#the dependancies and print out a list suitable for slack-requires
#It handles ONE file in the package
#it is up to the calling tool (mkslack or mkpkg) to feed it the filenames
#Finally note, this tool does NOT strip duplicates, that too is up to the
#caller (Try uniq)
#Also note that it only handles ONE level of dependancies
#hopefully the packages found have their own dependancies listed sepperately.

#We start by checking for other programs being called
#this is about as far from perfect a method as you can imagine
#but it does get most of them. Although only if it specifies the path
#and that path contains bin/. I have to filter SOMEHOW
#If you can think of a better way, please tell me !

for I in `strings $1 | grep "bin/"` ; do
	SLACKNAME=`slackfile "$I"`
	PROVIDER=`slackprovider $SLACKNAME | grep -v "none"`
	slackdepname $PROVIDER
done

#Next we try for libraries, this at least is SLIGHTLY more reliable
if ldd $1 > /dev/null ; then
	for I in `ldd $1 | awk '{print $1}'` ; do
	   PROVIDER=`slackprovider $I | grep -v "none"`
	   slackdepname $PROVIDER
	done
fi
	
  
	
