#!/bin/bash # # Generate dependency graph for 'dot' from the graphviz package # # Johannes Winkelmann, jw at tks6 dot net # # Note: make sure you have an up to date cache! getdep() { prt-cache printf "%e\n" --filter=^$1$ --config-set="useregex yes"|sed -e 's|,| |g' } usage() { echo "$0 " } nodelist="" printdeps() { source=$1 if [ -f $statedir/$source ]; then return fi touch $statedir/$source s=`getdep $source` path=`prt-get path $source` case "$path" in /usr/ports/base/*) c="gold1"; ;; /usr/ports/errata/*) c="darkorange2"; ;; /usr/ports/opt/*) c="lightskyblue2"; ;; /usr/ports/contrib/*) c="aquamarine2"; ;; *) c="mistyrose3"; ;; esac echo "\"$source\" [color=$c]" for p in $s; do echo "\"$source\" -> \"$p\";" done for p in $s; do printdeps $p done } if [ -z "$1" ]; then usage exit fi statedir=`mktemp -d` echo "digraph {" echo "graph [splines=true fontname=\"Verdana\" fontsize=\"9\" label=\"yellow=base orange=errata blue=opt green=contrib rose=other\"]" echo "node [shape=box fontname=\"Verdana\" fontsize=\"10\" style=filled]" printdeps $1|sort|uniq echo "}" rm -r $statedir