#!/bin/bash # Print packages containing libraries used by two or more binaries if [ -z "${1}" ]; then echo "Use `basename ${0}` --help for options." exit elif [ "${1}" = "--help" ]; then echo "Usage: `basename ${0}` [ --emerge ] [ --help ] binary1 binary2" echo "The --emerge flag will emerge all shared dependencies." exit elif [ "$#" -lt "2" ]; then echo "`basename ${0}` requires two or more binaries as arguments." exit elif [ "${1}" = "--emerge" ]; then shift for i in $(sudo ldd `which ${@}` | cut -d' ' -f3 | grep -v \: | sort | uniq -d) do qpkg -nc -f ${i} done | sort | uniq -d | xargs sudo emerge elif [ "${1}" != "--emerge" ]; then for i in $(sudo ldd `which ${@}`| cut -d' ' -f3 | grep -v \: | sort | uniq -d) do qpkg -nc -f ${i} done | sort | uniq -d else echo "You did something wrong. Try `basename ${0}` --help." fi