Source
1
1
#!/usr/bin/perl
2
2
3
3
use POSIX;
4
+
use LWP::Simple;
4
5
use File::Basename;
6
+
use File::Copy qw(copy);
5
7
use Cwd qw(abs_path getcwd);
6
8
7
9
$name = basename($0);
8
10
$exe = abs_path($0);
9
11
$path = abs_path(dirname($exe));
10
12
chop($java=`which java`);
11
13
$jarfile_name = "xml-casa-assembly-1.68.jar";
12
14
13
15
### install path
14
16
$jarfile = "$path/java/$jarfile_name";
15
17
### development path
16
-
if ( ! -e $jarfile ) { $jarfile = "$path/../target/scala-2.12/$jarfile_name" }
18
+
if ( ! -e $jarfile ) {
19
+
my $devjarfile = "$path/../target/scala-2.12/$jarfile_name";
20
+
if ( -e $devjarfile ) {
21
+
$jarfile = $devjarfile;
22
+
}
23
+
}
24
+
if ( ! -e $jarfile ) {
25
+
my $cmd = "curl --create-dirs --output $jarfile https://casa.nrao.edu/download/devel/xml-casa/java/$jarfile_name 2>&1 |";
26
+
open( my $fh, $cmd );
27
+
my @output = <$fh>;
28
+
close( $fh );
29
+
if ( `file $jarfile` =~ m|HTML| ) {
30
+
print( "\t--------------------------------------------------------------------------\n" );
31
+
print( "\tcould not fetch $jarfile_name\n" );
32
+
print( "\t--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- \n" );
33
+
foreach ( @output ) {
34
+
print( "\t$_" );
35
+
}
36
+
print( "\t--------------------------------------------------------------------------\n" );
37
+
unlink( $jarfile );
38
+
exit(1);
39
+
}
40
+
}
17
41
die "configuration error, cannot find jar file ($jarfile_name)" unless -e $jarfile;
18
42
19
43
@flags = ( );
20
44
@inputs = ( );
21
45
$doing_something = 0;
22
46
23
47
24
48
foreach ( @ARGV ) {
25
49
m|^-markdown$| && (push(@flags,$_),$doing_something=1,next);
26
50
m|^-upgrade$| && (push(@flags,$_),$doing_something=1,next);