4 if (! -d "bin" || ! -d "SL") {
5 print("This tool must be run from the Lx-Office ERP base directory.\n");
16 $lxdebug = LXDebug->new();
27 print("dbupgrade2_tool.pl [--list] [--tree] [--rtree] [--graphviz]\n" .
28 " [--nodepds] [--help]\n");
31 sub calc_rev_depends {
32 map({ $_->{"rev_depends"} = []; } values(%{$controls}));
33 foreach my $control (values(%{$controls})) {
34 map({ push(@{$controls->{$_}{"rev_depends"}}, $control->{"tag"}) }
35 @{$control->{"depends"}});
40 my @sorted_controls = sort_dbupdate_controls($controls);
42 print("LIST VIEW\n\n");
43 print("number tag depth priority\n");
45 foreach (@sorted_controls) {
46 print("$i $_->{tag} $_->{depth} $_->{priority}\n");
54 my ($tag, $depth) = @_;
56 print(" " x $depth . $tag . "\n");
58 my $c = $controls->{$tag};
59 my $num = scalar(@{$c->{"depends"}});
60 for (my $i = 0; $i < $num; $i++) {
61 dump_node($c->{"depends"}[$i], $depth + 1);
66 print("TREE VIEW\n\n");
70 my @sorted_controls = sort_dbupdate_controls($controls);
72 foreach my $control (@sorted_controls) {
73 dump_node($control->{"tag"}, "") unless (@{$control->{"rev_depends"}});
79 sub dump_node_reverse {
80 my ($tag, $depth) = @_;
82 print(" " x $depth . $tag . "\n");
84 my $c = $controls->{$tag};
85 my $num = scalar(@{$c->{"rev_depends"}});
86 for (my $i = 0; $i < $num; $i++) {
87 dump_node_reverse($c->{"rev_depends"}[$i], $depth + 1);
91 sub dump_tree_reverse {
92 print("REVERSE TREE VIEW\n\n");
96 my @sorted_controls = sort_dbupdate_controls($controls);
98 foreach my $control (@sorted_controls) {
99 last if ($control->{"depth"} > 1);
100 dump_node_reverse($control->{"tag"}, "");
107 print("GRAPHVIZ POSTCRIPT\n\n");
108 print("Output will be written to db_dependencies.ps\n");
110 open(OUT, "${dot}> db_dependencies.ps");
112 "digraph db_dependencies {\n" .
113 "node [shape=box];\n");
115 foreach my $c (values(%{$controls})) {
116 $ranks{$c->{"depth"}} = [] unless ($ranks{$c->{"depth"}});
117 push(@{$ranks{$c->{"depth"}}}, $c->{"tag"});
119 foreach (sort(keys(%ranks))) {
120 print(OUT "{ rank = same; " .
121 join("", map({ '"' . $_ . '"; ' } @{$ranks{$_}})) .
124 foreach my $c (values(%{$controls})) {
125 print(OUT "$c->{tag};\n");
126 foreach my $d (@{$c->{"depends"}}) {
127 print(OUT "$c->{tag} -> $d;\n");
137 print("SCRIPTS NO OTHER SCRIPTS DEPEND ON\n\n" .
140 grep({ !@{$_->{"rev_depends"}} }
141 values(%{$controls})))) .
149 eval { require "lx-erp.conf"; };
152 $locale = Locale->new("de", "login");
158 my ($opt_list, $opt_tree, $opt_rtree, $opt_nodeps, $opt_graphviz, $opt_help);
160 GetOptions("list" => \$opt_list,
161 "tree" => \$opt_tree,
162 "rtree" => \$opt_rtree,
163 "nodeps" => \$opt_nodeps,
164 "graphviz" => \$opt_graphviz,
165 "help" => \$opt_help,
173 $controls = parse_dbupdate_controls($form, "Pg");