initial commit
This commit is contained in:
9
support/deptree2dot/Makefile
Normal file
9
support/deptree2dot/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
MK= ../../mk
|
||||
include ${MK}/os.mk
|
||||
|
||||
DIR= ${DATADIR}/support/deptree2dot
|
||||
BIN= deptree2dot
|
||||
INC= README.md
|
||||
|
||||
|
||||
include ${MK}/scripts.mk
|
||||
11
support/deptree2dot/README.md
Normal file
11
support/deptree2dot/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# deptree2dot - Graph the OpenRC Dependency Tree
|
||||
|
||||
This utility can be used to graph the OpenRC dependency tree. It
|
||||
requires perl5.x and converts the tree to a .dot file which can be
|
||||
processed by graphviz.
|
||||
|
||||
Example usage:
|
||||
|
||||
$ chmod +x deptree2dot
|
||||
$deptree2dot > deptree.dot
|
||||
$deptree2dot | dot -Tpng -o deptree.png
|
||||
44
support/deptree2dot/deptree2dot
Normal file
44
support/deptree2dot/deptree2dot
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/perl -w
|
||||
# -*- cperl -*-
|
||||
# Copyright © 2012 Diego Elio Pettenò <flameeyes@flameeyes.eu>
|
||||
# Released under the 2-clause BSD license.
|
||||
#
|
||||
#Example usage:
|
||||
#deptree2dot > deptree.dot
|
||||
#deptree2dot | dot -Tpng -o deptree.png
|
||||
|
||||
my $deptree = defined($ARGV[0]) ? $ARGV[0] : "/run/openrc/deptree";
|
||||
|
||||
open DEPTREE, $deptree or exit 1;
|
||||
|
||||
print "digraph deptree {\n";
|
||||
|
||||
my @deptree;
|
||||
|
||||
while(my $line = readline(DEPTREE)) {
|
||||
$line =~ /^depinfo_([0-9]+)_([a-z]+)(?:_[0-9]+)?='(.*)'\n$/;
|
||||
my $index = $1;
|
||||
my $prop = $2;
|
||||
my $value = $3; $value =~ s/[-\.:~]/_/g;
|
||||
|
||||
if ( $prop eq "service" ) {
|
||||
$deptree[$index] = $value;
|
||||
printf "%s [shape=box];\n", $value;
|
||||
} else {
|
||||
my $service = $deptree[$index];
|
||||
|
||||
if ( $prop eq "ineed" ) {
|
||||
printf "%s -> %s;\n", $service, $value;
|
||||
} elsif ( $prop eq "iuse" ) {
|
||||
printf "%s -> %s [color=blue];\n", $service, $value;
|
||||
} elsif ( $prop eq "ibefore" ) {
|
||||
printf "%s -> %s [style=dotted];\n", $service, $value;
|
||||
} elsif ( $prop eq "iafter" ) {
|
||||
printf "%s -> %s [style=dotted color=purple];\n", $value, $service;
|
||||
} elsif ( $prop eq "iprovide" ) {
|
||||
printf "%s -> %s [color=red];\n", $value, $service;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "}\n";
|
||||
Reference in New Issue
Block a user