1 |
joko |
1.1 |
#!/usr/bin/perl |
2 |
|
|
|
3 |
|
|
## ------------------------------------------------------------------------- |
4 |
joko |
1.5 |
## $Id: rap.pl,v 1.4 2003/03/27 15:58:08 joko Exp $ |
5 |
joko |
1.1 |
## ------------------------------------------------------------------------- |
6 |
jonen |
1.2 |
## $Log: rap.pl,v $ |
7 |
joko |
1.5 |
## Revision 1.4 2003/03/27 15:58:08 joko |
8 |
|
|
## enhancement: now can execute perl-programs via 'do' here |
9 |
|
|
## |
10 |
joko |
1.4 |
## Revision 1.3 2003/02/20 21:39:49 joko |
11 |
|
|
## - find_rules moved to Rap.pm |
12 |
|
|
## |
13 |
joko |
1.3 |
## Revision 1.2 2003/02/18 19:09:07 jonen |
14 |
|
|
## + cwd for linux bootstrap |
15 |
|
|
## |
16 |
jonen |
1.2 |
## Revision 1.1 2003/02/18 15:30:52 joko |
17 |
|
|
## + initial commit |
18 |
|
|
## |
19 |
joko |
1.1 |
## ------------------------------------------------------------------------- |
20 |
|
|
|
21 |
|
|
|
22 |
|
|
use strict; |
23 |
|
|
use warnings; |
24 |
|
|
|
25 |
joko |
1.3 |
|
26 |
|
|
use File::Spec::Functions qw( splitpath splitdir catpath catdir ); |
27 |
|
|
|
28 |
|
|
sub popdir { |
29 |
|
|
my $path = shift; |
30 |
|
|
my $popcount = shift; |
31 |
|
|
(my $volume, my $directory, my $file) = splitpath( $path ); |
32 |
|
|
my @dir = splitdir($directory); |
33 |
|
|
while ($popcount--) { |
34 |
|
|
pop @dir; |
35 |
|
|
} |
36 |
|
|
#pop @dir; |
37 |
|
|
|
38 |
|
|
#my $base = catpath($volume, catdir(@dir)); |
39 |
|
|
my $base = join('/', @dir); |
40 |
|
|
$base = $volume . $base if $volume; |
41 |
|
|
|
42 |
|
|
return $base; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
joko |
1.1 |
BEGIN { |
48 |
|
|
use FindBin qw($Bin); |
49 |
joko |
1.3 |
#use lib "$Bin/../../libs"; |
50 |
|
|
my $libpath = popdir($Bin, 2) . '/libs'; |
51 |
|
|
#print "libpath: $libpath", "\n"; |
52 |
|
|
#exit; |
53 |
|
|
my $evs = "use lib '$libpath';"; |
54 |
|
|
#print "evs: $evs", "\n"; |
55 |
|
|
eval($evs); |
56 |
|
|
die($@) if $@; |
57 |
joko |
1.1 |
} |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
# ------------------------------------ main ------------ |
61 |
|
|
use Data::Dumper; |
62 |
|
|
use Data::Rap; |
63 |
jonen |
1.2 |
|
64 |
joko |
1.1 |
|
65 |
|
|
sub main { |
66 |
|
|
my $argString = shift; |
67 |
joko |
1.4 |
|
68 |
|
|
# check if target is a namespace-string (contains '::') |
69 |
|
|
# TODO: move this logic/code to inside Data::Rap! |
70 |
|
|
if ($argString =~ s/::/\//g) { |
71 |
|
|
my $res = do "$argString"; |
72 |
|
|
print $res, "\n" if $res; |
73 |
|
|
} else { |
74 |
|
|
my $rap = Data::Rap->new( target => $argString ); |
75 |
joko |
1.5 |
rap_boot(); |
76 |
joko |
1.4 |
$rap->start(); |
77 |
|
|
#$rap->stop(); |
78 |
|
|
} |
79 |
joko |
1.5 |
} |
80 |
|
|
|
81 |
|
|
sub rap_boot { |
82 |
|
|
# check for another environment-variable: 'RAPBIN' |
83 |
|
|
# FIXME: what about 'topic.basedir'??? implement this here! |
84 |
|
|
# enhance infrastructure to have per-topic basedirs!!! |
85 |
|
|
chdir $ENV{RAPBIN} if $ENV{RAPBIN}; |
86 |
joko |
1.1 |
} |
87 |
|
|
|
88 |
|
|
my @args = @ARGV; |
89 |
|
|
@args = () if not @args; |
90 |
|
|
main(join(' ', @args)); |
91 |
|
|
|
92 |
|
|
|
93 |
|
|
1; |
94 |
|
|
__END__ |