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 LWP::Simple;
use POSIX;
use lib $FindBin::Bin;
use webkitdirs;
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'} || "$sourceDir/WebKitLibraries/win";
my $tmpRelativeDir = File::Temp::tempdir("webkitlibsXXXXXXX", TMPDIR => 1, CLEANUP => 1);
my $tmpAbsDir = File::Spec->rel2abs($tmpRelativeDir);
print "Checking Last-Modified date of $zipFile...\n";
-my $result = system "curl -s -I -k $libsURL | grep Last-Modified > \"$tmpAbsDir/$file.headers\"";
+my ($content_type, $document_length, $modified_time, $expires, $server) = head($libsURL);
-if (WEXITSTATUS($result)) {
+if (defined $modified_time) {
+
+ open NEW, ">", "$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 -o \"$tmpAbsDir/$file.headers\" $headerURL";
+ my $result = getstore($headerURL, "$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 "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") {
print STDERR "Unable to check Last-Modified date and no version of $file to fall back to.\n";
}
print "Downloading $zipFile...\n\n";
-$result = system "curl -k -o \"$tmpAbsDir/$zipFile\" $libsURL";
-die "Couldn't download $zipFile!" if $result;
+print "$libsURL\n";
+my $result = getstore($libsURL, "$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("$tmpAbsDir/$zipFile");
+$result = $zip->extractTree("", $tmpAbsDir);
+die "Couldn't unzip $zipFile." if $result != AZ_OK;
print "\nInstalling $file...\n";
return;
}
- system "cp", $_, $destination;
+ copy($_, $destination);
}
File::Find::find(\&wanted, "$tmpAbsDir/$file");
-$result = system "mv", "$tmpAbsDir/$file.headers", $webkitLibrariesDir;
-print STDERR "Couldn't move $file.headers to $webkitLibrariesDir" . ".\n" if $result;
+$result = move("$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) = @_;
sub fontExists($)
{
my $font = shift;
- my $val = system qw(regtool get), '\\HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts\\' . $font . ' (TrueType)';
- return 0 == $val;
+ my $cmd = "reg query \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts\\" . $font ."\" 2>&1";
+ my $val = `$cmd`;
+ return $? == 0;
}
sub checkInstalledTools()
{
# SVN 1.7.10 is known to be compatible with current servers. SVN 1.8.x seems to be missing some authentication
# protocols we use for svn.webkit.org:
- my $svnVersion = `svn --version | grep "\\sversion"`;
+ my $svnVersion = `svn --version 2> NUL | grep "\\sversion"`;
chomp($svnVersion);
if (!$? and $svnVersion =~ /1\.8\./) {
print "svn 1.7.10 is known to be compatible with our servers. You are running $svnVersion,\nwhich may not work properly.\n"
die "You must have Python installed to build WebKit.\n" if ($?);
# cURL 7.34.0 has a bug that prevents authentication with opensource.apple.com (and other things using SSL3).
- my $curlVer = `curl --version | grep "curl"`;
+ my $curlVer = `curl --version 2> NUL | grep "curl"`;
chomp($curlVer);
if (!$? and $curlVer =~ /libcurl\/7\.34\.0/) {
print "cURL version 7.34.0 has a bug that prevents authentication with SSL v2 or v3.\n";
foreach my $variable (keys %variablesToSet) {
print "Setting the Environment Variable '" . $variable . "' to '" . $variablesToSet{$variable} . "'\n\n";
- system qw(regtool -s set), '\\HKEY_CURRENT_USER\\Environment\\' . $variable, $variablesToSet{$variable};
+ my $ret = system "setx", $variable, $variablesToSet{$variable};
+ if ($ret != 0) {
+ system qw(regtool -s set), '\\HKEY_CURRENT_USER\\Environment\\' . $variable, $variablesToSet{$variable};
+ }
$restartNeeded ||= $variable eq "WEBKIT_LIBRARIES" || $variable eq "WEBKIT_OUTPUTDIR";
}