Skip to content

Instantly share code, notes, and snippets.

@jtyr
Created May 5, 2017 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtyr/45f78cbe97755a02dc01027b4711bb7b to your computer and use it in GitHub Desktop.
Save jtyr/45f78cbe97755a02dc01027b4711bb7b to your computer and use it in GitHub Desktop.
Bash function which helps to print out the RPM dependency tree for a specific package.
function walk() {
if [ $1 == 0 ]; then
echo -n "" > /tmp/deps;
fi
echo $2 >> /tmp/deps;
for N in $(seq $1); do
echo -n ' ';
done
echo -n '- ';
echo $2;
DEPS=$(rpm -q --whatrequires $2 | grep -v 'no package' | sort -u | sed 's/-[0-9].*//');
for D in $DEPS; do
if [ $(egrep "^$D$" /tmp/deps | wc -l) == "0" ]; then
walk $(( $1 + 1 )) $D;
fi
done
}
walk 0 perl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment