2 |
## $Id$ |
## $Id$ |
3 |
## ---------------------------------------------------------------------- |
## ---------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.15 2004/06/16 16:37:59 joko |
6 |
|
## attempt to get things going in a generic way (Linux/FreeBSD/Win32) |
7 |
|
## |
8 |
|
## Revision 1.14 2004/05/12 14:23:31 jonen |
9 |
|
## add comment/code related to PERL5LIB var at different OS's |
10 |
|
## |
11 |
|
## Revision 1.13 2003/12/05 05:02:08 joko |
12 |
|
## + minor update: disabled some unnecessary loggers or changed to debug-level |
13 |
|
## |
14 |
|
## Revision 1.12 2003/06/24 20:59:51 jonen |
15 |
|
## added option 'detach' |
16 |
|
## |
17 |
## Revision 1.11 2003/06/23 17:54:32 joko |
## Revision 1.11 2003/06/23 17:54:32 joko |
18 |
## prepared execution of in-process perl-code via eval (not activated yet!) |
## prepared execution of in-process perl-code via eval (not activated yet!) |
19 |
## |
## |
66 |
use Hash::Merge qw( merge ); |
use Hash::Merge qw( merge ); |
67 |
use Iterate; |
use Iterate; |
68 |
|
|
69 |
use shortcuts qw( run_cmd ); |
use shortcuts qw( run_cmd RUNNING_IN_HELL ); |
70 |
use Data::Mungle::Code::Ref qw( ref_slot ); |
use Data::Mungle::Code::Ref qw( ref_slot ); |
71 |
use Data::Mungle::Transform::Deep qw( expand deep_copy ); |
use Data::Mungle::Transform::Deep qw( expand deep_copy ); |
72 |
use File::Temp qw/ tempfile tempdir /; |
use File::Temp qw/ tempfile tempdir /; |
73 |
|
|
74 |
|
my $DEBUG = 0; |
75 |
|
|
76 |
sub performTarget { |
sub performTarget { |
77 |
my $self = shift; |
my $self = shift; |
99 |
#$self->log($header, 'notice'); |
#$self->log($header, 'notice'); |
100 |
|
|
101 |
# V3 |
# V3 |
102 |
$self->log("- " x 20, 'info'); |
#$self->log("- " x 20, 'info'); |
103 |
$self->log("Performing Target '$targetname'.", 'notice'); |
$self->log("Performing Target '$targetname'.", 'notice'); |
104 |
|
|
105 |
#exit; |
#exit; |
148 |
my $content = $entry->{content}; |
my $content = $entry->{content}; |
149 |
$self->perform_command($command, $args, $content, { warn => 1 } ); |
$self->perform_command($command, $args, $content, { warn => 1 } ); |
150 |
# check recursiveness |
# check recursiveness |
151 |
# new condition: don't recurse if node is flagged to have inline-args (2004-04-17) |
# new condition: don't recurse if node is flagged to have inline-args (2003-04-17) |
152 |
my $has_inline_args = ($entry->{attrib}->{_args} && $entry->{attrib}->{_args} eq 'inline'); |
my $has_inline_args = ($entry->{attrib}->{_args} && $entry->{attrib}->{_args} eq 'inline'); |
153 |
if ($entry->{content} && ref $entry->{content} && !$has_inline_args) { |
if ($entry->{content} && ref $entry->{content} && !$has_inline_args) { |
154 |
$self->perform_details($entry); |
$self->perform_details($entry); |
155 |
} |
} |
156 |
# new of 2003-05-08 |
# new of 2003-05-08 |
157 |
|
$command ||= ''; |
158 |
$self->perform_command($command . '_end', undef, undef, { warn => 0 } ); |
$self->perform_command($command . '_end', undef, undef, { warn => 0 } ); |
159 |
} |
} |
160 |
} |
} |
172 |
my $options = shift; |
my $options = shift; |
173 |
|
|
174 |
if (!$command) { |
if (!$command) { |
175 |
$self->log("Command was empty!", 'debug'); |
$self->log("Command was empty!", 'debug') if $DEBUG; |
176 |
return; |
return; |
177 |
} |
} |
178 |
|
|
179 |
# FIXME: make '__PACKAGE__' go one level deeper properly! |
# FIXME: make '__PACKAGE__' go one level deeper properly! |
180 |
$self->log( __PACKAGE__ . "->perform_command: " . $command, 'debug'); |
$self->log( __PACKAGE__ . "->perform_command: " . $command, 'debug') if $DEBUG; |
181 |
|
|
182 |
|
|
183 |
# 1. make arguments from list of arguments(?) |
# 1. make arguments from list of arguments(?) |
220 |
} else { |
} else { |
221 |
my $level = "debug"; |
my $level = "debug"; |
222 |
$level = "warning" if $options->{warn}; |
$level = "warning" if $options->{warn}; |
223 |
$self->log("Command '$command' not implemented.", $level); |
$self->log("Command '$command' not implemented.", $level) if $DEBUG; |
224 |
} |
} |
225 |
|
|
226 |
} |
} |
347 |
|
|
348 |
$name = '__rap.properties.' . $name; |
$name = '__rap.properties.' . $name; |
349 |
|
|
350 |
$self->log("get-name: $name"); |
$self->log("get-name: $name") if $DEBUG; |
351 |
|
|
352 |
# get property slot and return value |
# get property slot and return value |
353 |
$result = ref_slot($self, $name, undef, '.'); |
$result = ref_slot($self, $name, undef, '.'); |
378 |
|
|
379 |
delete $opts->{caption}; |
delete $opts->{caption}; |
380 |
delete $opts->{async}; |
delete $opts->{async}; |
381 |
|
delete $opts->{detach}; |
382 |
|
|
383 |
#print Dumper($meta); |
#print Dumper($meta); |
384 |
|
|
423 |
#print "command: $cmd", "\n"; |
#print "command: $cmd", "\n"; |
424 |
|
|
425 |
# start process |
# start process |
426 |
# V1: via shortcut |
# 2004-05-11 - seems like only ONE args is valid at PERL5LIB, so we use V2! |
427 |
#$ENV{PERL5LIB} = join(' ', @INC); |
# 2004-06-16 - found out delimiter required for PERL5LIB, reverting back to V1! |
428 |
|
|
429 |
# FIXME!!! what about the other slots of @INC? |
# V1: join all args |
430 |
$ENV{PERL5LIB} = $INC[0]; |
my $delimiter = ':'; |
431 |
|
$delimiter = ';' if RUNNING_IN_HELL(); |
432 |
|
$ENV{PERL5LIB} = join($delimiter, @INC); |
433 |
|
# V2: insert only FIRST arg |
434 |
|
#$ENV{PERL5LIB} = $INC[0]; |
435 |
|
# WARNING: at (free)BSD our var is the SECOND, NOT FIRST!! |
436 |
|
# FIXME!! Do this in an abstract way!! |
437 |
|
#$ENV{PERL5LIB} = $INC[1]; |
438 |
|
|
439 |
#print Dumper(%ENV); |
#print Dumper(%ENV); |
440 |
|
|
446 |
# V1.b - enhanced: variable local method |
# V1.b - enhanced: variable local method |
447 |
$meta->{caption} ||= ''; |
$meta->{caption} ||= ''; |
448 |
$meta->{async} ||= 0; |
$meta->{async} ||= 0; |
449 |
|
$meta->{detach} ||= 0; |
450 |
# new of 2003-05-08: USE_PATH! |
# new of 2003-05-08: USE_PATH! |
451 |
$meta->{USE_PATH} ||= 0; |
$meta->{USE_PATH} ||= 0; |
452 |
my $evalstr = "run_cmd('$cmd', '$meta->{caption}', { async => $meta->{async}, USE_PATH => $meta->{USE_PATH} });"; |
my $evalstr = "run_cmd('$cmd', '$meta->{caption}', { async => $meta->{async}, detach => $meta->{detach}, USE_PATH => $meta->{USE_PATH} });"; |
453 |
eval($evalstr); |
eval($evalstr); |
454 |
#my $res = do "$cmd"; |
#my $res = do "$cmd"; |
455 |
#print $res, "\n" if $res; |
#print $res, "\n" if $res; |