All pastes #1427480 Raw Edit

libdep

public shellscript v1 · immutable
#1427480 ·published 2009-05-19 14:33 UTC
rendered paste body
#!/bin/bash# Developed by Anders Juel Jensen - andersjjensen at gmail dot com# This script is in the public domain - do what the heck ever you like# with it. And you dont even have to pass credits (bonus huh?)MATCHLIST=$(tempfile)FILELIST=$(tempfile)TEMPLIST=$(tempfile)DEPLIST=$(tempfile)# Check if user has a clue...if [ -z $1 ]; then  echo "DUDE!!! You must point me to a package log.."  echo "Those from /var/log/packages/, you know?"  exit 127fi# Pry the file list out of the packagelog. Prefix each line with / .# Find the relevant types of files. Save to file.for i in $(grep -v : $1 | grep -v install\/); do  j="/$i"  file $j | grep "executable" | grep ELF | cut -f 1 -d : >> $FILELIST  file $j | grep "shared object" | grep ELF | cut -f 1 -d : >> $FILELISTdone# Get the binaries to spill their little dirty secrets about hard runtime-linking dependencies.for i in $(cat $FILELIST); do  objdump -p $i | grep NEEDED | cut -d ' ' -f 18 >> $TEMPLISTdone# Sort and strip out dublicates to speed up grepping /var/log/packages/*cat $TEMPLIST | sort -u > $MATCHLIST# Find the relevant packages. Make sure a package doesn't show up as depending on itself.# Strip of the version and build numbers. Strip strip the /var/log/packages/ part. Collect the results.grep -l -f $MATCHLIST /var/log/packages/* | grep -v $(basename $1) | sed 's/\(.*\)-.*-.*-.*/\1/;' | cut -d \/ -f 5 >> $DEPLIST# Which package are we inspecting?PACK=$(echo -n $(basename $1 | sed 's/\(.*\)-.*-.*-.*/\1/;'))# If the package has dependencies, write out tsort'able pairs (the order is not relevant)if [ -s $DEPLIST ]; then  for i in $(cat $DEPLIST); do    echo "$PACK $i"  donefirm $MATCHLIST $FILELIST $TEMPLIST $DEPLIST