Home | History | Annotate | Download | only in Scripts
      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::Spec;
     37 use Getopt::Long;
     38 use VCSUtils;
     39 use webkitdirs;
     40 
     41 sub runSvnUpdate();
     42 sub runGitUpdate();
     43 
     44 # Handle options
     45 my $quiet = '';
     46 my $showHelp;
     47 
     48 determineIsChromium();
     49 
     50 chdirWebKit();
     51 
     52 my $isGit = isGit();
     53 my $isSVN = isSVN();
     54 
     55 my $getOptionsResult = GetOptions(
     56     'h|help'  => \$showHelp,
     57     'q|quiet' => \$quiet,
     58 ); 
     59 
     60 if (!$getOptionsResult || $showHelp) {
     61     print STDERR <<__END__;
     62 Usage: @{[ basename($0) ]} [options]
     63   --chromium  also update dependencies of the chromium port
     64   -h|--help   show the help message
     65   -q|--quiet  pass -q to svn update for quiet updates
     66 __END__
     67     exit 1;
     68 }
     69 
     70 my @svnOptions = ();
     71 push @svnOptions, '-q' if $quiet;
     72 
     73 # Don't prompt when using svn-1.6 or newer.
     74 push @svnOptions, qw(--accept postpone) if isSVNVersion16OrNewer();
     75 
     76 print "Updating OpenSource\n" unless $quiet;
     77 runSvnUpdate() if $isSVN;
     78 runGitUpdate() if $isGit;
     79 
     80 if (-d "../Internal") {
     81     chdir("../Internal");
     82     print "Updating Internal\n" unless $quiet;
     83     runSvnUpdate() if $isSVN;
     84     runGitUpdate() if $isGit;
     85 } elsif (isChromium()) {
     86     system("perl", "WebKitTools/Scripts/update-webkit-chromium") == 0 or die $!;
     87 } elsif (isAppleWinWebKit()) {
     88     system("perl", "WebKitTools/Scripts/update-webkit-auxiliary-libs") == 0 or die;
     89 }
     90 
     91 setupAppleWinEnv() if isAppleWinWebKit();
     92 
     93 exit 0;
     94 
     95 sub runSvnUpdate()
     96 {
     97     open UPDATE, "-|", "svn", "update", @svnOptions or die;
     98     my @conflictedChangeLogs;
     99     while (my $line = <UPDATE>) {
    100         print $line;
    101         $line =~ m/^C\s+(.+?)[\r\n]*$/;
    102         if ($1) {
    103           my $filename = normalizePath($1);
    104           push @conflictedChangeLogs, $filename if basename($filename) eq "ChangeLog";
    105         }
    106     }
    107     close UPDATE or die;
    108 
    109     if (@conflictedChangeLogs) {
    110         print "Attempting to merge conflicted ChangeLogs.\n";
    111         my $resolveChangeLogsPath = File::Spec->catfile(dirname($0), "resolve-ChangeLogs");
    112         (system($resolveChangeLogsPath, "--no-warnings", @conflictedChangeLogs) == 0)
    113             or die "Could not open resolve-ChangeLogs script: $!.\n";
    114     }
    115 }
    116 
    117 sub runGitUpdate()
    118 {
    119     system("git", "svn", "rebase") == 0 or die;
    120 }
    121