2 |
## $Id$ |
## $Id$ |
3 |
## ---------------------------------------------------------------------- |
## ---------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.11 2003/06/23 17:54:32 joko |
6 |
|
## prepared execution of in-process perl-code via eval (not activated yet!) |
7 |
|
## |
8 |
|
## Revision 1.10 2003/05/13 07:56:12 joko |
9 |
|
## enhanced: *hierarchical* containers for context handling |
10 |
|
## fixes: some pre-flight checks |
11 |
|
## new: propagate "end-tag" event to e.g. close containers |
12 |
|
## |
13 |
|
## Revision 1.9 2003/04/04 17:23:11 joko |
14 |
|
## minor update: debugging output |
15 |
|
## |
16 |
## Revision 1.8 2003/03/29 07:11:54 joko |
## Revision 1.8 2003/03/29 07:11:54 joko |
17 |
## modified: sub run_executable |
## modified: sub run_executable |
18 |
## new: sub run_script |
## new: sub run_script |
70 |
my $self = shift; |
my $self = shift; |
71 |
my $targetname = shift; |
my $targetname = shift; |
72 |
|
|
73 |
|
# pre-flight checks |
74 |
|
if (!$targetname) { |
75 |
|
$self->log("Target name empty. Please try to specify (e.g.) on the command line.", 'critical'); |
76 |
|
return; |
77 |
|
} |
78 |
|
|
79 |
my $header = ("- " x 12) . " " . $targetname . " " . ("- " x 6); |
my $header = ("- " x 12) . " " . $targetname . " " . ("- " x 6); |
80 |
|
|
81 |
# V1 |
# V1 |
86 |
#$self->log($header, 'notice'); |
#$self->log($header, 'notice'); |
87 |
|
|
88 |
# V3 |
# V3 |
89 |
$self->log("- " x 35, 'info'); |
$self->log("- " x 20, 'info'); |
90 |
$self->log("Performing Target '$targetname'.", 'notice'); |
$self->log("Performing Target '$targetname'.", 'notice'); |
91 |
|
|
92 |
#exit; |
#exit; |
99 |
|
|
100 |
$self->perform_dependencies($target); |
$self->perform_dependencies($target); |
101 |
$self->perform_details($target); |
$self->perform_details($target); |
102 |
|
|
103 |
|
return 1; |
104 |
|
|
105 |
} |
} |
106 |
|
|
133 |
my $command = $entry->{name}; |
my $command = $entry->{name}; |
134 |
my $args = $entry->{attrib}; |
my $args = $entry->{attrib}; |
135 |
my $content = $entry->{content}; |
my $content = $entry->{content}; |
136 |
$self->perform_command($command, $args, $content); |
$self->perform_command($command, $args, $content, { warn => 1 } ); |
137 |
# check recursiveness |
# check recursiveness |
138 |
if ($entry->{content} && ref $entry->{content}) { |
# new condition: don't recurse if node is flagged to have inline-args (2004-04-17) |
139 |
|
my $has_inline_args = ($entry->{attrib}->{_args} && $entry->{attrib}->{_args} eq 'inline'); |
140 |
|
if ($entry->{content} && ref $entry->{content} && !$has_inline_args) { |
141 |
$self->perform_details($entry); |
$self->perform_details($entry); |
142 |
} |
} |
143 |
|
# new of 2003-05-08 |
144 |
|
$self->perform_command($command . '_end', undef, undef, { warn => 0 } ); |
145 |
} |
} |
146 |
} |
} |
147 |
|
|
155 |
my $command = shift; |
my $command = shift; |
156 |
my $args_list = shift; |
my $args_list = shift; |
157 |
my $content = shift; |
my $content = shift; |
158 |
|
my $options = shift; |
159 |
|
|
160 |
if (!$command) { |
if (!$command) { |
161 |
$self->log("Command was empty!", 'debug'); |
$self->log("Command was empty!", 'debug'); |
165 |
# FIXME: make '__PACKAGE__' go one level deeper properly! |
# FIXME: make '__PACKAGE__' go one level deeper properly! |
166 |
$self->log( __PACKAGE__ . "->perform_command: " . $command, 'debug'); |
$self->log( __PACKAGE__ . "->perform_command: " . $command, 'debug'); |
167 |
|
|
168 |
|
|
169 |
|
# 1. make arguments from list of arguments(?) |
170 |
|
|
171 |
my $args = {}; |
my $args = {}; |
172 |
#print Dumper($args_list); |
#print Dumper($args_list); |
173 |
if ($args_list) { |
if ($args_list) { |
179 |
$args = $args_list; |
$args = $args_list; |
180 |
} |
} |
181 |
} |
} |
|
$command = '_' . $command; |
|
182 |
|
|
183 |
|
|
184 |
# determine container |
# 2. prepare command |
185 |
|
|
186 |
|
# default setting for internal rap commands |
187 |
|
my $method_prefix_default = '_'; |
188 |
|
# setting from property database |
189 |
|
my $method_prefix_setting = $self->get_property('core.method_prefix'); |
190 |
|
#print "setting: ", $method_prefix_setting, "\n"; |
191 |
|
my $prefix = $method_prefix_setting; |
192 |
|
if (not defined $prefix) { |
193 |
|
$prefix = $method_prefix_default; |
194 |
|
} |
195 |
|
$command = $prefix . $command; |
196 |
|
|
197 |
|
|
198 |
|
# 3. determine container |
199 |
my $container; # = $self->getInstance(); |
my $container; # = $self->getInstance(); |
200 |
|
#$container ||= $self->getInstance(); |
201 |
$container ||= $self; |
$container ||= $self; |
202 |
|
|
203 |
|
# 4. run method |
204 |
if ($container->can($command)) { |
if ($container->can($command)) { |
205 |
$container->$command($args, $content); |
$container->$command($args, $content); |
206 |
} else { |
} else { |
207 |
$self->log("Command '$command' not implemented.", "warning"); |
my $level = "debug"; |
208 |
|
$level = "warning" if $options->{warn}; |
209 |
|
$self->log("Command '$command' not implemented.", $level); |
210 |
} |
} |
211 |
|
|
212 |
} |
} |
270 |
|
|
271 |
$self->log("set-name: $name"); |
$self->log("set-name: $name"); |
272 |
|
|
273 |
|
#print Dumper($name, $value, '.'); |
274 |
|
|
275 |
# fill property slot with given value |
# fill property slot with given value |
276 |
if ($value) { |
# fix (2003-04-17): always do fill if value is *defined*!!! |
277 |
|
if (defined $value) { |
278 |
ref_slot($self, $name, $value, '.'); |
ref_slot($self, $name, $value, '.'); |
279 |
} |
} |
280 |
|
|
424 |
# V1.b - enhanced: variable local method |
# V1.b - enhanced: variable local method |
425 |
$meta->{caption} ||= ''; |
$meta->{caption} ||= ''; |
426 |
$meta->{async} ||= 0; |
$meta->{async} ||= 0; |
427 |
my $evalstr = "run_cmd('$cmd', '$meta->{caption}', { async => $meta->{async} });"; |
# new of 2003-05-08: USE_PATH! |
428 |
|
$meta->{USE_PATH} ||= 0; |
429 |
|
my $evalstr = "run_cmd('$cmd', '$meta->{caption}', { async => $meta->{async}, USE_PATH => $meta->{USE_PATH} });"; |
430 |
eval($evalstr); |
eval($evalstr); |
431 |
#my $res = do "$cmd"; |
#my $res = do "$cmd"; |
432 |
#print $res, "\n" if $res; |
#print $res, "\n" if $res; |
481 |
|
|
482 |
} elsif ($args->{language} eq 'bash') { |
} elsif ($args->{language} eq 'bash') { |
483 |
$self->log("FIXME: - - - - - -- - - -- BASH - - - - - - - -- - ", 'error'); |
$self->log("FIXME: - - - - - -- - - -- BASH - - - - - - - -- - ", 'error'); |
484 |
|
|
485 |
|
} elsif ($args->{language} eq 'perl') { |
486 |
|
|
487 |
|
# reporting |
488 |
|
#$self->log("Executing some arbitrary unsigned code (probably unsafe). [language=$args->{language}]", 'info'); |
489 |
|
#$self->log("\n<code>\n$code\n</code>", 'info'); |
490 |
|
|
491 |
|
# do it |
492 |
|
#eval($code); |
493 |
|
#$self->log("\n<code>\n$code\n</code>", 'error') if $@; |
494 |
|
|
495 |
} else { |
} else { |
496 |
$self->log("FIXME: Script language '$args->{language}' not implemented.", 'error'); |
$self->log("FIXME: Script language '$args->{language}' not implemented.", 'error'); |