Skip to content

Commit

Permalink
Merge pull request freifunk-gluon#2974 from freifunk-gluon/depdot
Browse files Browse the repository at this point in the history
contrib: depdot: use processed package info
  • Loading branch information
neocturne authored Sep 10, 2023
2 parents 84357cd + 57a95b0 commit 0db797c
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions contrib/depdot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,27 +15,42 @@ escape_name() {
echo -n "_$1" | tr -c '[:alnum:]' _
}

print_node () {
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_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
Expand Down

0 comments on commit 0db797c

Please sign in to comment.