WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: visualize dependencies  (Read 4026 times)

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
visualize dependencies
« on: September 08, 2011, 05:28:34 PM »
Needs graphviz and optionally eog.

Invoking
Code: [Select]
./tce-depends.sh graphviz generates this output:


Code: [Select]
#!/bin/sh

tcedone="/tmp/tcedone.$$"
touch ${tcedone}
tcedir="$(cat /opt/.tce_dir)"

depends()
{
   grep -v "^ *$" 2>/dev/null ${tcedir}/optional/$1.tcz.dep |
   while read tce; do
      tce=${tce%.tcz}
      echo "\"${1}\" -> \"${tce}\""
      if ! grep -q "^${tce}.tcz$" ${tcedone}; then
         echo ${tce}.tcz >> ${tcedone}
         depends "${tce}"
      fi
   done
}

(
echo "digraph connect {"
echo "rankdir = LR;"
echo "layout = dot;"
echo "node [ shape = box ];"
echo "\"$1\" [ style = filled, fillcolor = lightgrey ];"

depends "$1"
rm -f ${tcedone}

echo "}"
) | dot -Tpng -o${1}.png
eog ${1}.png && rm -f ${1}.png

Edit: included image from attachments
« Last Edit: September 08, 2011, 05:30:16 PM by SvOlli »

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: visualize dependencies
« Reply #1 on: September 08, 2011, 06:55:24 PM »
Great :D

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: visualize dependencies
« Reply #2 on: September 09, 2011, 01:06:56 AM »
!Like
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Re: visualize dependencies
« Reply #3 on: September 09, 2011, 07:53:34 PM »
Hi SvOlli,
Just curious:  was the script I posted a couple of weeks ago that does the same thing not working for you?   http://forum.tinycorelinux.net/index.php/topic,11300.0.html

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: visualize dependencies
« Reply #4 on: September 09, 2011, 08:18:13 PM »
@ixbiran: I obviously can't speak for SvOlli, but I had thought of re-writing your Perl script myself as a shell (or 'awk') script to not require 'perl5.tcz' (and yes, I now that 'microperl-5.8.9.tcz' would probably be enough).

Don't get me wrong, I REALLY like Perl, but I've in the last two years learned how much you can do with just the BusyBox tools, that I sometimes rewrite my own Perl scripts just for the fun of it.

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Re: visualize dependencies
« Reply #5 on: September 09, 2011, 08:23:59 PM »
@ixbiran: I obviously can't speak for SvOlli, but I had thought of re-writing your Perl script myself as a shell (or 'awk') script to not require 'perl5.tcz' (and yes, I now that 'microperl-5.8.9.tcz' would probably be enough).

Don't get me wrong, I REALLY like Perl, but I've in the last two years learned how much you can do with just the BusyBox tools, that I sometimes rewrite my own Perl scripts just for the fun of it.

Perl is a dependency of Graphviz so you're going to need Perl either way  :)

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: visualize dependencies
« Reply #6 on: September 09, 2011, 08:37:04 PM »
Helli ixbrian,
Just curious:  was the script I posted a couple of weeks ago that does the same thing not working for you?   
I didn't know about your script until now. My script is more a byproduct of my hacking up a script that generates a visual representation of a Qt state machine. It was just the result of having fun for a couple of minutes.

... but I've in the last two years learned how much you can do with just the BusyBox tools, that I sometimes rewrite my own Perl scripts just for the fun of it.
I have not written any perl for several years now, so I've gone out of practice. I'm quicker hacking up a shell script to get things done, than picking up my perl-pieces again.