File: update-webkit-libs-jhbuild

package info (click to toggle)
qtwebkit 2.3.4.dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 290,116 kB
  • ctags: 272,544
  • sloc: cpp: 1,417,496; python: 85,048; ansic: 39,353; perl: 38,858; ruby: 10,313; objc: 9,505; xml: 8,679; asm: 3,864; yacc: 2,458; sh: 1,237; lex: 813; makefile: 592; java: 228; php: 79
file content (128 lines) | stat: -rwxr-xr-x 3,586 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/perl -w
# Copyright (C) 2011 Igalia S.L.
# Copyright (C) 2012 Intel Corporation
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

use FindBin;
use lib $FindBin::Bin;
use webkitdirs;
use Getopt::Long;

my $platformEfl = 0;
my $platformGtk = 0;

my $getOptionsResult = GetOptions(
    'efl' => \$platformEfl,
    'gtk' => \$platformGtk
    );

my $platform = "";
if (!$getOptionsResult) {
    die "No platform specified for " . basename($0) .". Use --gtk or --efl.\n";
} else {
    if ($platformEfl) {
        $platform = "efl";
    }
    if ($platformGtk) {
        $platform = "gtk";
    }
}

sub getMD5HashForFile($)
{
    my $file = shift;

    open(FILE_CONTENTS, $file);

    my $contents = "";
    while (<FILE_CONTENTS>) {
        $contents .= $_;
    }

    close(FILE_CONTENTS);

    return md5_hex($contents);
}

sub jhbuildConfigurationChanged()
{
    foreach my $file (qw(jhbuildrc jhbuild.modules)) {
        my $path = join('/', getJhbuildPath(), $file . '.md5sum');
        if (! -e $path) {
            return 1;
        }

        # Get the md5 sum of the file we're testing, look in the right platform directory.
        my $actualFile = join('/', sourceDir(), 'Tools', $platform, $file);
        my $currentSum = getMD5HashForFile($actualFile);

        # Get our previous record.
        open(PREVIOUS_MD5, $path);
        chomp(my $previousSum = <PREVIOUS_MD5>);
        close(PREVIOUS_MD5);

        if ($previousSum ne $currentSum) {
            return 1;
        }
    }
}

sub saveJhbuildMd5() {
    # Save md5sum for jhbuild-related files.saveJhbuildMd5();
    foreach my $file (qw(jhbuildrc jhbuild.modules)) {
        my $source = join('/', sourceDir(), "Tools", $platform, $file);
        my $destination = join('/', getJhbuildPath(), $file);
        open(SUM, ">$destination" . ".md5sum");
        print SUM getMD5HashForFile($source);
        close(SUM);
    }
}

sub runJhbuild
{
    my $command = shift;
    my @jhbuildArgs = ("./jhbuild-wrapper", "--".$platform, $command);
    push(@jhbuildArgs, @ARGV[2..-1]);
    system(@jhbuildArgs) == 0 or die "Running jhbuild-wrapper " . $command . " failed.\n";
}

sub cleanJhbuild()
{
    runJhbuild("clean");

    # If the configuration changed, dependencies may have been removed.
    # Since we lack a granular way of uninstalling those we wipe out the
    # jhbuild root and start from scratch.
    my $jhbuildPath = getJhbuildPath();
    if (system("rm -rf $jhbuildPath/Root") ne 0) {
        die "Cleaning jhbuild root failed!";
    }
}

delete $ENV{AR_FLAGS} if exists $ENV{AR_FLAGS};

chdir(relativeScriptsDir() . "/../jhbuild") or die $!;

my %prettyPlatform = ( "efl" => "EFL", "gtk" => "GTK+" );

if (-e getJhbuildPath() && jhbuildConfigurationChanged()) {
    cleanJhbuild();
}

print "Updating " . $prettyPlatform{$platform} . " port dependencies using jhbuild...\n";
runJhbuild("build");

saveJhbuildMd5();