From 57a95b08d5ee58efcb2e96fca4268d910530d40b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 7 Sep 2023 23:15:06 +0200 Subject: [PATCH] contrib: depdot: use processed package info Instead of poorly parsing Makefiles using grep, use OpenWrt's processed package info files. This fixes handling of DEPENDS fields spanning multiple lines and adds support for source packages building multiple binary packages. Closes #2814 --- contrib/depdot.sh | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) 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