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();
26 print("dbupgrade2_tool.pl [--list] [--tree] [--rtree] [--graphviz]\n" .
27 " [--nodepds] [--help]\n");
30 sub calc_rev_depends {
31 map({ $_->{"rev_depends"} = []; } values(%{$controls}));
32 foreach my $control (values(%{$controls})) {
33 map({ push(@{$controls->{$_}{"rev_depends"}}, $control->{"tag"}) }
34 @{$control->{"depends"}});
39 my @sorted_controls = sort_dbupdate_controls($controls);
41 print("LIST VIEW\n\n");
42 print("number tag depth priority\n");
44 foreach (@sorted_controls) {
45 print("$i $_->{tag} $_->{depth} $_->{priority}\n");
53 my ($tag, $depth) = @_;
55 print(" " x $depth . $tag . "\n");
57 my $c = $controls->{$tag};
58 my $num = scalar(@{$c->{"depends"}});
59 for (my $i = 0; $i < $num; $i++) {
60 dump_node($c->{"depends"}[$i], $depth + 1);
65 print("TREE VIEW\n\n");
69 my @sorted_controls = sort_dbupdate_controls($controls);
71 foreach my $control (@sorted_controls) {
72 dump_node($control->{"tag"}, "") unless (@{$control->{"rev_depends"}});
78 sub dump_node_reverse {
79 my ($tag, $depth) = @_;
81 print(" " x $depth . $tag . "\n");
83 my $c = $controls->{$tag};
84 my $num = scalar(@{$c->{"rev_depends"}});
85 for (my $i = 0; $i < $num; $i++) {
86 dump_node_reverse($c->{"rev_depends"}[$i], $depth + 1);
90 sub dump_tree_reverse {
91 print("REVERSE TREE VIEW\n\n");
95 my @sorted_controls = sort_dbupdate_controls($controls);
97 foreach my $control (@sorted_controls) {
98 last if ($control->{"depth"} > 1);
99 dump_node_reverse($control->{"tag"}, "");
106 print("GRAPHVIZ POSTCRIPT\n\n");
107 print("Output will be written to db_dependencies.ps\n");
109 open(OUT, "${dot}> db_dependencies.ps");
111 "digraph db_dependencies {\n" .
112 "node [shape=box];\n");
114 foreach my $c (values(%{$controls})) {
115 $ranks{$c->{"depth"}} = [] unless ($ranks{$c->{"depth"}});
116 push(@{$ranks{$c->{"depth"}}}, $c->{"tag"});
118 foreach (sort(keys(%ranks))) {
119 print(OUT "{ rank = same; " .
120 join("", map({ '"' . $_ . '"; ' } @{$ranks{$_}})) .
123 foreach my $c (values(%{$controls})) {
124 print(OUT "$c->{tag};\n");
125 foreach my $d (@{$c->{"depends"}}) {
126 print(OUT "$c->{tag} -> $d;\n");
136 print("SCRIPTS NO OTHER SCRIPTS DEPEND ON\n\n" .
139 grep({ !@{$_->{"rev_depends"}} }
140 values(%{$controls})))) .
148 eval { require "lx-erp.conf"; };
151 $locale = Locale->new("de", "login");
157 my ($opt_list, $opt_tree, $opt_rtree, $opt_nodeps, $opt_graphviz, $opt_help);
159 GetOptions("list" => \$opt_list,
160 "tree" => \$opt_tree,
161 "rtree" => \$opt_rtree,
162 "nodeps" => \$opt_nodeps,
163 "graphviz" => \$opt_graphviz,
164 "help" => \$opt_help,
172 $controls = parse_dbupdate_controls($form, "Pg");