Author: arielch
Date: Sun Sep 18 19:04:52 2016
New Revision: 1761352

URL: http://svn.apache.org/viewvc?rev=1761352&view=rev
Log:
i127120 - Some fixes for downloading dependecies

Cherrypick some changes already present on trunk, and remove the dependency on
newer libwww-perl that makes it difficult to work on older systems like
CentOS5.

Cherrypicked the following commits from trunk:

Revision 1591062
Revision 1700845
Revision 1723866
Revision 1728822
Revision 1731307



Modified:
    openoffice/branches/AOO413/main/bootstrap.1
    openoffice/branches/AOO413/main/solenv/bin/download_external_dependencies.pl
    openoffice/branches/AOO413/main/solenv/bin/modules/ExtensionsLst.pm

Modified: openoffice/branches/AOO413/main/bootstrap.1
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO413/main/bootstrap.1?rev=1761352&r1=1761351&r2=1761352&view=diff
==============================================================================
--- openoffice/branches/AOO413/main/bootstrap.1 (original)
+++ openoffice/branches/AOO413/main/bootstrap.1 Sun Sep 18 19:04:52 2016
@@ -40,6 +40,10 @@ chmod +x "$SRC_ROOT/solenv/bin/gccinstli
 # fetch or update external tarballs
 if [ "$DO_FETCH_TARBALLS" = "yes" ]; then
     "$PERL" "$SOLARENV/bin/download_external_dependencies.pl" 
$SRC_ROOT/external_deps.lst
+    if [ "$?" != "0" ]; then
+        echo "*** Error downloading external dependencies, please fix the 
previous problems and try again ***"
+        exit 1
+    fi
 fi
 
 # 
------------------------------------------------------------------------------

Modified: 
openoffice/branches/AOO413/main/solenv/bin/download_external_dependencies.pl
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO413/main/solenv/bin/download_external_dependencies.pl?rev=1761352&r1=1761351&r2=1761352&view=diff
==============================================================================
--- 
openoffice/branches/AOO413/main/solenv/bin/download_external_dependencies.pl 
(original)
+++ 
openoffice/branches/AOO413/main/solenv/bin/download_external_dependencies.pl 
Sun Sep 18 19:04:52 2016
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #**************************************************************
 #  
@@ -85,15 +85,7 @@ use File::Basename;
 use Digest::MD5;
 use Digest::SHA;
 use URI;
-my $simple = 1;
-if ($simple)
-{
-    use LWP::Simple;
-}
-else
-{
-    use LWP::UserAgent;
-}
+use LWP::UserAgent;
 
 my $Debug = 1;
 
@@ -479,20 +471,25 @@ sub Download ()
     }
 
     # Download the missing files.
+    my $all_downloaded = 1;
     for my $item (@Missing)
     {
         my ($name, $checksum, $urls) = @$item;
 
+        my $downloaded = 0;
         foreach my $url (@$urls)
         {
-            last if DownloadFile(
+            $downloaded = DownloadFile(
                 defined $checksum
                     ? $checksum->{'value'}."-".$name
                     : $name,
                 $url,
                 $checksum);
+            last if $downloaded
         }
+        $all_downloaded &&= $downloaded;
     }
+    die "some needed files could not be downloaded!" if !$all_downloaded;
 }
 
 
@@ -538,56 +535,27 @@ sub DownloadFile ($$$)
 
     # Download the extension.
     my $success = 0;
