Debian Codegraph @

3rdparty/getall

raw
1 #!/usr/bin/perl
2
3 ############################################################################
4 # This file is part of FreeFEM. #
5 # #
6 # FreeFEM is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU Lesser General Public License as #
8 # published by the Free Software Foundation, either version 3 of #
9 # the License, or (at your option) any later version. #
10 # #
11 # FreeFEM is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU Lesser General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU Lesser General Public License #
17 # along with FreeFEM. If not, see <http://www.gnu.org/licenses/>. #
18 ############################################################################
19 # SUMMARY : Download third-party packages independently of FF configuration
20 # LICENSE : LGPLv3
21 # ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE
22 # AUTHORS : Antoine Le Hyaric
23 # E-MAIL : http://www.ljll.math.upmc.fr/lehyaric
24
25 use strict;
26 use Getopt::Std;
27 use Digest::MD5 qw(md5_hex); # [[http://perldoc.perl.org/Digest/MD5.html]]
28
29 # This download script needs to be able to work on platforms that do not have threads (eg Mingw).
30
31 my $can_use_threads = eval 'use threads;use threads::shared;1';
32
33 my %opts;
34 getopts( 'afho:', \%opts );
35
36 if ( $opts{h} ) {
37 print <<EOF;
38 getall [options]: Download third-party packages independently of the FreeFEM configuration procedure
39
40 Available options:
41
42 -a = accept all licences without further user interaction
43 -f = force downloads even if packages are already present locally
44 -h = this help
45 -o name,name,... = only download packages with the given names
46
47 EOF
48 exit 0;
49 }
50
51 # Accumulate errors and print them all at the end of the script
52
53 my $errors = '';
54 if ($can_use_threads) { share( \$errors ) }
55
56 # Accumulate errors and print them all at the end of the script
57
58 my $errors = '';
59 if ($can_use_threads) { share( \$errors ) }
60
61 # list required packages
62 my $only = 0;
63 my %packs;
64 if ( defined $opts{o} ) {
65 $only = 1;
66 foreach ( split( /,/, $opts{o} ) ) { $packs{$_} = 1 }
67 }
68
69 # can be run from the parent directory
70
71 if ( -x "3rdparty/getall" ) { chdir "3rdparty" }
72
73 # can be run from any of the child directories
74
75 if ( -x "../getall" ) { chdir ".." }
76
77 system "mkdir -p pkg";
78 my @downloads;
79
80 download('ARPACK','https://www.ljll.fr/hecht/pkg/arpack96.tar.gz',
81 'https://www.ljll.fr/hecht/pkg',
82 'arpack96.tar.gz',
83 'fffaa970198b285676f4156cebc8626e');
84 download('ARPACK','https://www.ljll.fr/hecht/pkg/patch.tar.gz',
85 'https://www.ljll.fr/hecht/pkg',
86 'patch.tar.gz',
87 '14830d758f195f272b8594a493501fa2');
88 download('BLAS','http://www.netlib.org/blas/blas-3.7.1.tgz',
89 'http://www.netlib.org/blas',
90 'blas-3.7.1.tgz',
91 'cd132aea6f7055a49aa48ca0a61e7cd5');
92 download('BLAS','http://www.netlib.org/blas/blast-forum/cblas.tgz',
93 'http://www.netlib.org/blas/blast-forum',
94 'cblas.tgz',
95 '1e8830f622d2112239a4a8a83b84209a');
96 download('OpenBLAS','http://github.com/xianyi/OpenBLAS/archive/v0.3.6.tar.gz',
97 'http://www.openblas.net/',
98 'OpenBLAS.tar.gz',
99 '8a110a25b819a4b94e8a9580702b6495',
100 'BAD_CERT');
101 download('FFTW','http://www.fftw.org/fftw-3.3.8.tar.gz',
102 'http://www.fftw.org',
103 'fftw-3.3.8.tar.gz','8aac833c943d8e90d51b697b27d4384d');
104 # 3.3.2 '6977ee770ed68c85698c7168ffa6e178');
105 download('freeYams','https://www.ljll.fr/frey/ftp/archives/freeyams.2012.02.05.tgz',
106 'https://www.ljll.fr/frey/software.html',
107 'freeyams.2012.02.05.tgz',
108 'b7c82a256a3e59beeb2b578de93a4e0b');
109 download('Gmm++','https://www.ljll.fr/hecht/pkg/gmm-4.2.tar.gz',
110 'https://www.ljll.fr/hecht/pkg/',
111 'gmm-4.2.tar.gz',
112 '35fe900f7459c49f4b4337dc691c8cdf');
113 download('Ipopt','http://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.4.tgz',
114 'https://projects.coin-or.org/Ipopt',
115 'Ipopt-3.12.4.tgz',
116 '12a8ecaff8dd90025ddea6c65b49cb03');
117 download('METIS','https://www.ljll.fr/hecht/pkg/metis-5.1.0.tar.gz',
118 'http://www.netlib.org/linalg/',
119 'metis-5.1.0.tar.gz',
120 '5465e67079419a69e0116de24fce58fe');
121 download('ParMETIS','https://www.ljll.fr/hecht/pkg/ParMetis-4.0.3.tar.gz',
122 'https://www.ljll.fr/hecht/pkg',
123 'ParMetis-4.0.3.tar.gz',
124 'f69c479586bf6bb7aff6a9bc0c739628');
125 download('MMG3D','http://www.math.u-bordeaux1.fr/~dobrzyns/logiciels/download/mmg3d4.0.tgz',
126 'http://www.math.u-bordeaux1.fr/~dobrzyns/logiciels/mmg3d.php',
127 'mmg3d4.0.tgz',
128 'bfc2b0373bc208e0512415d1aa2e76a1');
129 download('mshmet','https://www.ljll.fr/frey/ftp/archives/mshmet.2012.04.25.tgz',
130 'https://www.ljll.fr/frey/software.html',
131 'mshmet.2012.04.25.tgz',
132 '427f397e0602efc56aa897d38a8e9bfa');
133 download('MUMPS','https://ftp.mcs.anl.gov/pub/petsc/externalpackages/MUMPS_5.0.2.tar.gz',
134 'https://ftp.mcs.anl.gov/pub/petsc/externalpackages',
135 'MUMPS_5.0.2.tar.gz',
136 '591bcb2c205dcb0283872608cdf04927');
137 download('NLopt','http://ab-initio.mit.edu/nlopt/nlopt-2.2.4.tar.gz',
138 'http://ab-initio.mit.edu/wiki/index.php/NLopt',
139 'nlopt-2.2.4.tar.gz',
140 '9c60c6380a10c6d2a06895f0e8756d4f');
141 download('ScaLAPACK','http://www.netlib.org/scalapack/scalapack-2.1.0.tgz',
142 'http://www.netlib.org/scalapack/',
143 'scalapack-2.1.0.tgz',
144 '3b239ef80353c67354a0a62d54946fa8');
145 download('Scotch','https://gitlab.inria.fr/scotch/scotch/-/archive/v6.1.0/scotch-v6.1.0.tar.gz',
146 'https://gitlab.inria.fr/scotch/',
147 'scotch-v6.1.0.tar.gz',
148 '7bfad4aaa851af6815b2160da7ebe36a'); # web certificate from gforge.inria.fr is rejected
149 download('SuiteSparse','http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-4.4.4.tar.gz',
150 'http://faculty.cse.tamu.edu/davis/SuiteSparse/',
151 'SuiteSparse-4.4.4.tar.gz',
152 'e0af74476935c9ff6d971df8bb6b82fc') ;
153 #download('SuperLU','https://github.com/xiaoyeli/superlu/archive/4f2da83a24c52641c1f7ab06f57c00b8954cf215.zip',
154 # 'https://github.com/xiaoyeli/superlu',
155 # 'superlu.zip',
156 # '596927f39d28a7d6eb396764f46455b2');
157 download('SuperLU','https://github.com/xiaoyeli/superlu/archive/v5.2.2.zip',
158 'https://github.com/xiaoyeli/superlu',
159 'superlu-5.2.2.zip',
160 '6e24842b0aa07f457d929b162e09ca6c');
161 download('TetGen','http://www.tetgen.org/1.5/src/tetgen1.5.1-beta1.tar.gz',
162 'http://www.tetgen.org/1.5/src/',
163 'tetgen1.5.1-beta1.tar.gz',
164 '3d55c197bcbfc611b7ced6f343643756');
165 download('mmg','https://github.com/MmgTools/mmg/archive/v5.8.0.zip',
166 'https://github.com/MmgTools',
167 'mmg.zip',
168 '3645f67e30f076b2f91368d12a538e30');
169 download('parmmg','https://github.com/MmgTools/ParMmg/archive/v1.5.0.zip',
170 'https://github.com/MmgTools',
171 'parmmg.zip',
172 '52b82cd18108c3fdfd229ac0158ef187');
173 download('PETSc','https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-3.25.3.tar.gz',
174 'https://web.cels.anl.gov/projects/petsc/download/release-snapshots',
175 'petsc-3.25.3.tar.gz',
176 'c2e2d88ad5b6f7b03c9bb4a3263c9724');
177
178 download('htool','https://github.com/htool-ddm/htool/archive/d7c0fa8b42c461446b92a4891dea78532eeea6b5.zip',
179 'https://github.com/htool-ddm/',
180 'htool.zip',
181 'a31c9a01b81b7e7f7724ffc8f3515d0c');
182
183 download('hpddm','https://codeload.github.com/hpddm/hpddm/zip/7113b9a6b77fceee3f52490cb27941a87b96542f',
184 'https://codeload.github.com/hpddm',
185 'hpddm.zip',
186 '6910b7b974f0b60d9c247c666e7f3862');
187
188 download('bemtool','https://github.com/PierreMarchand20/BemTool/archive/6381b9029e51d31d2e2d53ea42c10747b70563a9.zip',
189 'https://github.com/PierreMarchand20/BemTool',
190 'bemtool.zip',
191 'ebbdadc398c8a1debbb58fcd69ae7996');
192
193 download('Boost','https://www.ljll.fr/~tournier/boost_for_bemtool.tar.gz',
194 'https://www.boost.org',
195 'boost_for_bemtool.tar.gz',
196 '9b15ef07d3e8bd9eedf11bc3cd6f1f8f');
197
198 download('libpthread-google','https://www.ljll.fr/hecht/pkg/libpthread-google.tar.gz',
199 'https://www.ljll.fr/hecht/pkg/',
200 'libpthread-google.tar.gz',
201 '945c006d898983d1a710aabf52a32d9c');
202
203 # run all downloads concurrently
204
205 if ($can_use_threads) {
206 my @threads;
207 foreach (@downloads) { push @threads, threads->create( \&downloadone, $_ ) }
208 foreach (@threads) { $_->join() }
209 }
210 else {
211 foreach (@downloads) { downloadone($_) }
212 }
213
214 if ( $errors ne '' ) {
215 print "\n$errors";
216 exit 1;
217 }
218
219 sub download {
220 my ( $title, $url, $lic, $pkg, $md5, $opts ) = @_;
221
222 # skip packages that have not been requested explicitely
223 return if ( $only && !defined $packs{$title} );
224
225 # skip packages that are already present
226 if ( -f "pkg/$pkg" && !$opts{f} ) {
227 my $md5check = md5_hex(`cat pkg/$pkg`);
228 if ( ( $md5 eq "none" ) || ( $md5check eq $md5 ) ) {
229 print "$title $pkg done\n";
230 return;
231 }
232 else {
233 print "$title $pkg md5 change => reget \n";
234 }
235 }
236
237 # we do not store the answers to these questions. To repeat the same downloads without manual input, options "-a" and
238 # "-o names" are provided.
239
240 if ( !$opts{a} ) {
241 print
242 "$title: please check the licence at $lic. Do you want to download $url? (yN)\n";
243 my $ans = uc <STDIN>;
244 chomp $ans;
245 return if $ans ne 'Y';
246 }
247
248 # uses [[file:../bin/build/download]]
249 push @downloads, "$url,$pkg,$md5,$opts";
250 }
251
252 sub downloadone{
253 ## correct rescue server for done load
254 my($url,$pkg,$md5,$opts)=split(/,/,$_[0]);# warning just $pkg without pkg/$pkg
255 my $cmd="../bin/build/download $url pkg/$pkg $opts";
256 print "$cmd\n";
257 system $cmd;
258 if($?){
259 print "Download failed from $url of $pkg\n";
260 my $url="https://www.ljll.fr/hecht/pkg/$pkg";
261 my $cmd="../bin/build/download $url pkg/$pkg $opts";
262 print "Try other site: $url\n";
263 system $cmd;
264 if($?){
265 print "Download 2 times failed from $url of $pkg\n";
266 my $url="https://joliv.et/freefem/pkg/$pkg";
267 my $cmd="../bin/build/download $url pkg/$pkg $opts";
268 print "Try (2 times) other site: $url\n";
269 system $cmd;
270 if ($?){
271 $errors.="ERROR: $cmd FAILED\n"
272 }
273 }
274
275 }
276 # check if resulting package contents are valid
277 my $md5check=md5_hex(`cat pkg/$pkg`);
278 if( ( $md5 ne "none") && ($md5check ne $md5)){
279 print "Download failed (MD5 check $md5check) from $url of $pkg\n";
280 my $url="https://www.ljll.fr/hecht/pkg/$pkg";
281 my $cmd="../bin/build/download $url pkg/$pkg $opts";
282 print "Try other site: $url\n";
283 system $cmd;
284 if($?){
285 $errors.="ERROR 2: $cmd FAILED\n"
286 }
287 else { $md5check=md5_hex(`cat pkg/$pkg`);}
288 if( ($md5check ne $md5))
289 {
290 $errors.="ERROR2: INVALID MD5 for $pkg $md5check\n"}
291 }
292 }