24
24
25
25
use strict;
26
26
use Getopt::Std;
27
- use Digest::MD5 qw( md5_hex) ; # [[http://perldoc.perl.org/Digest/MD5.html]]
27
+ use Digest::MD5 qw( md5_hex) ; # [[http://perldoc.perl.org/Digest/MD5.html]]
28
28
29
29
# This download script needs to be able to work on platforms that do not have threads (eg Mingw).
30
30
31
- my $can_use_threads = eval ' use threads;use threads::shared;1' ;
31
+ my $can_use_threads = eval ' use threads;use threads::shared;1' ;
32
32
33
33
my %opts ;
34
- getopts(' afho:' ,\%opts );
34
+ getopts( ' afho:' , \%opts );
35
35
36
- if ( $opts {h }) {
37
- print <<EOF ;
36
+ if ( $opts {h } ) {
37
+ print <<EOF ;
38
38
getall [options]: Download third-party packages independently of the FreeFEM configuration procedure
39
39
40
40
Available options:
@@ -45,34 +45,34 @@ Available options:
45
45
-o name,name,... = only download packages with the given names
46
46
47
47
EOF
48
- exit 0;
48
+ exit 0;
49
49
}
50
50
51
51
# Accumulate errors and print them all at the end of the script
52
52
53
- my $errors = ' ' ;
54
- if ($can_use_threads ){ share(\$errors ) }
53
+ my $errors = ' ' ;
54
+ if ($can_use_threads ) { share( \$errors ) }
55
55
56
56
# Accumulate errors and print them all at the end of the script
57
57
58
- my $errors = ' ' ;
59
- if ($can_use_threads ){ share(\$errors ) }
58
+ my $errors = ' ' ;
59
+ if ($can_use_threads ) { share( \$errors ) }
60
60
61
61
# list required packages
62
- my $only = 0;
62
+ my $only = 0;
63
63
my %packs ;
64
- if ( defined $opts {o }) {
65
- $only = 1;
66
- foreach ( split (/ ,/ ,$opts {o })){ $packs {$_ }=1 }
64
+ if ( defined $opts {o } ) {
65
+ $only = 1;
66
+ foreach ( split ( / ,/ , $opts {o } ) ) { $packs {$_ } = 1 }
67
67
}
68
68
69
69
# can be run from the parent directory
70
70
71
- if ( -x " 3rdparty/getall" ){ chdir " 3rdparty" }
71
+ if ( -x " 3rdparty/getall" ) { chdir " 3rdparty" }
72
72
73
73
# can be run from any of the child directories
74
74
75
- if ( -x " ../getall" ){ chdir " .." }
75
+ if ( -x " ../getall" ) { chdir " .." }
76
76
77
77
system " mkdir -p pkg" ;
78
78
my @downloads ;
@@ -99,9 +99,6 @@ download('OpenBLAS','http://github.com/xianyi/OpenBLAS/archive/v0.3.6.tar.gz',
99
99
' 8a110a25b819a4b94e8a9580702b6495' ,
100
100
' BAD_CERT' );
101
101
102
- download(' FFTW' ,' http://www.fftw.org/fftw-3.3.8.tar.gz' ,
103
- ' http://www.fftw.org' ,
104
- ' fftw-3.3.8.tar.gz' ,' 8aac833c943d8e90d51b697b27d4384d' );
105
102
# 3.3.2 '6977ee770ed68c85698c7168ffa6e178');
106
103
download(' freeYams' ,' https://www.ljll.fr/frey/ftp/archives/freeyams.2012.02.05.tgz' ,
107
104
' https://www.ljll.fr/frey/software.html' ,
@@ -181,11 +178,13 @@ download('htool','https://github.com/htool-ddm/htool/archive/f9a7e48eaa90cad7e23
181
178
' htool.zip' ,
182
179
' f0b977c3ab24f26e23b5e7398577d0f4' );
183
180
184
-
185
- download(' hpddm' ,' https://codeload.github.com/hpddm/hpddm/zip/7113b9a6b77fceee3f52490cb27941a87b96542f' ,
186
- ' https://codeload.github.com/hpddm' ,
187
- ' hpddm.zip' ,
188
- ' 6910b7b974f0b60d9c247c666e7f3862' );
181
+ download(
182
+ ' hpddm' ,
183
+ ' https://codeload.github.com/hpddm/hpddm/zip/7113b9a6b77fceee3f52490cb27941a87b96542f' ,
184
+ ' https://codeload.github.com/hpddm' ,
185
+ ' hpddm.zip' ,
186
+ ' 6910b7b974f0b60d9c247c666e7f3862'
187
+ );
189
188
190
189
download(' bemtool' ,' https://github.com/PierreMarchand20/BemTool/archive/6e61fbf86d8cd53994d9f597e60fde537650ba14.zip' ,
191
190
' https://github.com/PierreMarchand20/BemTool' ,
@@ -203,53 +202,61 @@ download('libpthread-google','https://www.ljll.fr/hecht/pkg/libpthread-google.ta
203
202
' libpthread-google.tar.gz' ,
204
203
' 945c006d898983d1a710aabf52a32d9c' );
205
204
205
+ download(
206
+ ' libpthread-google' ,
207
+ ' https://www.ljll.fr/hecht/pkg/libpthread-google.tar.gz' ,
208
+ ' https://www.ljll.fr/hecht/pkg/' ,
209
+ ' libpthread-google.tar.gz' ,
210
+ ' 945c006d898983d1a710aabf52a32d9c'
211
+ );
206
212
207
213
# run all downloads concurrently
208
214
209
- if ($can_use_threads ){
210
- my @threads ;
211
- foreach (@downloads ){ push @threads ,threads-> create(\&downloadone,$_ ) }
212
- foreach (@threads ){ $_ -> join ()}
215
+ if ($can_use_threads ) {
216
+ my @threads ;
217
+ foreach (@downloads ) { push @threads , threads-> create( \&downloadone, $_ ) }
218
+ foreach (@threads ) { $_ -> join () }
213
219
}
214
- else {
215
- foreach (@downloads ){ downloadone($_ )}
220
+ else {
221
+ foreach (@downloads ) { downloadone($_ ) }
216
222
}
217
223
218
- if ( $errors ne ' ' ) {
219
- print " \n $errors " ;
220
- exit 1;
224
+ if ( $errors ne ' ' ) {
225
+ print " \n $errors " ;
226
+ exit 1;
221
227
}
222
228
223
- sub download{
224
- my ($title ,$url ,$lic ,$pkg ,$md5 ,$opts )=@_ ;
225
-
226
- # skip packages that have not been requested explicitely
227
- return if ($only && !defined $packs {$title });
228
-
229
- # skip packages that are already present
230
- if (-f " pkg/$pkg " && !$opts {f }){
231
- my $md5check =md5_hex(` cat pkg/$pkg ` );
232
- if ( ( $md5 eq " none" ) || ($md5check eq $md5 )){
233
- print " $title $pkg done\n " ;
234
- return ;
235
- }
236
- else {
237
- print " $title $pkg md5 change => reget \n " ;
238
- }
239
- }
240
-
241
- # we do not store the answers to these questions. To repeat the same downloads without manual input, options "-a" and
242
- # "-o names" are provided.
243
-
244
- if (!$opts {a }){
245
- print " $title : please check the licence at $lic . Do you want to download $url ? (yN)\n " ;
246
- my $ans =uc <STDIN >;
247
- chomp $ans ;
248
- return if $ans ne ' Y' ;
249
- }
250
-
251
- # uses [[file:../bin/build/download]]
252
- push @downloads ," $url ,$pkg ,$md5 ,$opts " ;
229
+ sub download {
230
+ my ( $title , $url , $lic , $pkg , $md5 , $opts ) = @_ ;
231
+
232
+ # skip packages that have not been requested explicitely
233
+ return if ( $only && !defined $packs {$title } );
234
+
235
+ # skip packages that are already present
236
+ if ( -f " pkg/$pkg " && !$opts {f } ) {
237
+ my $md5check = md5_hex(` cat pkg/$pkg ` );
238
+ if ( ( $md5 eq " none" ) || ( $md5check eq $md5 ) ) {
239
+ print " $title $pkg done\n " ;
240
+ return ;
241
+ }
242
+ else {
243
+ print " $title $pkg md5 change => reget \n " ;
244
+ }
245
+ }
246
+
247
+ # we do not store the answers to these questions. To repeat the same downloads without manual input, options "-a" and
248
+ # "-o names" are provided.
249
+
250
+ if ( !$opts {a } ) {
251
+ print
252
+ " $title : please check the licence at $lic . Do you want to download $url ? (yN)\n " ;
253
+ my $ans = uc <STDIN >;
254
+ chomp $ans ;
255
+ return if $ans ne ' Y' ;
256
+ }
257
+
258
+ # uses [[file:../bin/build/download]]
259
+ push @downloads , " $url ,$pkg ,$md5 ,$opts " ;
253
260
}
254
261
255
262
sub downloadone{
@@ -260,7 +267,7 @@ sub downloadone{
260
267
system $cmd ;
261
268
if ($? ){
262
269
print " Download failed from $url of $pkg \n " ;
263
- my $url =" https://www.ljll.fr/hecht /pkg/$pkg " ;
270
+ my $url =" https://joliv.et/freefem /pkg/$pkg " ;
264
271
my $cmd =" ../bin/build/download $url pkg/$pkg $opts " ;
265
272
print " Try other site: $url \n " ;
266
273
system $cmd ;
@@ -280,7 +287,7 @@ sub downloadone{
280
287
my $md5check =md5_hex(` cat pkg/$pkg ` );
281
288
if ( ( $md5 ne " none" ) && ($md5check ne $md5 )){
282
289
print " Download failed (MD5 check $md5check ) from $url of $pkg \n " ;
283
- my $url =" https://www.ljll.fr/hecht /pkg/$pkg " ;
290
+ my $url =" https://joliv.et/freefem /pkg/$pkg " ;
284
291
my $cmd =" ../bin/build/download $url pkg/$pkg $opts " ;
285
292
print " Try other site: $url \n " ;
286
293
system $cmd ;
0 commit comments