-    if ($simple)
+
+    my $agent = LWP::UserAgent->new();
+    $agent->env_proxy;
+    my $response = $agent->get($URL);
+
+    $success = $response->is_success;
+    if ($success)
     {
-       my $content = LWP::Simple::get($URL);
-       $success = defined $content;
-       if ($success)
-       {
-           open $out, ">$temporary_filename";
-           binmode($out);
-           print $out $content;
-           close($out);
-           $digest->add($content);
-       }
-       else
-       {
-           print "download from $URL failed\n";
-       }
+        my $content = $response->content;
+        open $out, ">$temporary_filename";
+        binmode($out);
+        print $out $content;
+        $digest->add($content);
     }
     else
     {
-       my $agent = LWP::UserAgent->new();
-       $agent->timeout(120);
-       $agent->env_proxy;
-       $agent->show_progress(1);
-       my $last_was_redirect = 0;
-       $agent->add_handler('response_redirect'
-                           => sub{
-                               $last_was_redirect = 1;
-                               return;
-                           });
-       $agent->add_handler('response_data'
-                           => sub{
-                               if ($last_was_redirect)
-                               {
-                                   $last_was_redirect = 0;
-                                   # Throw away the data we got so far.
-                                   $digest->reset();
-                                   close $out;
-                                   open $out, ">$temporary_filename";
-                                   binmode($out);
-                               }
-                               my($response,$agent,$h,$data)=@_;
-                               print $out $data;
-                               $digest->add($data);
-                           });
-
-       $success = $agent->get($URL)->is_success();
-       close $out;
+        print "download from $URL failed (" . $response->status_line . ")\n";
     }
-    
-    # When download was successfull then check the checksum and rename the 
.part file
+    close($out);
+
+    # When download was successful then check the checksum and rename the 
.part file
     # into the actual extension name.
     if ($success)
     {

Modified: openoffice/branches/AOO413/main/solenv/bin/modules/ExtensionsLst.pm
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO413/main/solenv/bin/modules/ExtensionsLst.pm?rev=1761352&r1=1761351&r2=1761352&view=diff
==============================================================================
--- openoffice/branches/AOO413/main/solenv/bin/modules/ExtensionsLst.pm 
(original)
+++ openoffice/branches/AOO413/main/solenv/bin/modules/ExtensionsLst.pm Sun Sep 
18 19:04:52 2016
@@ -418,7 +418,7 @@ sub Download (@)
         # We can not check the existence of file URLs because they point to 
extensions that
         # have yet to be built.
         
-        next if $protocol ne "http";
+        next if $protocol !~ /(http|https)/;
         my $candidate = File::Spec->catfile($download_path, $name);
         if ( ! -f $candidate)
         {
@@ -472,8 +472,6 @@ sub Download (@)
         my $filename = File::Spec->catfile($download_path, $name);
         my $temporary_filename = $filename . ".part";
         print "downloading to $temporary_filename\n";
-        open my $out, ">$temporary_filename";
-        binmode($out);
 
         # Prepare md5
         my $md5 = Digest::MD5->new();
@@ -481,35 +479,20 @@ sub Download (@)
         # Download the extension.
         my $agent = LWP::UserAgent->new();
         $agent->timeout(120);
-        $agent->show_progress(1);
+        $agent->env_proxy;
         my $last_was_redirect = 0;
-        $agent->add_handler('response_redirect'
-                            => sub{
-                                $last_was_redirect = 1;
-                                return;
-                            });
-        $agent->add_handler('response_data'
-                            => sub{
-                                if ($last_was_redirect)
-                                {
-                                    $last_was_redirect = 0;
-                                    # Throw away the data we got so far.
-                                    $md5->reset();
-                                    close $out;
-                                    open $out, ">$temporary_filename";
-                                    binmode($out);
-                                }
-                                my($response,$agent,$h,$data)=@_;
-                                print $out $data;
-                                $md5->add($data);
-                            });
         my $response = $agent->get($URL);
-        close $out;
 
         # When download was successfull then check the md5 checksum and rename 
the .part file
         # into the actual extension name.
         if ($response->is_success())
         {
+            my $content = $response->content;
+            open $out, ">$temporary_filename";
+            binmode($out);
+            print $out $content;
+            $md5->add($content);
+            close $out;
             if (defined $md5sum && length($md5sum)==32)
             {
                 my $file_md5 = $md5->hexdigest();


Reply via email to