You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2016/12/03 11:51:39 UTC
svn commit: r1772462 - in /openoffice/trunk/main: bootstrap.1
solenv/bin/download_external_dependencies.pl
solenv/bin/modules/ExtensionsLst.pm
Author: arielch
Date: Sat Dec 3 11:51:39 2016
New Revision: 1772462
URL: http://svn.apache.org/viewvc?rev=1772462&view=rev
Log:
i127236 - Use libwww-perl to download dependencies
Cherrypicked some changes from Revision 1761352
Modified:
openoffice/trunk/main/bootstrap.1
openoffice/trunk/main/solenv/bin/download_external_dependencies.pl
openoffice/trunk/main/solenv/bin/modules/ExtensionsLst.pm
Modified: openoffice/trunk/main/bootstrap.1
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/bootstrap.1?rev=1772462&r1=1772461&r2=1772462&view=diff
==============================================================================
--- openoffice/trunk/main/bootstrap.1 (original)
+++ openoffice/trunk/main/bootstrap.1 Sat Dec 3 11:51:39 2016
@@ -54,14 +54,6 @@ chmod +x "$SRC_ROOT/solenv/bin/build_cli
chmod +x "$SRC_ROOT/solenv/bin/zipdep.pl"
chmod +x "$SRC_ROOT/solenv/bin/gccinstlib.pl"
-# build the AOOJavaDownloader
-mkdir -p "$SOLARENV/$INPATH/class"
-"$JAVACOMPILER" "$SOLARENV/javadownloader/AOOJavaDownloader.java" -d "$SOLARENV/$INPATH/class"
-if [ "$?" != "0" ]; then
- echo "*** Failed to build AOOJavaDownloader, aborting! ***"
- exit 1
-fi
-
# fetch or update external tarballs
if [ "$DO_FETCH_TARBALLS" = "yes" ]; then
# check perl include locations
Modified: openoffice/trunk/main/solenv/bin/download_external_dependencies.pl
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/solenv/bin/download_external_dependencies.pl?rev=1772462&r1=1772461&r2=1772462&view=diff
==============================================================================
--- openoffice/trunk/main/solenv/bin/download_external_dependencies.pl (original)
+++ openoffice/trunk/main/solenv/bin/download_external_dependencies.pl Sat Dec 3 11:51:39 2016
@@ -507,45 +507,92 @@ sub DownloadFile ($$$)
my $URL = shift;
my $checksum = shift;
- if (defined $checksum)
+ my $filename = File::Spec->catfile($ENV{'TARFILE_LOCATION'}, $name);
+
+ my $temporary_filename = $filename . ".part";
+
+ print "downloading to $temporary_filename\n";
+ my $out;
+ open $out, ">$temporary_filename";
+ binmode($out);
+
+ # Prepare checksum
+ my $digest;
+ if (defined $checksum && $checksum->{'type'} eq "SHA1")
+ {
+ # Use SHA1 only when explicitly requested (by the presence of a "SHA1=..." line.)
+ $digest = Digest::SHA->new("1");
+ }
+ elsif ( ! defined $checksum || $checksum->{'type'} eq "MD5")
{
- system(
- $ENV{'JAVAINTERPRETER'},
- "-cp",
- File::Spec->catfile(
- File::Spec->catfile($ENV{'SOLARENV'}, $ENV{'INPATH'}),
- "class"),
- "AOOJavaDownloader",
- $name,
- $URL,
- $checksum->{'type'},
- $checksum->{'value'});
+ # Use MD5 when explicitly requested or when no checksum type is given.
+ $digest = Digest::MD5->new();
}
else
{
- system(
- $ENV{'JAVAINTERPRETER'},
- "-cp",
- File::Spec->catfile(
- File::Spec->catfile($ENV{'SOLARENV'}, $ENV{'INPATH'}),
- "class"),
- "AOOJavaDownloader",
- $name,
- $URL);
+ die "checksum type ".$checksum->{'type'}." is not supported";
}
- my $rc = $? >> 8;
- if ($rc == 0)
+ # Download the extension.
+ my $success = 0;
+
+ my $agent = LWP::UserAgent->new();
+ $agent->env_proxy;
+ my $response = $agent->get($URL);
+
+ $success = $response->is_success;
+ if ($success)
{
- return 1;
+ my $content = $response->content;
+ open $out, ">$temporary_filename";
+ binmode($out);
+ print $out $content;
+ $digest->add($content);
}
- elsif ($rc == 1)
+ else
{
- return 0;
+ print "download from $URL failed (" . $response->status_line . ")\n";
+ }
+ close($out);
+
+ # When download was successful then check the checksum and rename the .part file
+ # into the actual extension name.
+ if ($success)
+ {
+ my $file_checksum = $digest->hexdigest();
+ if (defined $checksum)
+ {
+ if ($checksum->{'value'} eq $file_checksum)
+ {
+ printf("%s checksum is OK\n", $checksum->{'type'});
+ }
+ else
+ {
+ unlink($temporary_filename);
+ printf(" %s checksum does not match (%s instead of %s)\n",
+ $checksum->{'type'},
+ $file_checksum,
+ $checksum->{'value'});
+ return 0;
+ }
+ }
+ else
+ {
+ # The datafile does not contain a checksum to match against.
+ # Display the one that was calculated for the downloaded file so that
+ # it can be integrated manually into the data file.
+ printf("checksum not given, md5 of file is %s\n", $file_checksum);
+ $filename = File::Spec->catfile($ENV{'TARFILE_LOCATION'}, $file_checksum . "-" . $name);
+ }
+
+ rename($temporary_filename, $filename) || die "can not rename $temporary_filename to $filename";
+ return 1;
}
else
{
- exit $rc;
+ unlink($temporary_filename);
+ print " download failed\n";
+ return 0;
}
}
Modified: openoffice/trunk/main/solenv/bin/modules/ExtensionsLst.pm
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/solenv/bin/modules/ExtensionsLst.pm?rev=1772462&r1=1772461&r2=1772462&view=diff
==============================================================================
--- openoffice/trunk/main/solenv/bin/modules/ExtensionsLst.pm (original)
+++ openoffice/trunk/main/solenv/bin/modules/ExtensionsLst.pm Sat Dec 3 11:51:39 2016
@@ -468,19 +468,53 @@ sub Download (@)
{
my ($protocol, $name, $URL, $md5sum) = @{$entry};
- system(
- $ENV{'JAVAINTERPRETER'},
- "-cp",
- File::Spec->catfile(
- File::Spec->catfile($ENV{'SOLARENV'}, $ENV{'INPATH'}),
- "class"),
- "AOOJavaDownloader",
- $name,
- $URL,
- 'MD5',
- $md5sum);
+ # Open a .part file for writing.
+ my $filename = File::Spec->catfile($download_path, $name);
+ my $temporary_filename = $filename . ".part";
+ print "downloading to $temporary_filename\n";
- if ($? != 0)
+ # Prepare md5
+ my $md5 = Digest::MD5->new();
+
+ # Download the extension.
+ my $agent = LWP::UserAgent->new();
+ $agent->timeout(120);
+ $agent->env_proxy;
+ my $last_was_redirect = 0;
+ my $response = $agent->get($URL);
+
+ # 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();
+ if ($md5sum eq $file_md5)
+ {
+ print "md5 is OK\n";
+ }
+ else
+ {
+ unlink($temporary_filename) if ! $Debug;
+ die "downloaded file has the wrong md5 checksum: $file_md5 instead of $md5sum";
+ }
+ }
+ else
+ {
+ print "md5 is not present\n";
+ printf " is %s, length is %d\n", $md5sum, length(md5sum);
+ }
+
+ rename($temporary_filename, $filename) || die "can not rename $temporary_filename to $filename";
+ }
+ else
{
die "failed to download $URL";
}