3 # Copyright (C) 2005, 2006, 2007 Apple Computer, Inc. All rights reserved.
4 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16 # its contributors may be used to endorse or promote products derived
17 # from this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 # Updates a development environment to the new WebKitSupportLibrary
39 use lib $FindBin::Bin;
42 use constant NOTAVERSION => "-1";
44 my $sourceDir = sourceDir();
45 my $file = "WebKitSupportLibrary";
46 my $zipFile = "$file.zip";
47 my $zipDirectory = toUnixPath($ENV{'WEBKITSUPPORTLIBRARIESZIPDIR'}) || $sourceDir;
48 my $pathToZip = File::Spec->catfile($zipDirectory, $zipFile);
49 my $webkitLibrariesDir = toUnixPath($ENV{'WEBKITLIBRARIESDIR'}) || "$sourceDir/WebKitLibraries/win";
50 my $versionFile = $file . "Version";
51 my $pathToVersionFile = File::Spec->catfile($webkitLibrariesDir, $versionFile);
52 my $tmpRelativeDir = File::Temp::tempdir("webkitlibsXXXXXXX", TMPDIR => 1, CLEANUP => 1);
53 my $tmpAbsDir = File::Spec->rel2abs($tmpRelativeDir);
54 my $versionFileURL = "https://developer.apple.com/opensource/internet/$versionFile";
56 my $extractedVersion = extractedVersion();
58 # Check whether the extracted library is up-to-date. If it is, we don't have anything to do.
59 my $expectedVersion = downloadExpectedVersionNumber();
60 if ($extractedVersion ne NOTAVERSION && $extractedVersion eq $expectedVersion) {
61 print "$file is up-to-date.\n";
65 # Check whether the downloaded library is up-to-date. If it isn't, the user needs to download it.
66 my $zipFileVersion = zipFileVersion();
67 dieAndInstructToDownload("$zipFile could not be found in $zipDirectory.") if $zipFileVersion eq NOTAVERSION;
68 dieAndInstructToDownload("$zipFile is out-of-date.") if $expectedVersion ne NOTAVERSION && $zipFileVersion ne $expectedVersion;
69 if ($zipFileVersion eq $extractedVersion) {
70 print "Falling back to existing version of $file.\n";
74 my $result = system "unzip", "-q", "-d", $tmpAbsDir, $pathToZip;
75 die "Couldn't unzip $zipFile." if $result;
77 print "\nInstalling $file...\n";
81 my $relativeName = File::Spec->abs2rel($File::Find::name, "$tmpAbsDir/$file/win");
82 my $destination = "$webkitLibrariesDir/$relativeName";
89 system "cp", $_, $destination;
92 File::Find::find(\&wanted, "$tmpAbsDir/$file");
94 print "The $file has been sucessfully installed in\n $webkitLibrariesDir\n";
101 chomp($path = `cygpath -u '$path'`);
107 if (open VERSION, "<", $pathToVersionFile) {
108 chomp(my $extractedVersion = <VERSION>);
110 return $extractedVersion;
115 sub downloadExpectedVersionNumber
117 chomp(my $expectedVersion = `curl -s --sslv3 -k $versionFileURL`);
118 return WEXITSTATUS($?) ? NOTAVERSION : $expectedVersion;
123 return NOTAVERSION unless -f $pathToZip;
124 chomp(my $zipFileVersion = `unzip -p "$pathToZip" $file/win/$versionFile`);
125 return $zipFileVersion;
128 sub dieAndInstructToDownload
134 ===============================================================================
136 Please download $zipFile from:
138 https://developer.apple.com/opensource/internet/webkit_sptlib_agree.html
144 Then run build-webkit again.
145 ===============================================================================