OSDN Git Service

Merge WebKit at r73109: Initial merge by git.
[android-x86/external-webkit.git] / WebKitTools / Scripts / update-webkit-support-libs
index fa2afd0..f0c897e 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/perl -w
 
 # Copyright (C) 2005, 2006, 2007 Apple Computer, Inc.  All rights reserved.
+# Copyright (C) Research In Motion Limited 2010. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -38,6 +39,8 @@ use FindBin;
 use lib $FindBin::Bin;
 use webkitdirs;
 
+use constant NOTAVERSION => "-1";
+
 my $sourceDir = sourceDir();
 my $file = "WebKitSupportLibrary";
 my $zipFile = "$file.zip"; 
@@ -47,23 +50,25 @@ my $webkitLibrariesDir = toUnixPath($ENV{'WEBKITLIBRARIESDIR'}) || "$sourceDir/W
 my $versionFile = $file . "Version";
 my $pathToVersionFile = File::Spec->catfile($webkitLibrariesDir, $versionFile);
 my $tmpDir = File::Spec->rel2abs(File::Temp::tempdir("webkitlibsXXXXXXX", TMPDIR => 1, CLEANUP => 1));
+my $versionFileURL = "http://developer.apple.com/opensource/internet/$versionFile";
 
-chomp(my $expectedVersion = `curl -s http://developer.apple.com/opensource/internet/$versionFile`);
+my $extractedVersion = extractedVersion();
 
 # Check whether the extracted library is up-to-date. If it is, we don't have anything to do.
-if (open VERSION, "<", $pathToVersionFile) {
-    chomp(my $extractedVersion = <VERSION>);
-    close VERSION;
-    if ($extractedVersion eq $expectedVersion) {
-        print "$file is up-to-date.\n";
-        exit;
-    }
+my $expectedVersion = downloadExpectedVersionNumber();
+if ($extractedVersion ne NOTAVERSION && $extractedVersion eq $expectedVersion) {
+    print "$file is up-to-date.\n";
+    exit;
 }
 
 # Check whether the downloaded library is up-to-date. If it isn't, the user needs to download it.
--f $pathToZip or dieAndInstructToDownload("$zipFile could not be found in $zipDirectory.");
-chomp(my $zipFileVersion = `unzip -p "$pathToZip" $file/win/$versionFile`);
-dieAndInstructToDownload("$zipFile is out-of-date.") if $zipFileVersion ne $expectedVersion;
+my $zipFileVersion = zipFileVersion();
+dieAndInstructToDownload("$zipFile could not be found in $zipDirectory.") if $zipFileVersion eq NOTAVERSION;
+dieAndInstructToDownload("$zipFile is out-of-date.") if $expectedVersion ne NOTAVERSION && $zipFileVersion ne $expectedVersion;
+if ($zipFileVersion eq $extractedVersion) {
+    print "Falling back to existing version of $file.\n";
+    exit;
+}
 
 my $result = system "unzip", "-q", "-d", $tmpDir, $pathToZip;
 die "Couldn't unzip $zipFile." if $result;
@@ -96,6 +101,29 @@ sub toUnixPath
     return $path;
 }
 
+sub extractedVersion
+{
+    if (open VERSION, "<", $pathToVersionFile) {
+        chomp(my $extractedVersion = <VERSION>);
+        close VERSION;
+        return $extractedVersion;
+    }
+    return NOTAVERSION;
+}
+
+sub downloadExpectedVersionNumber
+{
+    chomp(my $expectedVersion = `curl -s $versionFileURL`);
+    return WEXITSTATUS($?) ? NOTAVERSION : $expectedVersion;
+}
+
+sub zipFileVersion
+{
+    return NOTAVERSION unless -f $pathToZip;
+    chomp(my $zipFileVersion = `unzip -p "$pathToZip" $file/win/$versionFile`);
+    return $zipFileVersion;
+}
+
 sub dieAndInstructToDownload
 {
     my $message = shift;