From 1e78665b12cc4fc7d5ea03c6b23f099c5ef44f3e Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 28 Feb 2016 20:01:19 +0100 Subject: [PATCH] Add contrib/depdot.sh This script will analyze the dependencies of Gluon's packages and output them as a dot graph. --- contrib/depdot.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 contrib/depdot.sh diff --git a/contrib/depdot.sh b/contrib/depdot.sh new file mode 100755 index 00000000..c065ea57 --- /dev/null +++ b/contrib/depdot.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Script to output the dependency graph of Gluon's packages +# Limitations: +# * Works only if directory names and package names are the same (true for all Gluon packages) +# * Doesn't show dependencies through virtual packages correctly + + + +shopt -s nullglob + + +pushd "$(dirname "$0")/.." >/dev/null + + +escape_name() { + echo -n "_$1" | tr -c '[:alnum:]' _ +} + +print_node () { + echo "$(escape_name "$1") [label=\"$1\", shape=box];" +} + +print_dep() { + echo "$(escape_name "$1") -> $(escape_name "$2");" +} + +echo 'digraph G {' + +for makefile in ./package/*/Makefile; do + dir="$(dirname "$makefile")" + package="$(basename "$dir")" + + deps=$(grep -w DEPENDS "$makefile" | cut -d= -f2 | tr -d +) + + print_node "$package" + for dep in $deps; do + print_node "$dep" + print_dep "$package" "$dep" + done +done | sort -u + +popd >/dev/null + +echo '}'