diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-06-27 20:42:16 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-06-27 23:22:26 (EDT) |
commit | a4f616cef42aedb7db142376b1e33c8480149280 (patch) | |
tree | 02aabd93f43d8b83d27e63ec0d13393206c69bc4 |
Initial commit
-rw-r--r-- | bin/depsdot | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/bin/depsdot b/bin/depsdot new file mode 100644 index 0000000..a7be98f --- /dev/null +++ b/bin/depsdot @@ -0,0 +1,81 @@ +#!/usr/bin/perl + +use strict; +use warnings; +no indirect; +use autovivification; +use English qw(-no_match_vars); + +use LWP::Simple; + +my $BASE_URL = 'http://files.proteanos.com/pub/proteanos/feeds/dev/trunk'; +my @DEP_FIELDS = qw(Depends Recommends Suggests Pre-Depends); +my @IGNORE_DEPS = qw(libc.6); + +my %bin_src_map; +my %rdeps_graph; +my %deps_graph; + +sub read_list +{ + my ($list, $is_src) = @_; + + foreach my $para (split(m{\n\n}, get($list))) { + my $package = undef; + my $source = undef; + my @deps; + foreach my $line (split(m{\n}, $para)) { + my ($name, $value) = split(m{\s*:\s*}, $line); + if ($name eq 'Package') { + $package = $value; + } + if ($name eq 'Source') { + $source = $value; + } + if (grep(m{^\Q$name\E$}, @DEP_FIELDS)) { + push(@deps, split(m{\s*,\s*}, $value)); + } + } + if (not $is_src) { + $bin_src_map{$package}{$source} = 1; + } + map({ $_ =~ s{[\s(].*$}{}; } @deps); # Vim: ) + foreach my $dep (@deps) { + next if grep(m{^\Q$dep\E$}, @IGNORE_DEPS); + $rdeps_graph{$dep}{$source} = 1; + } + } + + return; +} + +sub main +{ + my @manifest; + + @manifest = split(m{\n}, get($BASE_URL . '/Manifest')); + foreach my $aps (@manifest) { + read_list($BASE_URL . '/' . $aps . '/Packages', + ($aps =~ m{^src/})); + } + STDOUT->print("digraph deps {\n"); + foreach my $dep_bin (keys(%rdeps_graph)) { + foreach my $src (keys(%{$rdeps_graph{$dep_bin}})) { + foreach my $dep_src (keys(%{$bin_src_map{$dep_bin}})) { + next if $dep_src eq $src; + $deps_graph{$src}{$dep_src} = 1; + } + } + } + foreach my $src (sort(keys(%deps_graph))) { + foreach my $dep_src (sort(keys(%{$deps_graph{$src}}))) { + STDOUT->print("\t\"" . $src . '" -> "' . $dep_src . + "\";\n"); + } + } + STDOUT->print("}\n"); + + return 0; +} + +exit(main()); |