ExtensionsLst.pm (274b8a62) ExtensionsLst.pm (c0f6b924)
1#**************************************************************
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements. See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership. The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance

--- 454 unchanged lines hidden (view full) ---

463 return;
464 }
465
466 # Download the missing files.
467 for my $entry (@missing)
468 {
469 my ($protocol, $name, $URL, $md5sum) = @{$entry};
470
1#**************************************************************
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements. See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership. The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance

--- 454 unchanged lines hidden (view full) ---

463 return;
464 }
465
466 # Download the missing files.
467 for my $entry (@missing)
468 {
469 my ($protocol, $name, $URL, $md5sum) = @{$entry};
470
471 system(
472 $ENV{'JAVAINTERPRETER'},
473 "-cp",
474 File::Spec->catfile(
475 File::Spec->catfile($ENV{'SOLARENV'}, $ENV{'INPATH'}),
476 "class"),
477 "AOOJavaDownloader",
478 $name,
479 $URL,
480 'MD5',
481 $md5sum);
471 # Open a .part file for writing.
472 my $filename = File::Spec->catfile($download_path, $name);
473 my $temporary_filename = $filename . ".part";
474 print "downloading to $temporary_filename\n";
482
475
483 if ($? != 0)
476 # Prepare md5
477 my $md5 = Digest::MD5->new();
478
479 # Download the extension.
480 my $agent = LWP::UserAgent->new();
481 $agent->timeout(120);
482 $agent->env_proxy;
483 my $last_was_redirect = 0;
484 my $response = $agent->get($URL);
485
486 # When download was successfull then check the md5 checksum and rename the .part file
487 # into the actual extension name.
488 if ($response->is_success())
484 {
489 {
490 my $content = $response->content;
491 open $out, ">$temporary_filename";
492 binmode($out);
493 print $out $content;
494 $md5->add($content);
495 close $out;
496 if (defined $md5sum && length($md5sum)==32)
497 {
498 my $file_md5 = $md5->hexdigest();
499 if ($md5sum eq $file_md5)
500 {
501 print "md5 is OK\n";
502 }
503 else
504 {
505 unlink($temporary_filename) if ! $Debug;
506 die "downloaded file has the wrong md5 checksum: $file_md5 instead of $md5sum";
507 }
508 }
509 else
510 {
511 print "md5 is not present\n";
512 printf " is %s, length is %d\n", $md5sum, length(md5sum);
513 }
514
515 rename($temporary_filename, $filename) || die "can not rename $temporary_filename to $filename";
516 }
517 else
518 {
485 die "failed to download $URL";
486 }
487 }
488}
489
490
491
492

--- 79 unchanged lines hidden ---
519 die "failed to download $URL";
520 }
521 }
522}
523
524
525
526

--- 79 unchanged lines hidden ---