quarta-feira, 22 de junho de 2011

making a .dot (graphviz) graph of RPM dependencies

http://www.singularity.be/2008/07/making-dot-graphviz-graph-of-rpm.html

nice tool for making .dot graphs with RPM dependecies on installed system:


#!/bin/bash

# deps:
# bash
# rpm
# sed
# cut
# uniq
# sort

installedrpms=$(rpm -qa --queryformat "%{NAME}\n")


function printdeps() {
local package deps dep providedby out

package=$1
out=""
deps=$(rpm -qR $package | cut -d " " -f 1)

for dep in $deps;
do
providedby=$(rpm -q --queryformat "%{NAME}\n" --whatprovides "$dep")
if [ $? -eq 0 ];
then
# packages should not depend on themselves
if [ "$package" != "$providedby" ];
then
out="$out\"$package\" -> \"$providedby\";\n"
fi
fi
done

echo $out
}

alloutput=""

for i in $installedrpms;
do
output=$(printdeps $i)
alloutput="$alloutput$output"
done


echo "digraph deptree {"
echo -e "$alloutput" | sort | uniq
echo "}"

Nenhum comentário: