2011-05-06 00:52:54 +00:00
|
|
|
#!/usr/bin/env perl
|
2011-04-27 10:34:00 +00:00
|
|
|
#############################################################################
|
|
|
|
##
|
2012-01-05 07:27:21 +00:00
|
|
|
## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-04-27 10:34:00 +00:00
|
|
|
## All rights reserved.
|
|
|
|
## Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
##
|
|
|
|
## This file is part of the utilities of the Qt Toolkit.
|
|
|
|
##
|
|
|
|
## $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
## GNU Lesser General Public License Usage
|
2011-07-08 11:10:54 +00:00
|
|
|
## This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
## License version 2.1 as published by the Free Software Foundation and
|
|
|
|
## appearing in the file LICENSE.LGPL included in the packaging of this
|
|
|
|
## file. Please review the following information to ensure the GNU Lesser
|
|
|
|
## General Public License version 2.1 requirements will be met:
|
|
|
|
## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-04-27 10:34:00 +00:00
|
|
|
##
|
|
|
|
## In addition, as a special exception, Nokia gives you certain additional
|
2011-07-08 11:10:54 +00:00
|
|
|
## rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-04-27 10:34:00 +00:00
|
|
|
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
##
|
2011-07-08 11:10:54 +00:00
|
|
|
## GNU General Public License Usage
|
|
|
|
## Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
## Public License version 3.0 as published by the Free Software Foundation
|
|
|
|
## and appearing in the file LICENSE.GPL included in the packaging of this
|
|
|
|
## file. Please review the following information to ensure the GNU General
|
|
|
|
## Public License version 3.0 requirements will be met:
|
|
|
|
## http://www.gnu.org/copyleft/gpl.html.
|
2011-04-27 10:34:00 +00:00
|
|
|
##
|
2011-07-08 11:10:54 +00:00
|
|
|
## Other Usage
|
|
|
|
## Alternatively, this file may be used in accordance with the terms and
|
|
|
|
## conditions contained in a signed written agreement between you and Nokia.
|
2011-04-27 10:34:00 +00:00
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
## $QT_END_LICENSE$
|
|
|
|
##
|
|
|
|
#############################################################################
|
|
|
|
|
2011-05-15 23:54:36 +00:00
|
|
|
use v5.10;
|
2011-04-28 04:19:42 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
package Qt::InitRepository;
|
|
|
|
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
init-repository - initialize the Qt5 repository and all submodules
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
./init-repository [options]
|
|
|
|
|
|
|
|
This script may be run after an initial `git clone' of Qt5 in order to check
|
|
|
|
out all submodules.
|
|
|
|
|
|
|
|
|
2011-05-15 23:52:17 +00:00
|
|
|
=head1 OPTIONS
|
|
|
|
|
|
|
|
B<Global options:>
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item --force, -f
|
|
|
|
|
|
|
|
Force initialization (even if the submodules are already checked out).
|
|
|
|
|
|
|
|
|
|
|
|
=item --quiet, -q
|
|
|
|
|
|
|
|
Be quiet. Will exit cleanly if the repository is already initialized.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
2011-05-15 23:52:17 +00:00
|
|
|
B<Module options:>
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item --no-webkit
|
|
|
|
|
|
|
|
Skip webkit and webkit examples submodules.
|
|
|
|
It may be desirable to skip these modules due to the large size of the webkit
|
|
|
|
git repository.
|
|
|
|
|
2011-07-06 07:53:58 +00:00
|
|
|
=item --module-subset=<module1>,<module2>...
|
|
|
|
|
|
|
|
Only initialize the specified subset of modules given as the argument. Specified
|
|
|
|
modules must already exist in .gitmodules.
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
=item --no-update
|
|
|
|
|
|
|
|
Skip the `git submodule update' command.
|
|
|
|
|
|
|
|
|
|
|
|
=item --ignore-submodules
|
|
|
|
|
|
|
|
Set git config to ignore submodules by default when doing operations on the
|
|
|
|
qt5 repo, such as `pull', `fetch', `diff' etc.
|
|
|
|
|
2011-06-01 15:52:29 +00:00
|
|
|
This option is default for --nokia-developer/--brisbane.
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
After using this option, pass `--ignore-submodules=none' to git to override
|
|
|
|
it as needed.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
2011-05-15 23:52:17 +00:00
|
|
|
B<Repository options:>
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item --nokia-developer
|
|
|
|
|
|
|
|
Switch to internal Nokia URLs.
|
|
|
|
|
|
|
|
|
|
|
|
=item --brisbane
|
|
|
|
|
|
|
|
Switch to internal Nokia URLs and make use of the Brisbane git mirrors.
|
|
|
|
(Implies `--mirror' and `--mirror-webkit').
|
|
|
|
|
2011-06-21 06:37:30 +00:00
|
|
|
=item --berlin
|
|
|
|
|
|
|
|
Switch to internal Nokia URLs and make use of the Berlin git mirrors.
|
|
|
|
(Implies `--mirror' and `--mirror-webkit').
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
=item --ssh
|
|
|
|
|
|
|
|
Use the SSH protocol for git operations. This may be useful if the git
|
|
|
|
protocol is blocked by a firewall. Note that this requires a user account
|
|
|
|
with an uploaded SSH key on all servers used. (Implies `--nokia-developer').
|
|
|
|
|
2011-07-07 00:49:23 +00:00
|
|
|
The `--ssh' option does not affect the gerrit remotes.
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
=item --http
|
|
|
|
|
|
|
|
Use the HTTP protocol for git operations. This may be useful if the git
|
|
|
|
protocol is blocked by a firewall. Note that this only works with the
|
|
|
|
external Gitorious server.
|
|
|
|
|
2011-07-07 00:49:23 +00:00
|
|
|
The `--http' option does not affect the gerrit remotes.
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
|
2011-06-01 18:16:09 +00:00
|
|
|
=item --codereview-username <Gerrit/JIRA username>
|
|
|
|
|
2011-11-09 14:59:24 +00:00
|
|
|
Specify the user name for the (potentially) writable `gerrit' remote
|
|
|
|
for each module, for use with the Gerrit code review tool.
|
2011-06-01 18:16:09 +00:00
|
|
|
|
2011-11-09 14:59:24 +00:00
|
|
|
If this option is omitted, the gerrit remote is created without a username
|
|
|
|
and port number, and thus relies on a correct SSH configuration.
|
2011-07-07 00:49:23 +00:00
|
|
|
|
2011-06-01 18:16:09 +00:00
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
=item --alternates <path to other Qt5 repo>
|
|
|
|
|
|
|
|
Adds alternates for each submodule to another full qt5 checkout. This makes
|
|
|
|
this qt5 checkout very small, as it will use the object store of the
|
|
|
|
alternates before unique objects are stored in its own object store.
|
|
|
|
|
|
|
|
This option has no effect when using `--no-update'.
|
|
|
|
|
|
|
|
B<NOTE:> This will make this repo dependent on the alternate, which is
|
|
|
|
potentially dangerous! The dependency can be broken by also using
|
|
|
|
the `--copy-objects' option, or by running C<git repack -a> in each
|
|
|
|
submodule, where required. Please read the note about the `--shared' option
|
|
|
|
in the documentation of `git clone' for more information.
|
|
|
|
|
|
|
|
|
|
|
|
=item --copy-objects
|
|
|
|
|
|
|
|
When `--alternates' is used, automatically do a C<git repack -a> in each
|
|
|
|
submodule after cloning, to ensure that the repositories are independent
|
|
|
|
from the source used as a reference for cloning.
|
|
|
|
|
|
|
|
Note that this negates the disk usage benefits gained from the use of
|
|
|
|
`--alternates'.
|
|
|
|
|
|
|
|
|
|
|
|
=item --mirror <url-base>
|
|
|
|
|
|
|
|
Uses <url-base> as the base URL for submodule git mirrors.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
--mirror user@machine:/foo/bar
|
|
|
|
|
|
|
|
...will use the following as a mirror for qtbase:
|
|
|
|
|
|
|
|
user@machine:/foo/bar/qtbase.git
|
|
|
|
|
|
|
|
|
|
|
|
=item --mirror-webkit <url>
|
|
|
|
|
|
|
|
Uses <url> as the URL for the webkit git mirror.
|
|
|
|
|
2011-12-13 20:47:28 +00:00
|
|
|
=item --mirror-v8 <url>
|
|
|
|
|
|
|
|
Uses <url> as the URL for the V8 git mirror.
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
=back
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
use Carp qw( confess );
|
|
|
|
use English qw( -no_match_vars );
|
|
|
|
use Getopt::Long qw( GetOptionsFromArray );
|
|
|
|
use Pod::Usage qw( pod2usage );
|
2011-05-11 05:24:41 +00:00
|
|
|
use Cwd qw( getcwd );
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
my %PROTOCOLS = (
|
|
|
|
'internal' => 'git://scm.dev.nokia.troll.no/' ,
|
|
|
|
'ssh' => 'git@scm.dev.nokia.troll.no:' ,
|
|
|
|
'http' => 'http://git.gitorious.org/' ,
|
2011-05-04 17:49:18 +00:00
|
|
|
);
|
2011-04-27 10:34:00 +00:00
|
|
|
|
2011-07-07 00:49:23 +00:00
|
|
|
my %GERRIT_REPOS = map { $_ => "qt/$_" } qw(
|
2011-12-09 01:59:06 +00:00
|
|
|
qt3d
|
2011-06-01 16:00:33 +00:00
|
|
|
qt5
|
2011-07-07 00:49:23 +00:00
|
|
|
qlalr
|
2011-06-01 16:00:33 +00:00
|
|
|
qtactiveqt
|
|
|
|
qtbase
|
2011-08-24 06:05:34 +00:00
|
|
|
qtconnectivity
|
2011-06-01 16:00:33 +00:00
|
|
|
qtdeclarative
|
|
|
|
qtdoc
|
2011-08-09 23:37:37 +00:00
|
|
|
qtdocgallery
|
2011-07-07 00:49:23 +00:00
|
|
|
qtfeedback
|
2011-10-28 14:22:01 +00:00
|
|
|
qtjsondb
|
2011-07-07 00:49:23 +00:00
|
|
|
qtlocation
|
2011-10-26 06:40:48 +00:00
|
|
|
qtmultimedia
|
2011-06-01 16:00:33 +00:00
|
|
|
qtphonon
|
2011-08-24 00:57:25 +00:00
|
|
|
qtpim
|
2011-06-01 16:00:33 +00:00
|
|
|
qtqa
|
2011-07-07 00:49:23 +00:00
|
|
|
qtrepotools
|
2011-06-01 16:00:33 +00:00
|
|
|
qtscript
|
2011-07-07 00:49:23 +00:00
|
|
|
qtsensors
|
2011-06-01 16:00:33 +00:00
|
|
|
qtsvg
|
2011-07-07 00:49:23 +00:00
|
|
|
qtsystems
|
2011-06-01 16:00:33 +00:00
|
|
|
qttools
|
|
|
|
qttranslations
|
2011-09-26 23:21:52 +00:00
|
|
|
qtwayland
|
2011-06-01 16:00:33 +00:00
|
|
|
qtwebkit-examples-and-demos
|
|
|
|
qtxmlpatterns
|
2011-05-05 14:37:24 +00:00
|
|
|
);
|
2011-07-14 09:13:54 +00:00
|
|
|
$GERRIT_REPOS{qtquick3d} = "qt/quick3d";
|
|
|
|
|
|
|
|
# Protocol-specific repo overrides, if they differ from the values set in the git submodule config
|
|
|
|
# (e.g. because public vs private names differ for whatever reason)
|
|
|
|
my %PROTOCOL_REPOS = (
|
|
|
|
qtquick3d => {
|
|
|
|
internal => "qt/quick3d", # instead of qt-quick3d/qt-quick3d on gitorious
|
|
|
|
ssh => "qt/quick3d",
|
|
|
|
},
|
|
|
|
);
|
2011-05-05 14:37:24 +00:00
|
|
|
|
2011-07-07 00:49:23 +00:00
|
|
|
my $GERRIT_SSH_BASE
|
2011-11-09 14:59:24 +00:00
|
|
|
= 'ssh://@USER@codereview.qt-project.org@PORT@/';
|
2011-06-01 18:16:09 +00:00
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
my $BNE_MIRROR_URL_BASE
|
2011-07-14 09:13:54 +00:00
|
|
|
= 'git://bq-git.apac.nokia.com/qtsoftware/';
|
2011-05-05 14:37:24 +00:00
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
my $BNE_MIRROR_WEBKIT_URL
|
|
|
|
= 'git://bq-git.apac.nokia.com/qtsoftware/research/gitorious-org-webkit-qtwebkit-mirror.git';
|
2011-05-05 14:37:24 +00:00
|
|
|
|
2011-07-11 04:40:35 +00:00
|
|
|
my $BNE_MIRROR_V8_URL
|
|
|
|
= 'git://bq-git.apac.nokia.com/github/v8.git';
|
|
|
|
|
2011-06-21 06:37:30 +00:00
|
|
|
my $BER_MIRROR_URL_BASE
|
2011-07-14 09:13:54 +00:00
|
|
|
= 'git://ber-git.europe.nokia.com/';
|
2011-06-21 06:37:30 +00:00
|
|
|
|
|
|
|
my $BER_MIRROR_WEBKIT_URL
|
|
|
|
= 'git://ber-git.europe.nokia.com/qtwebkit/qtwebkit.git';
|
|
|
|
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
sub new
|
2011-04-27 10:34:00 +00:00
|
|
|
{
|
2011-05-06 00:52:54 +00:00
|
|
|
my ($class, @arguments) = @_;
|
|
|
|
|
|
|
|
my $self = {};
|
|
|
|
bless $self, $class;
|
|
|
|
$self->parse_arguments(@arguments);
|
|
|
|
|
|
|
|
return $self;
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
# Like `system', but possibly log the command, and die on non-zero exit code
|
|
|
|
sub exe
|
2011-04-27 10:34:00 +00:00
|
|
|
{
|
2011-05-06 00:52:54 +00:00
|
|
|
my ($self, @cmd) = @_;
|
|
|
|
|
|
|
|
if (!$self->{quiet}) {
|
|
|
|
print "+ @cmd\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (system(@cmd) != 0) {
|
|
|
|
confess "@cmd exited with status $CHILD_ERROR";
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
sub parse_arguments
|
|
|
|
{
|
|
|
|
my ($self, @args) = @_;
|
|
|
|
|
|
|
|
%{$self} = (%{$self},
|
|
|
|
'alternates' => "",
|
2011-06-01 18:16:09 +00:00
|
|
|
'codereview-username' => "",
|
2011-05-06 00:52:54 +00:00
|
|
|
'detach-alternates' => 0 ,
|
|
|
|
'force' => 0 ,
|
|
|
|
'ignore-submodules' => 0 ,
|
|
|
|
'mirror-url' => "",
|
|
|
|
'mirror-webkit-url' => "",
|
2011-07-11 04:40:35 +00:00
|
|
|
'mirror-v8-url' => "",
|
2011-05-06 00:52:54 +00:00
|
|
|
'nokia-developer' => 0 ,
|
|
|
|
'protocol' => "",
|
|
|
|
'update' => 1 ,
|
|
|
|
'webkit' => 1 ,
|
2011-07-06 07:53:58 +00:00
|
|
|
'module-subset' => "",
|
2011-05-06 00:52:54 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
GetOptionsFromArray(\@args,
|
|
|
|
'alternates=s' => \$self->{qw{ alternates }},
|
2011-06-01 18:16:09 +00:00
|
|
|
'codereview-username=s' => \$self->{qw{ codereview-username }},
|
2011-05-06 00:52:54 +00:00
|
|
|
'copy-objects' => \$self->{qw{ detach-alternates }},
|
|
|
|
'force' => \$self->{qw{ force }},
|
2011-05-19 16:22:25 +00:00
|
|
|
'ignore-submodules' => \$self->{qw{ ignore-submodules }},
|
2011-05-06 00:52:54 +00:00
|
|
|
'mirror-webkit=s' => \$self->{qw{ mirror-webkit-url }},
|
2011-12-13 20:47:28 +00:00
|
|
|
'mirror-v8=s' => \$self->{qw{ mirror-v8-url }},
|
2011-05-06 00:52:54 +00:00
|
|
|
'mirror=s' => \$self->{qw{ mirror-url }},
|
|
|
|
'nokia-developer' => \$self->{qw{ nokia-developer }},
|
|
|
|
'quiet' => \$self->{qw{ quiet }},
|
|
|
|
'update!' => \$self->{qw{ update }},
|
|
|
|
'webkit!' => \$self->{qw{ webkit }},
|
2011-07-06 07:53:58 +00:00
|
|
|
'module-subset=s' => \$self->{qw{ module-subset }},
|
2011-05-06 00:52:54 +00:00
|
|
|
|
2011-05-10 22:48:55 +00:00
|
|
|
'help|?' => sub { pod2usage(1); },
|
2011-05-06 00:52:54 +00:00
|
|
|
'http' => sub { $self->{protocol} = 'http'; },
|
|
|
|
'ssh|ssh-protocol' => sub { $self->{protocol} = 'ssh'; },
|
|
|
|
|
|
|
|
'brisbane|brisbane-nokia-developer' => sub {
|
|
|
|
$self->{'nokia-developer'} = 1;
|
|
|
|
$self->{'protocol'} = 'internal';
|
|
|
|
$self->{'mirror-url'} = $BNE_MIRROR_URL_BASE;
|
2011-07-11 04:40:35 +00:00
|
|
|
$self->{'mirror-v8-url'} = $BNE_MIRROR_V8_URL;
|
2011-05-06 00:52:54 +00:00
|
|
|
$self->{'mirror-webkit-url'} = $BNE_MIRROR_WEBKIT_URL;
|
2011-06-01 15:52:29 +00:00
|
|
|
$self->{'ignore-submodules'} = 1;
|
2011-05-06 00:52:54 +00:00
|
|
|
},
|
|
|
|
|
2011-06-21 06:37:30 +00:00
|
|
|
'berlin|berlin-nokia-developer' => sub {
|
|
|
|
$self->{'nokia-developer'} = 1;
|
|
|
|
$self->{'protocol'} = 'internal';
|
|
|
|
$self->{'mirror-url'} = $BER_MIRROR_URL_BASE;
|
|
|
|
$self->{'mirror-webkit-url'} = $BER_MIRROR_WEBKIT_URL;
|
|
|
|
},
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
'nokia-developer' => sub {
|
|
|
|
$self->{'nokia-developer'} = 1;
|
|
|
|
$self->{'protocol'} = 'internal';
|
2011-06-01 15:52:29 +00:00
|
|
|
$self->{'ignore-submodules'} = 1;
|
2011-05-06 00:52:54 +00:00
|
|
|
},
|
|
|
|
) || pod2usage(2);
|
|
|
|
|
|
|
|
if ($self->{'nokia-developer'} && $self->{'protocol'} eq 'http') {
|
|
|
|
print "*** Ignoring use of HTTP protocol, as it's only usable with external server\n";
|
|
|
|
$self->{'protocol'} = '';
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
# Replace any double trailing slashes from end of mirror
|
|
|
|
$self->{'mirror-url'} =~ s{//+$}{/};
|
|
|
|
|
2011-07-06 07:53:58 +00:00
|
|
|
if ($self->{'module-subset'}) {
|
|
|
|
$self->{'module-subset'} = {
|
|
|
|
map { $_ => 1 } split(qr{,}, $self->{'module-subset'})
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
return;
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
sub check_if_already_initialized
|
|
|
|
{
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
# We consider the repo as `initialized' if submodule.qtbase.url is set
|
|
|
|
if (qx(git config --get submodule.qtbase.url)) {
|
|
|
|
if ($self->{force}) {
|
|
|
|
my @configresult = qx(git config -l);
|
|
|
|
foreach (@configresult) {
|
|
|
|
# Example line: submodule.qtqa.url=git://gitorious.org/qt/qtqa.git
|
|
|
|
if (/(submodule\.[^.=]+)\.url=.*/) {
|
|
|
|
$self->exe('git', 'config', '--remove-section', $1);
|
|
|
|
}
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-06 00:52:54 +00:00
|
|
|
else {
|
|
|
|
exit 0 if ($self->{quiet});
|
|
|
|
print "Will not reinitialize already initialized repository (use -f to force)!\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub git_submodule_init
|
|
|
|
{
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
my @init_args;
|
|
|
|
if ($self->{quiet}) {
|
|
|
|
push @init_args, '--quiet';
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
2011-05-06 00:52:54 +00:00
|
|
|
$self->exe('git', 'submodule', 'init', @init_args);
|
|
|
|
|
2011-05-11 05:24:41 +00:00
|
|
|
my $template = getcwd()."/.commit-template";
|
|
|
|
if (-e $template) {
|
|
|
|
$self->exe('git', 'config', 'commit.template', $template);
|
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
return;
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
sub git_disable_webkit_submodule
|
|
|
|
{
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
$self->exe('git', 'config', '--remove', 'submodule.qtwebkit');
|
|
|
|
$self->exe('git', 'config', '--remove', 'submodule.qtwebkit-examples-and-demos');
|
|
|
|
|
|
|
|
return;
|
2011-04-28 01:46:22 +00:00
|
|
|
}
|
2011-04-27 10:34:00 +00:00
|
|
|
|
2011-07-06 07:53:58 +00:00
|
|
|
sub git_prune_submodules
|
|
|
|
{
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
my @configresult = qx(git config -l);
|
|
|
|
foreach my $line (@configresult) {
|
|
|
|
if ($line =~ /submodule\.([^.=]+)\.url=/) {
|
|
|
|
my $module_name = $1;
|
|
|
|
if (!$self->{'module-subset'}{$module_name}) {
|
|
|
|
$self->exe('git', 'config', '--remove', "submodule.$module_name");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
sub git_set_submodule_config
|
|
|
|
{
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
my @configresult = qx(git config -l);
|
|
|
|
my $protocol = $self->{protocol};
|
|
|
|
my $url_base_for_protocol = $PROTOCOLS{$protocol};
|
|
|
|
|
|
|
|
foreach my $line (@configresult) {
|
|
|
|
# Example line: submodule.qtqa.url=git://gitorious.org/qt/qtqa.git
|
2011-07-14 09:13:54 +00:00
|
|
|
next if ($line !~ /submodule\.([^.=]+)\.url=(.*)/);
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
my $key = $1;
|
2011-05-03 09:08:50 +00:00
|
|
|
my $value = $2;
|
2011-05-06 00:52:54 +00:00
|
|
|
|
2011-05-04 17:49:18 +00:00
|
|
|
if ($protocol) {
|
2011-04-26 16:03:52 +00:00
|
|
|
# WebKit is special, and has only external link.
|
2011-12-09 01:59:06 +00:00
|
|
|
if ($key ne 'qtwebkit' and $key ne 'qt3d') {
|
2011-04-26 16:00:16 +00:00
|
|
|
# qt-labs projects are still hosted under qt internally.
|
2011-05-06 00:52:54 +00:00
|
|
|
if ($protocol ne 'http') {
|
|
|
|
$value =~ s,^git://gitorious\.org/qt-labs/,${url_base_for_protocol}qt/,;
|
|
|
|
}
|
2011-07-14 09:13:54 +00:00
|
|
|
|
|
|
|
if ($PROTOCOL_REPOS{$key}->{$protocol}) {
|
|
|
|
# If this repo has an explicitly set basename for this protocol, use it...
|
|
|
|
# e.g. 'git@example.com:' . 'qt/quick3d'
|
|
|
|
$value = $url_base_for_protocol . $PROTOCOL_REPOS{$key}->{$protocol};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# ...otherwise, assume the selected protocol uses same naming structure
|
|
|
|
# as gitorious.org
|
|
|
|
# e.g. git://gitorious.org/qt/qt5 => git@example.com:qt/qt5
|
|
|
|
$value =~ s,^git://gitorious\.org/,$url_base_for_protocol,;
|
|
|
|
}
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-06 00:52:54 +00:00
|
|
|
|
2011-07-14 09:13:54 +00:00
|
|
|
$self->exe('git', 'config', "submodule.$key.url", $value);
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
if ($self->{'ignore-submodules'}) {
|
2011-07-14 09:13:54 +00:00
|
|
|
$self->exe('git', 'config', "submodule.$key.ignore", 'all');
|
2011-05-04 17:45:05 +00:00
|
|
|
}
|
2011-04-27 10:34:00 +00:00
|
|
|
}
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
return;
|
2011-05-03 09:08:50 +00:00
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
sub git_clone_all_submodules
|
|
|
|
{
|
|
|
|
my ($self) = @_;
|
2011-05-05 14:37:24 +00:00
|
|
|
|
2011-07-07 00:49:23 +00:00
|
|
|
# manually clone each repo here, so we can easily use reference repos, mirrors etc
|
2011-05-06 00:52:54 +00:00
|
|
|
my @configresult = qx(git config -l);
|
|
|
|
foreach my $line (@configresult) {
|
|
|
|
if ($line =~ /submodule\.([^.=]+)\.url=(.*)/) {
|
|
|
|
$self->git_clone_one_submodule($1, $2);
|
|
|
|
}
|
|
|
|
}
|
2011-05-05 14:37:24 +00:00
|
|
|
|
2011-11-11 02:15:17 +00:00
|
|
|
$self->exe('git', 'submodule', 'update', '--recursive');
|
2011-05-05 14:37:24 +00:00
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-05-05 14:37:24 +00:00
|
|
|
|
2011-06-01 18:16:09 +00:00
|
|
|
sub git_add_remotes
|
2011-05-06 05:42:10 +00:00
|
|
|
{
|
|
|
|
my ($self, $repo_basename) = @_;
|
|
|
|
|
2011-07-07 00:49:23 +00:00
|
|
|
my $gerrit_repo_basename = $GERRIT_REPOS{$repo_basename};
|
2011-11-09 16:38:49 +00:00
|
|
|
if ($gerrit_repo_basename) {
|
2011-07-07 00:49:23 +00:00
|
|
|
my $gerrit_repo_url;
|
2011-05-06 05:42:10 +00:00
|
|
|
|
2011-11-09 14:59:24 +00:00
|
|
|
# If given a username, make a "verbose" remote.
|
|
|
|
# Otherwise, rely on proper SSH configuration.
|
2011-07-07 00:49:23 +00:00
|
|
|
if ($self->{'codereview-username'}) {
|
|
|
|
$gerrit_repo_url = $GERRIT_SSH_BASE;
|
2011-11-09 14:59:24 +00:00
|
|
|
$gerrit_repo_url =~ s,\@USER\@,$self->{'codereview-username'}\@,;
|
|
|
|
$gerrit_repo_url =~ s,\@PORT\@,:29418,;
|
2011-06-01 18:16:09 +00:00
|
|
|
}
|
2011-07-07 00:49:23 +00:00
|
|
|
else {
|
2011-11-09 14:59:24 +00:00
|
|
|
$gerrit_repo_url = $GERRIT_SSH_BASE;
|
|
|
|
$gerrit_repo_url =~ s,\@[^\@]+\@,,g;
|
2011-06-01 18:16:09 +00:00
|
|
|
}
|
2011-07-07 00:49:23 +00:00
|
|
|
|
|
|
|
$gerrit_repo_url .= $gerrit_repo_basename;
|
2011-11-09 16:38:49 +00:00
|
|
|
$self->exe('git', 'config', 'remote.gerrit.url', $gerrit_repo_url);
|
|
|
|
$self->exe('git', 'config', 'remote.gerrit.fetch', '+refs/heads/*:refs/remotes/gerrit/*');
|
2011-06-01 18:16:09 +00:00
|
|
|
}
|
|
|
|
|
2011-05-06 05:42:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
sub git_clone_one_submodule
|
|
|
|
{
|
|
|
|
my ($self, $submodule, $url) = @_;
|
2011-05-05 14:37:24 +00:00
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
my $alternates = $self->{ 'alternates' };
|
|
|
|
my $mirror_url = $self->{ 'mirror-url' };
|
|
|
|
my $mirror_webkit_url = $self->{ 'mirror-webkit-url' };
|
2011-07-11 04:40:35 +00:00
|
|
|
my $mirror_v8_url = $self->{ 'mirror-v8-url' };
|
2011-08-11 00:30:41 +00:00
|
|
|
my $protocol = $self->{ 'protocol' };
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
# `--reference FOO' args for the clone, if any.
|
|
|
|
my @reference_args;
|
|
|
|
|
|
|
|
if ($alternates) {
|
|
|
|
# alternates is a qt5 repo, so the submodule will be under that.
|
|
|
|
if (-d "$alternates/$submodule") {
|
|
|
|
@reference_args = ('--reference', "$alternates/$submodule");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print " *** $alternates/$submodule not found, ignoring alternate for this submodule\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $mirror;
|
|
|
|
if ($mirror_url && ($submodule ne 'qtwebkit')) {
|
2011-07-14 09:13:54 +00:00
|
|
|
$mirror = $mirror_url.( $PROTOCOL_REPOS{$submodule}->{internal} // "qt/$submodule" );
|
2011-05-06 00:52:54 +00:00
|
|
|
$mirror .= ".git" unless (-d $mirror); # Support local disk mirror
|
|
|
|
}
|
|
|
|
elsif ($mirror_webkit_url && ($submodule eq 'qtwebkit')) {
|
|
|
|
$mirror = $mirror_webkit_url;
|
|
|
|
}
|
2011-12-09 01:59:06 +00:00
|
|
|
if ($mirror && ($submodule eq 'qt3d')) {
|
|
|
|
$mirror =~ s/qtsoftware/gitorious/ ;
|
|
|
|
}
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
my $do_clone = (! -d "$submodule/.git");
|
|
|
|
if ($do_clone) {
|
|
|
|
$self->exe('git', 'clone', @reference_args, ($mirror ? $mirror : $url), $submodule);
|
|
|
|
}
|
|
|
|
|
|
|
|
chdir($submodule) or confess "chdir $submodule: $OS_ERROR";
|
|
|
|
|
2011-11-09 16:38:49 +00:00
|
|
|
$self->exe('git', 'config', 'remote.origin.url', $url);
|
|
|
|
if ($mirror) {
|
|
|
|
$self->exe('git', 'config', 'remote.mirror.url', $mirror);
|
|
|
|
$self->exe('git', 'config', 'remote.mirror.fetch', '+refs/heads/*:refs/remotes/mirror/*');
|
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
if (!$do_clone) {
|
|
|
|
$self->exe('git', 'fetch', ($mirror ? $mirror : $url));
|
|
|
|
}
|
|
|
|
|
2011-05-11 05:24:41 +00:00
|
|
|
my $template = getcwd()."/../.commit-template";
|
|
|
|
if (-e $template) {
|
|
|
|
$self->exe('git', 'config', 'commit.template', $template);
|
|
|
|
}
|
|
|
|
|
2011-10-26 13:11:16 +00:00
|
|
|
$self->git_add_remotes($submodule);
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
if ($self->{'detach-alternates'}) {
|
|
|
|
$self->exe('git', 'repack', '-a');
|
|
|
|
|
|
|
|
my $alternates_path = '.git/objects/info/alternates';
|
|
|
|
unlink($alternates_path) || confess "unlink $alternates_path: $OS_ERROR";
|
2011-04-28 06:02:39 +00:00
|
|
|
}
|
2011-05-06 00:52:54 +00:00
|
|
|
|
2011-08-22 09:51:22 +00:00
|
|
|
if ($submodule eq "qtbase" || $submodule eq "qtdeclarative") { #Extra steps needed to setup base and declarative
|
2011-06-21 06:54:22 +00:00
|
|
|
$self->exe('git', 'submodule', 'init');
|
2011-08-11 00:30:41 +00:00
|
|
|
if ($mirror_v8_url || $protocol eq 'http') {
|
2011-07-11 04:40:35 +00:00
|
|
|
my @configresult = qx(git config -l);
|
|
|
|
my $v8url;
|
|
|
|
foreach my $line (@configresult) {
|
|
|
|
# Example line: submodule.qtqa.url=git://gitorious.org/qt/qtqa.git
|
|
|
|
next if ($line !~ /submodule.src\/3rdparty\/v8.url=(.*)/);
|
|
|
|
$v8url = $1;
|
|
|
|
}
|
2011-08-11 00:30:41 +00:00
|
|
|
|
2011-08-22 09:51:22 +00:00
|
|
|
if ($v8url) {
|
|
|
|
if ($protocol eq 'http') {
|
|
|
|
# rewrite the git:// url to https://
|
|
|
|
if ($v8url =~ s{^git://github}{https://github}) {
|
|
|
|
$self->exe('git', 'config', 'submodule.src/3rdparty/v8.url', $v8url);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
warn 'You requested git over http, but I could not figure out how to '
|
|
|
|
."rewrite v8's giturl of $v8url";
|
|
|
|
}
|
2011-08-11 00:30:41 +00:00
|
|
|
}
|
|
|
|
|
2011-08-22 09:51:22 +00:00
|
|
|
if ($mirror_v8_url && $do_clone) {
|
|
|
|
chdir('src/3rdparty/') or confess "chdir $submodule/src/3rdparty: $OS_ERROR";
|
|
|
|
$self->exe('git', 'clone', $mirror_v8_url, 'v8');
|
|
|
|
chdir('v8') or confess "chdir $submodule/src/3rdparty/v8: $OS_ERROR";
|
|
|
|
$self->exe('git', 'config', 'remote.origin.url', $v8url);
|
|
|
|
chdir('../../..') or confess "cd ../../..: $OS_ERROR";
|
|
|
|
}
|
2011-08-11 00:30:41 +00:00
|
|
|
}
|
2011-07-11 04:40:35 +00:00
|
|
|
}
|
2011-06-21 06:54:22 +00:00
|
|
|
$self->exe('git', 'submodule', 'update');
|
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
chdir("..") or confess "cd ..: $OS_ERROR";
|
|
|
|
|
|
|
|
return;
|
2011-04-28 11:25:41 +00:00
|
|
|
}
|
2011-05-06 00:52:54 +00:00
|
|
|
|
|
|
|
sub run
|
|
|
|
{
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
$self->check_if_already_initialized;
|
|
|
|
$self->git_submodule_init;
|
|
|
|
|
|
|
|
if (!$self->{webkit}) {
|
|
|
|
$self->git_disable_webkit_submodule;
|
|
|
|
}
|
|
|
|
|
2011-07-06 07:53:58 +00:00
|
|
|
if ($self->{'module-subset'}) {
|
|
|
|
$self->git_prune_submodules;
|
|
|
|
}
|
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
$self->git_set_submodule_config;
|
|
|
|
|
|
|
|
if ($self->{update}) {
|
|
|
|
$self->git_clone_all_submodules;
|
|
|
|
}
|
|
|
|
|
2011-10-26 13:11:16 +00:00
|
|
|
$self->git_add_remotes('qt5');
|
2011-05-06 05:42:10 +00:00
|
|
|
|
2011-05-06 00:52:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#==============================================================================
|
|
|
|
|
|
|
|
Qt::InitRepository->new(@ARGV)->run if (!caller);
|
|
|
|
1;
|