|
1 #!/usr/bin/perl -w |
|
2 |
|
3 # Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
|
4 # Copyright (C) 2009 Google Inc. All rights reserved. |
|
5 # |
|
6 # Redistribution and use in source and binary forms, with or without |
|
7 # modification, are permitted provided that the following conditions |
|
8 # are met: |
|
9 # |
|
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. |
|
18 # |
|
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. |
|
29 |
|
30 # Update script for WebKit Open Source Project. |
|
31 |
|
32 use strict; |
|
33 use FindBin; |
|
34 use lib $FindBin::Bin; |
|
35 use File::Basename; |
|
36 use File::Path; |
|
37 use File::Spec; |
|
38 use Getopt::Long; |
|
39 use VCSUtils; |
|
40 use webkitdirs; |
|
41 |
|
42 sub runSvnUpdate(); |
|
43 sub runGitUpdate(); |
|
44 |
|
45 # Handle options |
|
46 my $quiet = ''; |
|
47 my $showHelp; |
|
48 |
|
49 determineIsChromium(); |
|
50 |
|
51 chdirWebKit(); |
|
52 |
|
53 my $isGit = isGit(); |
|
54 my $isSVN = isSVN(); |
|
55 |
|
56 my $getOptionsResult = GetOptions( |
|
57 'h|help' => \$showHelp, |
|
58 'q|quiet' => \$quiet, |
|
59 ); |
|
60 |
|
61 if (!$getOptionsResult || $showHelp) { |
|
62 print STDERR <<__END__; |
|
63 Usage: @{[ basename($0) ]} [options] |
|
64 --chromium also update dependencies of the chromium port |
|
65 -h|--help show the help message |
|
66 -q|--quiet pass -q to svn update for quiet updates |
|
67 __END__ |
|
68 exit 1; |
|
69 } |
|
70 |
|
71 my $startTime = time(); |
|
72 |
|
73 my @svnOptions = (); |
|
74 push @svnOptions, '-q' if $quiet; |
|
75 |
|
76 # Don't prompt when using svn-1.6 or newer. |
|
77 push @svnOptions, qw(--accept postpone) if isSVNVersion16OrNewer(); |
|
78 |
|
79 print "Updating OpenSource\n" unless $quiet; |
|
80 runSvnUpdate() if $isSVN; |
|
81 runGitUpdate() if $isGit; |
|
82 |
|
83 if (-d "../Internal") { |
|
84 chdir("../Internal"); |
|
85 print "Updating Internal\n" unless $quiet; |
|
86 runSvnUpdate() if $isSVN; |
|
87 runGitUpdate() if $isGit; |
|
88 } elsif (isChromium()) { |
|
89 # Workaround for https://bugs.webkit.org/show_bug.cgi?id=38926 |
|
90 # We should remove the following "if" block when we find a right fix. |
|
91 if ((isCygwin() || isWindows()) && (stat("WebKit/chromium/features.gypi"))[9] >= $startTime) { |
|
92 print "features.gypi has been updated. Cleaning the build directories.\n"; |
|
93 rmtree(["WebKit/chromium/Debug", "WebKit/chromium/Release"]); |
|
94 } |
|
95 |
|
96 system("perl", "WebKitTools/Scripts/update-webkit-chromium") == 0 or die $!; |
|
97 } elsif (isAppleWinWebKit()) { |
|
98 system("perl", "WebKitTools/Scripts/update-webkit-auxiliary-libs") == 0 or die; |
|
99 } |
|
100 |
|
101 setupAppleWinEnv() if isAppleWinWebKit(); |
|
102 |
|
103 exit 0; |
|
104 |
|
105 sub runSvnUpdate() |
|
106 { |
|
107 open UPDATE, "-|", "svn", "update", @svnOptions or die; |
|
108 my @conflictedChangeLogs; |
|
109 while (my $line = <UPDATE>) { |
|
110 print $line; |
|
111 $line =~ m/^C\s+(.+?)[\r\n]*$/; |
|
112 if ($1) { |
|
113 my $filename = normalizePath($1); |
|
114 push @conflictedChangeLogs, $filename if basename($filename) eq "ChangeLog"; |
|
115 } |
|
116 } |
|
117 close UPDATE or die; |
|
118 |
|
119 if (@conflictedChangeLogs) { |
|
120 print "Attempting to merge conflicted ChangeLogs.\n"; |
|
121 my $resolveChangeLogsPath = File::Spec->catfile(dirname($0), "resolve-ChangeLogs"); |
|
122 (system($resolveChangeLogsPath, "--no-warnings", @conflictedChangeLogs) == 0) |
|
123 or die "Could not open resolve-ChangeLogs script: $!.\n"; |
|
124 } |
|
125 } |
|
126 |
|
127 sub runGitUpdate() |
|
128 { |
|
129 system("git", "svn", "rebase") == 0 or die; |
|
130 } |