summaryrefslogtreecommitdiffstats
path: root/Tools/Scripts/update-webkit-dependency
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/Scripts/update-webkit-dependency')
-rwxr-xr-xTools/Scripts/update-webkit-dependency77
1 files changed, 47 insertions, 30 deletions
diff --git a/Tools/Scripts/update-webkit-dependency b/Tools/Scripts/update-webkit-dependency
index 2654229cc..0bb7ed3bb 100755
--- a/Tools/Scripts/update-webkit-dependency
+++ b/Tools/Scripts/update-webkit-dependency
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
-# Copyright (C) 2005, 2006, 2007 Apple Computer, Inc. All rights reserved.
+# Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
# Copyright (C) 2011 Carl Lobo. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -12,7 +12,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+# 3. Neither the name of Apple Inc. ("Apple") nor the names of
# its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
@@ -32,11 +32,16 @@
use strict;
use warnings;
+use Archive::Zip qw( :ERROR_CODES );
+use File::Copy;
use File::Find;
use File::Spec;
use File::Temp ();
use FindBin;
-use HTTP::Date qw(str2time);
+use HTTP::Date qw(str2time time2str);
+use HTTP::Request;
+use LWP::Simple;
+use LWP::UserAgent;
use POSIX;
use lib $FindBin::Bin;
use webkitdirs;
@@ -67,28 +72,46 @@ my $prefixInZip = shift;
my $sourceDir = sourceDir();
my $file = getLibraryName($libsURL);
my $zipFile = "$file.zip";
-my $webkitLibrariesDir = toUnixPath($ENV{'WEBKIT_LIBRARIES'}) || "$sourceDir/WebKitLibraries/win";
+my $webkitLibrariesDir = $ENV{'WEBKIT_LIBRARIES'} || File::Spec->catdir($sourceDir, "WebKitLibraries", "win");
my $tmpRelativeDir = File::Temp::tempdir("webkitlibsXXXXXXX", TMPDIR => 1, CLEANUP => 1);
my $tmpAbsDir = File::Spec->rel2abs($tmpRelativeDir);
+my $ua = LWP::UserAgent->new();
+$ua->env_proxy;
print "Checking Last-Modified date of $zipFile...\n";
-my $result = system "curl -s -I -k --sslv3 $libsURL | grep Last-Modified > \"$tmpAbsDir/$file.headers\"";
+my $response = $ua->get($libsURL);
-if (WEXITSTATUS($result)) {
+unless ($response->is_success) {
+ print "Could not access $libsURL:\n" . $response->headers_as_string . "\n";
+ print "You may not be connected to the internet. Attempting to build without updating.\n";
+ exit 0;
+}
+
+my $content_type = $response->header('Content-Type');
+my $document_length = $response->header('Content-Length');
+my $modified_time = str2time($response->header('Last-Modified'));
+if (defined $modified_time) {
+ print STDERR "Located a file of type $content_type, of size $document_length.\n";
+ open NEW, ">", File::Spec->catfile($tmpAbsDir, "$file.headers");
+ print NEW "Last-Modified: " . time2str($modified_time) . "\n";
+ close NEW;
+} else {
#Note: Neither GitHub nor DropBox emit the Last-Modified HTTP header, so fall back to a file
#containing the necessary information if we do not receive the information in our initial query.
my $headerURL = $libsURL;
$headerURL =~ s/\.zip$/\.headers/;
- $result = system "curl -k --sslv3 -o \"$tmpAbsDir/$file.headers\" $headerURL";
+ my $result = getstore($headerURL, File::Spec->catfile($tmpAbsDir, "$file.headers"));
- if (WEXITSTATUS($result)) {
+ if (!is_success($result)) {
print STDERR "Couldn't check Last-Modified date of new $zipFile.\n";
- print STDERR "Please ensure that $libsURL is reachable.\n";
+ print STDERR "Response was: $result.\n";
+ print STDERR "Please ensure that Perl can use LWP::Simple to connect to HTTPS urls, and that $libsURL is reachable.\n";
+ print STDERR "You may have to run \$ cpan LWP::Protocol::https\n";
- if (! -f "$webkitLibrariesDir/$file.headers") {
+ if (! -f File::Spec->catfile($webkitLibrariesDir, "$file.headers")) {
print STDERR "Unable to check Last-Modified date and no version of $file to fall back to.\n";
exit 1;
}
@@ -98,11 +121,11 @@ if (WEXITSTATUS($result)) {
}
}
-if (open NEW, "$tmpAbsDir/$file.headers") {
+if (open NEW, File::Spec->catfile($tmpAbsDir, "$file.headers")) {
my $new = lastModifiedToUnixTime(<NEW>);
close NEW;
- if (defined $new && open OLD, "$webkitLibrariesDir/$file.headers") {
+ if (defined $new && open OLD, File::Spec->catfile($webkitLibrariesDir, "$file.headers")) {
my $old = lastModifiedToUnixTime(<OLD>);
close OLD;
if (defined $old && abs($new - $old) < $newnessThreshold) {
@@ -113,43 +136,37 @@ if (open NEW, "$tmpAbsDir/$file.headers") {
}
print "Downloading $zipFile...\n\n";
-$result = system "curl -k --sslv3 -o \"$tmpAbsDir/$zipFile\" $libsURL";
-die "Couldn't download $zipFile!" if $result;
+print "$libsURL\n";
+my $result = getstore($libsURL, File::Spec->catfile($tmpAbsDir, $zipFile));
+die "Couldn't download $zipFile!" if is_error($result);
-$result = system "unzip", "-q", "-d", $tmpAbsDir, "$tmpAbsDir/$zipFile";
-die "Couldn't unzip $zipFile." if $result;
+my $zip = Archive::Zip->new(File::Spec->catfile($tmpAbsDir, $zipFile));
+$result = $zip->extractTree("", $tmpAbsDir);
+die "Couldn't unzip $zipFile." if $result != AZ_OK;
print "\nInstalling $file...\n";
sub wanted
{
- my $relativeName = File::Spec->abs2rel($File::Find::name, "$tmpAbsDir/$file/$prefixInZip");
- my $destination = "$webkitLibrariesDir/$relativeName";
+ my $relativeName = File::Spec->abs2rel($File::Find::name, File::Spec->catdir($tmpAbsDir, $file, $prefixInZip));
+ my $destination = File::Spec->catfile($webkitLibrariesDir, $relativeName);
if (-d $_) {
mkdir $destination;
return;
}
- system "cp", $_, $destination;
+ copy($_, $destination);
}
-File::Find::find(\&wanted, "$tmpAbsDir/$file");
+File::Find::find(\&wanted, File::Spec->catfile($tmpAbsDir, $file));
-$result = system "mv", "$tmpAbsDir/$file.headers", $webkitLibrariesDir;
-print STDERR "Couldn't move $file.headers to $webkitLibrariesDir" . ".\n" if $result;
+$result = move(File::Spec->catfile($tmpAbsDir, "$file.headers"), $webkitLibrariesDir);
+print STDERR "Couldn't move $file.headers to $webkitLibrariesDir" . ".\n" if $result == 0;
print "The $file has been sucessfully installed in\n $webkitLibrariesDir\n";
exit;
-sub toUnixPath
-{
- my $path = shift;
- return unless $path;
- chomp($path = `cygpath -u '$path'`);
- return $path;
-}
-
sub lastModifiedToUnixTime($)
{
my ($str) = @_;