~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Tools/Scripts/update-webkit-libs-jhbuild

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
# Copyright (C) 2011 Igalia S.L.
 
3
# Copyright (C) 2012 Intel Corporation
 
4
#
 
5
# This library is free software; you can redistribute it and/or
 
6
# modify it under the terms of the GNU Lesser General Public
 
7
# License as published by the Free Software Foundation; either
 
8
# version 2 of the License, or (at your option) any later version.
 
9
#
 
10
# This library is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
# Lesser General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU Lesser General Public
 
16
# License along with this library; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 
 
19
use FindBin;
 
20
use lib $FindBin::Bin;
 
21
use webkitdirs;
 
22
use Getopt::Long;
 
23
 
 
24
my $platformEfl = 0;
 
25
my $platformGtk = 0;
 
26
 
 
27
my $getOptionsResult = GetOptions(
 
28
    'efl' => \$platformEfl,
 
29
    'gtk' => \$platformGtk
 
30
    );
 
31
 
 
32
my $platform = "";
 
33
if (!$getOptionsResult) {
 
34
    die "No platform specified for " . basename($0) .". Use --gtk or --efl.\n";
 
35
} else {
 
36
    if ($platformEfl) {
 
37
        $platform = "efl";
 
38
    }
 
39
    if ($platformGtk) {
 
40
        $platform = "gtk";
 
41
    }
 
42
}
 
43
 
 
44
sub getMD5HashForFile($)
 
45
{
 
46
    my $file = shift;
 
47
 
 
48
    open(FILE_CONTENTS, $file);
 
49
 
 
50
    my $contents = "";
 
51
    while (<FILE_CONTENTS>) {
 
52
        $contents .= $_;
 
53
    }
 
54
 
 
55
    close(FILE_CONTENTS);
 
56
 
 
57
    return md5_hex($contents);
 
58
}
 
59
 
 
60
sub jhbuildConfigurationChanged()
 
61
{
 
62
    foreach my $file (qw(jhbuildrc jhbuild.modules)) {
 
63
        my $path = join('/', getJhbuildPath(), $file . '.md5sum');
 
64
        if (! -e $path) {
 
65
            return 1;
 
66
        }
 
67
 
 
68
        # Get the md5 sum of the file we're testing, look in the right platform directory.
 
69
        my $actualFile = join('/', sourceDir(), 'Tools', $platform, $file);
 
70
        my $currentSum = getMD5HashForFile($actualFile);
 
71
 
 
72
        # Get our previous record.
 
73
        open(PREVIOUS_MD5, $path);
 
74
        chomp(my $previousSum = <PREVIOUS_MD5>);
 
75
        close(PREVIOUS_MD5);
 
76
 
 
77
        if ($previousSum ne $currentSum) {
 
78
            return 1;
 
79
        }
 
80
    }
 
81
}
 
82
 
 
83
sub saveJhbuildMd5() {
 
84
    # Save md5sum for jhbuild-related files.saveJhbuildMd5();
 
85
    foreach my $file (qw(jhbuildrc jhbuild.modules)) {
 
86
        my $source = join('/', sourceDir(), "Tools", $platform, $file);
 
87
        my $destination = join('/', getJhbuildPath(), $file);
 
88
        open(SUM, ">$destination" . ".md5sum");
 
89
        print SUM getMD5HashForFile($source);
 
90
        close(SUM);
 
91
    }
 
92
}
 
93
 
 
94
sub runJhbuild
 
95
{
 
96
    my $command = shift;
 
97
    my @jhbuildArgs = ("./jhbuild-wrapper", "--".$platform, $command);
 
98
    push(@jhbuildArgs, @ARGV[2..-1]);
 
99
    system(@jhbuildArgs) == 0 or die "Running jhbuild-wrapper " . $command . " failed.\n";
 
100
}
 
101
 
 
102
sub cleanJhbuild()
 
103
{
 
104
    runJhbuild("clean");
 
105
 
 
106
    # If the configuration changed, dependencies may have been removed.
 
107
    # Since we lack a granular way of uninstalling those we wipe out the
 
108
    # jhbuild root and start from scratch.
 
109
    my $jhbuildPath = getJhbuildPath();
 
110
    if (system("rm -rf $jhbuildPath/Root") ne 0) {
 
111
        die "Cleaning jhbuild root failed!";
 
112
    }
 
113
}
 
114
 
 
115
delete $ENV{AR_FLAGS} if exists $ENV{AR_FLAGS};
 
116
 
 
117
chdir(relativeScriptsDir() . "/../jhbuild") or die $!;
 
118
 
 
119
my %prettyPlatform = ( "efl" => "EFL", "gtk" => "GTK+" );
 
120
 
 
121
if (-e getJhbuildPath() && jhbuildConfigurationChanged()) {
 
122
    cleanJhbuild();
 
123
}
 
124
 
 
125
print "Updating " . $prettyPlatform{$platform} . " port dependencies using jhbuild...\n";
 
126
runJhbuild("build");
 
127
 
 
128
saveJhbuildMd5();