Revision 53c7990b
Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt
SL/DBUpgrade2.pm | ||
---|---|---|
27 | 27 |
|
28 | 28 |
my $control = { |
29 | 29 |
"priority" => 1000, |
30 |
"depends" => [], |
|
30 |
"depends" => [],
|
|
31 | 31 |
}; |
32 | 32 |
|
33 | 33 |
while (<IN>) { |
... | ... | |
49 | 49 |
|
50 | 50 |
$control->{charset} ||= Common::DEFAULT_CHARSET; |
51 | 51 |
|
52 |
_control_error($form, $file_name, |
|
53 |
$locale->text("Missing 'tag' field.")) |
|
54 |
unless ($control->{"tag"}); |
|
55 |
|
|
56 |
_control_error($form, $file_name, |
|
57 |
$locale->text("The 'tag' field must only consist of " . |
|
58 |
"alphanumeric characters or the carachters " . |
|
59 |
"- _ ( )")) |
|
60 |
if ($control->{"tag"} =~ /[^a-zA-Z0-9_\(\)\-]/); |
|
52 |
if (!$control->{"tag"}) { |
|
53 |
_control_error($form, $file_name, $locale->text("Missing 'tag' field.")) ; |
|
54 |
} |
|
61 | 55 |
|
62 |
_control_error($form, $file_name, |
|
63 |
sprintf($locale->text("More than one control file " . |
|
64 |
"with the tag '%s' exist."), |
|
65 |
$control->{"tag"})) |
|
66 |
if (defined($all_controls{$control->{"tag"}})); |
|
56 |
if ($control->{"tag"} =~ /[^a-zA-Z0-9_\(\)\-]/) { |
|
57 |
_control_error($form, $file_name, $locale->text("The 'tag' field must only consist of alphanumeric characters or the carachters - _ ( )")) |
|
58 |
} |
|
67 | 59 |
|
68 |
_control_error($form, $file_name,
|
|
69 |
sprintf($locale->text("Missing 'description' field.")))
|
|
70 |
unless ($control->{"description"});
|
|
60 |
if (defined($all_controls{$control->{"tag"}})) {
|
|
61 |
_control_error($form, $file_name, sprintf($locale->text("More than one control file with the tag '%s' exist."), $control->{"tag"}))
|
|
62 |
}
|
|
71 | 63 |
|
72 |
$control->{"priority"} *= 1; |
|
73 |
$control->{"priority"} = 1000 unless ($control->{"priority"}); |
|
64 |
if (!$control->{"description"}) { |
|
65 |
_control_error($form, $file_name, sprintf($locale->text("Missing 'description' field."))) ; |
|
66 |
} |
|
74 | 67 |
|
75 |
$control->{"file"} = $file; |
|
68 |
$control->{"priority"} *= 1; |
|
69 |
$control->{"priority"} ||= 1000; |
|
70 |
$control->{"file"} = $file; |
|
76 | 71 |
|
77 |
map({ delete($control->{$_}); } qw(depth applied));
|
|
72 |
delete @{$control}{qw(depth applied)};
|
|
78 | 73 |
|
79 | 74 |
$all_controls{$control->{"tag"}} = $control; |
80 | 75 |
|
... | ... | |
83 | 78 |
|
84 | 79 |
foreach my $control (values(%all_controls)) { |
85 | 80 |
foreach my $dependency (@{$control->{"depends"}}) { |
86 |
_control_error($form, $control->{"file"}, |
|
87 |
sprintf($locale->text("Unknown dependency '%s'."), |
|
88 |
$dependency)) |
|
89 |
if (!defined($all_controls{$dependency})); |
|
81 |
_control_error($form, $control->{"file"}, sprintf($locale->text("Unknown dependency '%s'."), $dependency)) if (!defined($all_controls{$dependency})); |
|
90 | 82 |
} |
91 | 83 |
|
92 | 84 |
map({ $_->{"loop"} = 0; } values(%all_controls)); |
93 |
_check_for_loops($form, $control->{"file"}, \%all_controls, |
|
94 |
$control->{"tag"}); |
|
85 |
_check_for_loops($form, $control->{"file"}, \%all_controls, $control->{"tag"}); |
|
95 | 86 |
} |
96 | 87 |
|
97 | 88 |
map({ _dbupdate2_calculate_depth(\%all_controls, $_->{"tag"}) } |
... | ... | |
111 | 102 |
|
112 | 103 |
if ($ctrl->{"loop"} == 1) { |
113 | 104 |
# Not done yet. |
114 |
_control_error($form, $file_name, |
|
115 |
$main::locale->text("Dependency loop detected:") . |
|
116 |
" " . join(" -> ", @path)) |
|
105 |
_control_error($form, $file_name, $main::locale->text("Dependency loop detected:") . " " . join(" -> ", @path)) |
|
106 |
|
|
117 | 107 |
} elsif ($ctrl->{"loop"} == 0) { |
118 | 108 |
# Not checked yet. |
119 | 109 |
$ctrl->{"loop"} = 1; |
120 |
map({ _check_for_loops($form, $file_name, $controls, $_, @path); } |
|
121 |
@{ $ctrl->{"depends"} }); |
|
110 |
map({ _check_for_loops($form, $file_name, $controls, $_, @path); } @{ $ctrl->{"depends"} }); |
|
122 | 111 |
$ctrl->{"loop"} = 2; |
123 | 112 |
} |
124 | 113 |
} |
... | ... | |
129 | 118 |
$form = $main::form; |
130 | 119 |
my $locale = $main::locale; |
131 | 120 |
|
132 |
$form->error(sprintf($locale->text("Error in database control file '%s': %s"), |
|
133 |
$file_name, $message)); |
|
121 |
$form->error(sprintf($locale->text("Error in database control file '%s': %s"), $file_name, $message)); |
|
134 | 122 |
} |
135 | 123 |
|
136 | 124 |
sub _dbupdate2_calculate_depth { |
... | ... | |
156 | 144 |
} |
157 | 145 |
|
158 | 146 |
sub sort_dbupdate_controls { |
159 |
return |
|
160 |
sort({ $a->{"depth"} != $b->{"depth"} ? $a->{"depth"} <=> $b->{"depth"} : |
|
161 |
$a->{"priority"} != $b->{"priority"} ? |
|
162 |
$a->{"priority"} <=> $b->{"priority"} : |
|
163 |
$a->{"tag"} cmp $b->{"tag"} } values(%{$_[0]})); |
|
147 |
return sort({ $a->{"depth"} != $b->{"depth"} ? $a->{"depth"} <=> $b->{"depth"} |
|
148 |
: $a->{"priority"} != $b->{"priority"} ? $a->{"priority"} <=> $b->{"priority"} |
|
149 |
: $a->{"tag"} cmp $b->{"tag"} } values(%{$_[0]})); |
|
164 | 150 |
} |
165 | 151 |
|
166 |
|
|
167 | 152 |
1; |
Auch abrufbar als: Unified diff
Kosmetik