|
1 #!/usr/bin/perl -w |
|
2 |
|
3 # Copyright (C) 2005, 2006, 2007 Apple Computer, Inc. All rights reserved. |
|
4 # |
|
5 # Redistribution and use in source and binary forms, with or without |
|
6 # modification, are permitted provided that the following conditions |
|
7 # are met: |
|
8 # |
|
9 # 1. Redistributions of source code must retain the above copyright |
|
10 # notice, this list of conditions and the following disclaimer. |
|
11 # 2. Redistributions in binary form must reproduce the above copyright |
|
12 # notice, this list of conditions and the following disclaimer in the |
|
13 # documentation and/or other materials provided with the distribution. |
|
14 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
|
15 # its contributors may be used to endorse or promote products derived |
|
16 # from this software without specific prior written permission. |
|
17 # |
|
18 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
|
19 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
21 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
|
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
|
27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
|
29 # Updates a development environment to the new WebKitAuxiliaryLibrary |
|
30 |
|
31 use strict; |
|
32 use warnings; |
|
33 |
|
34 use File::Find; |
|
35 use File::Temp; |
|
36 use File::Spec; |
|
37 use FindBin; |
|
38 use lib $FindBin::Bin; |
|
39 use webkitdirs; |
|
40 |
|
41 my $sourceDir = sourceDir(); |
|
42 my $file = "WebKitAuxiliaryLibrary"; |
|
43 my $zipFile = "$file.zip"; |
|
44 my $auxiliaryLibsURL = "http://developer.apple.com/opensource/internet/$zipFile"; |
|
45 my $webkitLibrariesDir = toUnixPath($ENV{'WEBKITLIBRARIESDIR'}) || "$sourceDir/WebKitLibraries/win"; |
|
46 my $tmpDir = File::Spec->rel2abs(File::Temp::tempdir("webkitlibsXXXXXXX", TMPDIR => 1, CLEANUP => 1)); |
|
47 |
|
48 print "Checking Last-Modified date of $zipFile...\n"; |
|
49 |
|
50 my $result = system "curl -s -I $auxiliaryLibsURL | grep Last-Modified > \"$tmpDir/$file.headers\""; |
|
51 print STDERR "Couldn't check Last-Modified date of new $zipFile.\n" if $result; |
|
52 |
|
53 if (!$result && open NEW, "$tmpDir/$file.headers") { |
|
54 my $new = <NEW>; |
|
55 close NEW; |
|
56 |
|
57 if (open OLD, "$webkitLibrariesDir/$file.headers") { |
|
58 my $old = <OLD>; |
|
59 close OLD; |
|
60 if ($old eq $new) { |
|
61 print "Current $file is up to date\n"; |
|
62 exit 0; |
|
63 } |
|
64 } |
|
65 } |
|
66 |
|
67 print "Downloading $zipFile...\n\n"; |
|
68 $result = system "curl -o \"$tmpDir/$zipFile\" $auxiliaryLibsURL"; |
|
69 die "Couldn't download $zipFile!" if $result; |
|
70 |
|
71 $result = system "unzip", "-q", "-d", $tmpDir, "$tmpDir/$zipFile"; |
|
72 die "Couldn't unzip $zipFile." if $result; |
|
73 |
|
74 print "\nInstalling $file...\n"; |
|
75 |
|
76 sub wanted |
|
77 { |
|
78 my $relativeName = File::Spec->abs2rel($File::Find::name, "$tmpDir/$file/win"); |
|
79 my $destination = "$webkitLibrariesDir/$relativeName"; |
|
80 |
|
81 if (-d $_) { |
|
82 mkdir $destination; |
|
83 return; |
|
84 } |
|
85 |
|
86 system "cp", $_, $destination; |
|
87 } |
|
88 |
|
89 File::Find::find(\&wanted, "$tmpDir/$file"); |
|
90 |
|
91 $result = system "mv", "$tmpDir/$file.headers", $webkitLibrariesDir; |
|
92 print STDERR "Couldn't move $file.headers to $webkitLibrariesDir" . ".\n" if $result; |
|
93 |
|
94 print "The $file has been sucessfully installed in\n $webkitLibrariesDir\n"; |
|
95 exit; |
|
96 |
|
97 sub toUnixPath |
|
98 { |
|
99 my $path = shift; |
|
100 return unless $path; |
|
101 chomp($path = `cygpath -u '$path'`); |
|
102 return $path; |
|
103 } |