#!/usr/bin/perl -w

# Copyright (C) 2005, 2006, 2007 Apple Computer, Inc.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1.  Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer. 
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution. 
# 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
#     its contributors may be used to endorse or promote products derived
#     from this software without specific prior written permission. 
#
# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Updates a development environment to the new WebKitAuxiliaryLibrary

use strict;
use warnings;

use File::Find;
use File::Temp;
use File::Spec;
use FindBin;
use lib $FindBin::Bin;
use webkitdirs;

my $sourceDir = sourceDir();
my $file = "WebKitAuxiliaryLibrary";
my $zipFile = "$file.zip"; 
my $auxiliaryLibsURL = "http://developer.apple.com/opensource/internet/$zipFile";
my $webkitLibrariesDir = toUnixPath($ENV{'WEBKITLIBRARIESDIR'}) || "$sourceDir/WebKitLibraries/win";
my $tmpDir = File::Spec->rel2abs(File::Temp::tempdir("webkitlibsXXXXXXX", TMPDIR => 1, CLEANUP => 1));

print "Checking Last-Modified date of $zipFile...\n";

my $result = system "curl -s -I $auxiliaryLibsURL | grep Last-Modified > \"$tmpDir/$file.headers\"";
print STDERR "Couldn't check Last-Modified date of new $zipFile.\n" if $result;

if (!$result && open NEW, "$tmpDir/$file.headers") {
    my $new = <NEW>;
    close NEW;

    if (open OLD, "$webkitLibrariesDir/$file.headers") {
        my $old = <OLD>;
        close OLD;
        if ($old eq $new) {
            print "Current $file is up to date\n";
            exit 0;
        }
    }
}

print "Downloading $zipFile...\n\n";
$result = system "curl -o \"$tmpDir/$zipFile\" $auxiliaryLibsURL";
die "Couldn't download $zipFile!" if $result;

$result = system "unzip", "-q", "-d", $tmpDir, "$tmpDir/$zipFile";
die "Couldn't unzip $zipFile." if $result;

print "\nInstalling $file...\n";

sub wanted
{
    my $relativeName = File::Spec->abs2rel($File::Find::name, "$tmpDir/$file/win");
    my $destination = "$webkitLibrariesDir/$relativeName";

    if (-d $_) {
        mkdir $destination;
        return;
    }

    system "cp", $_, $destination;
}

File::Find::find(\&wanted, "$tmpDir/$file");

$result = system "mv", "$tmpDir/$file.headers", $webkitLibrariesDir;
print STDERR "Couldn't move $file.headers to $webkitLibrariesDir" . ".\n" if $result;

print "The $file has been sucessfully installed in\n $webkitLibrariesDir\n";
exit;

sub toUnixPath
{
    my $path = shift;
    return unless $path;
    chomp($path = `cygpath -u '$path'`);
    return $path;
}
