#!/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) # 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 127 fi # Pry the file list out of the packagelog, and find the relevant types of files for i in $(grep \/ $1 | grep -v LOCATION); 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 : >> $FILELIST done # Get the binaries to spill their little dirty secrets about hard dependencies for i in $(cat $FILELIST); do objdump -p $i | grep NEEDED | cut -d ' ' -f 18 >> $TEMPLIST done # Sort and strip out dublicates to speed up grepping /var/log/packages/* cat $TEMPLIST | sort -u > $MATCHLIST # Find the relevant packages, and make sure a package doesn't show up as depending on itself... grep -l -f $MATCHLIST /var/log/packages/* | grep -v $(basename $1)