diff --git a/contrib/depdot.sh b/contrib/depdot.sh index 4e0a940685..36fbe496bb 100755 --- a/contrib/depdot.sh +++ b/contrib/depdot.sh @@ -2,7 +2,6 @@ # 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 set -e @@ -16,7 +15,7 @@ escape_name() { echo -n "_$1" | tr -c '[:alnum:]' _ } -print_node () { +print_node() { echo "$(escape_name "$1") [label=\"$1\", shape=box];" } @@ -24,19 +23,34 @@ 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_package() { + local package="$1" depends="$2" + # shellcheck disable=SC2086 + set -- $depends print_node "$package" - for dep in $deps; do + for dep in "$@"; do print_node "$dep" print_dep "$package" "$dep" done +} + +make -C openwrt -s prepare-tmpinfo + +echo 'digraph G {' + +cat ./openwrt/tmp/info/.packageinfo-feeds_gluon_base_* | while read -r key value; do + case "$key" in + 'Package:') + package="$value" + ;; + 'Depends:') + depends="${value//+/}" + ;; + '@@') + print_package "$package" "$depends" + ;; + esac done | sort -u popd >/dev/null