depdot.sh 839 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # Script to output the dependency graph of Gluon's packages
  3. # Limitations:
  4. # * Works only if directory names and package names are the same (true for all Gluon packages)
  5. # * Doesn't show dependencies through virtual packages correctly
  6. shopt -s nullglob
  7. pushd "$(dirname "$0")/.." >/dev/null
  8. escape_name() {
  9. echo -n "_$1" | tr -c '[:alnum:]' _
  10. }
  11. print_node () {
  12. echo "$(escape_name "$1") [label=\"$1\", shape=box];"
  13. }
  14. print_dep() {
  15. echo "$(escape_name "$1") -> $(escape_name "$2");"
  16. }
  17. echo 'digraph G {'
  18. for makefile in ./package/*/Makefile; do
  19. dir="$(dirname "$makefile")"
  20. package="$(basename "$dir")"
  21. deps=$(grep -w DEPENDS "$makefile" | cut -d= -f2 | tr -d +)
  22. print_node "$package"
  23. for dep in $deps; do
  24. print_node "$dep"
  25. print_dep "$package" "$dep"
  26. done
  27. done | sort -u
  28. popd >/dev/null
  29. echo '}'