4 if (! -d "bin" || ! -d "SL") {
5 print("This tool must be run from the Lx-Office ERP base directory.\n");
18 $lxdebug = LXDebug->new();
29 print("dbupgrade2_tool.pl [--list] [--tree] [--rtree] [--graphviz]\n" .
30 " [--nodepds] [--help]\n");
33 sub calc_rev_depends {
34 map({ $_->{"rev_depends"} = []; } values(%{$controls}));
35 foreach my $control (values(%{$controls})) {
36 map({ push(@{$controls->{$_}{"rev_depends"}}, $control->{"tag"}) }
37 @{$control->{"depends"}});
42 my @sorted_controls = sort_dbupdate_controls($controls);
44 print("LIST VIEW\n\n");
45 print("number tag depth priority\n");
47 foreach (@sorted_controls) {
48 print("$i $_->{tag} $_->{depth} $_->{priority}\n");
56 my ($tag, $depth) = @_;
58 print(" " x $depth . $tag . "\n");
60 my $c = $controls->{$tag};
61 my $num = scalar(@{$c->{"depends"}});
62 for (my $i = 0; $i < $num; $i++) {
63 dump_node($c->{"depends"}[$i], $depth + 1);
68 print("TREE VIEW\n\n");
72 my @sorted_controls = sort_dbupdate_controls($controls);
74 foreach my $control (@sorted_controls) {
75 dump_node($control->{"tag"}, "") unless (@{$control->{"rev_depends"}});
81 sub dump_node_reverse {
82 my ($tag, $depth) = @_;
84 print(" " x $depth . $tag . "\n");
86 my $c = $controls->{$tag};
87 my $num = scalar(@{$c->{"rev_depends"}});
88 for (my $i = 0; $i < $num; $i++) {
89 dump_node_reverse($c->{"rev_depends"}[$i], $depth + 1);
93 sub dump_tree_reverse {
94 print("REVERSE TREE VIEW\n\n");
98 my @sorted_controls = sort_dbupdate_controls($controls);
100 foreach my $control (@sorted_controls) {
101 last if ($control->{"depth"} > 1);
102 dump_node_reverse($control->{"tag"}, "");
109 print("GRAPHVIZ POSTCRIPT\n\n");
110 print("Output will be written to db_dependencies.ps\n");
112 open(OUT, "${dot}> db_dependencies.ps");
114 "digraph db_dependencies {\n" .
115 "node [shape=box];\n");
117 foreach my $c (values(%{$controls})) {
118 $ranks{$c->{"depth"}} = [] unless ($ranks{$c->{"depth"}});
119 push(@{$ranks{$c->{"depth"}}}, $c->{"tag"});
121 foreach (sort(keys(%ranks))) {
122 print(OUT "{ rank = same; " .
123 join("", map({ '"' . $_ . '"; ' } @{$ranks{$_}})) .
126 foreach my $c (values(%{$controls})) {
127 print(OUT "$c->{tag};\n");
128 foreach my $d (@{$c->{"depends"}}) {
129 print(OUT "$c->{tag} -> $d;\n");
139 print("SCRIPTS NO OTHER SCRIPTS DEPEND ON\n\n" .
142 grep({ !@{$_->{"rev_depends"}} }
143 values(%{$controls})))) .
151 eval { require "lx-erp.conf"; };
154 $locale = Locale->new("de", "login");
160 my ($opt_list, $opt_tree, $opt_rtree, $opt_nodeps, $opt_graphviz, $opt_help);
162 GetOptions("list" => \$opt_list,
163 "tree" => \$opt_tree,
164 "rtree" => \$opt_rtree,
165 "nodeps" => \$opt_nodeps,
166 "graphviz" => \$opt_graphviz,
167 "help" => \$opt_help,
175 $controls = parse_dbupdate_controls($form, "Pg");