Hello all, I've just finished off LFS 6.8 with dpkg 1.15.8.10 as the package manager. It's my pet project, although using dpkg does add another layer of complexity. Over the course of doing this, I created a shell script to help out with runtime dependencies and would like to share it with you. I figure that there's an outside chance someone else might get some use out of it. Of course, suggestions are always welcome.
---*---*--- #!/bin/sh set -e # dep.sh: Shell script to help out with dependencies # Created by Andrew Elian <[email protected]> # # Copyright ???? Who'd want to copy this anyway ???? 2010 # Okay, then GPL it is. # # There are *official* debian tools which look like they do the same thing. # Hmmm. Might have to look into those # # Needs a DEPFILE, dpkg and the usual command line tools # to work correctly # # DEPFILE is a flat text file with the listing of # deb packages installed and their respective deb dep # eg. essential-files_0.1_amd64.deb: essential-files (= 0.1) DEPFILE="/usr/share/dLFS/Dependencies" if [ $1 = "-h" ]; then echo "dep.sh, the dpkg dependency finder version 0.3" echo "Finds all runtime dependencies in current directory: dep.sh" echo "Finds all runtime dependencies of app or shared object: dep.sh foo" exit 0 fi if [ "$1" = "" ]; then echo "Finding shared libs and executables" process=$( for A in $(find . | xargs file |grep -e "executable" -e "shared" | grep ELF | cut -f 1 -d:) do objdump -p $A | grep NEEDED | cut -d ' ' -f 18 # Use just the name done ) else process=$(objdump -p "$1" |grep NEEDED | cut -d ' ' -f 18) fi # Find which packages the libs and executables belong to results(){ for package in $process do dpkg -S $package | cut -d: -f1 | sort -u >> /tmp/dep-tempfile.1 done } # Get the dep part from Dependencies compare(){ for C in $(sort -u /tmp/dep-tempfile.1) do grep -i "${C}_" $DEPFILE | grep -v '#' | # ignore lines with hash marks - are comments cut -d : -f 2 >> /tmp/dep-tempfile.2 done } # Tidy up the output. sed adds a comma, xargs puts it into one line # and then sed takes just the last comma off output(){ sed 's/)/),/' /tmp/dep-tempfile.2 | xargs | sed 's/\(.*\)./\1/' } clean(){ rm /tmp/dep-tempfile.1 /tmp/dep-tempfile.2 } ### Main Program ### echo "Getting Results" results echo "Comparing against $DEPFILE" compare echo output echo echo "Cleaning up" clean echo "All Done!" ---*---*--- Cheers, ae -- My Blog: http://elian001.wordpress.com -- http://linuxfromscratch.org/mailman/listinfo/lfs-chat FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
