summaryrefslogtreecommitdiffstats
path: root/init-repository
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-08-15 21:24:21 +0200
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-09-23 20:28:59 +0200
commit4553d9ec11308b5de5cfda5dc2deef1d68b09ff1 (patch)
tree38eba3d3482454c9d89a02d3e1922d0ed0a0ab80 /init-repository
parent3ade7c4567eb00375a3670eb92a41ba979d5322c (diff)
get submodule urls from .gitmodules
keeping a redundant copy in the script is plain backwards. Change-Id: Ibdd1bab9d2cb5af7d7747d5caa2afc7d6e7571ad Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'init-repository')
-rwxr-xr-xinit-repository117
1 files changed, 42 insertions, 75 deletions
diff --git a/init-repository b/init-repository
index c38aff2e..45567c3c 100755
--- a/init-repository
+++ b/init-repository
@@ -191,47 +191,6 @@ use Getopt::Long qw( GetOptionsFromArray );
use Pod::Usage qw( pod2usage );
use Cwd qw( getcwd );
-my %GERRIT_REPOS = map { $_ => "qt/$_" } qw(
- qt3d
- qt5
- qtactiveqt
- qtandroidextras
- qtbase
- qtconnectivity
- qtdeclarative
- qtdoc
- qtdocgallery
- qtenginio
- qtfeedback
- qtgraphicaleffects
- qtimageformats
- qtjsondb
- qtlocation
- qtmacextras
- qtmultimedia
- qtpim
- qtqa
- qtquick1
- qtquickcontrols
- qtrepotools
- qtscript
- qtsensors
- qtserialport
- qtsvg
- qtsystems
- qttools
- qttranslations
- qtwayland
- qtwebchannel
- qtwebengine
- qtwebkit
- qtwebkit-examples
- qtwebsockets
- qtwinextras
- qtx11extras
- qtxmlpatterns
-);
-
my @DEFAULT_REPOS = qw(
qtactiveqt
qtandroidextras
@@ -399,16 +358,33 @@ sub git_submodule_init
sub git_clone_all_submodules
{
- my ($self, @subset) = @_;
+ my ($self, $my_repo_base, @subset) = @_;
+
+ my %subdirs = ();
+ my %subbases = ();
+ my @submodconfig = qx(git config -l -f .gitmodules);
+ foreach my $line (@submodconfig) {
+ # Example line: submodule.qtqa.url=../qtqa.git
+ next if ($line !~ /^submodule\.([^.=]+)\.([^.=]+)=(.*)$/);
+ if ($2 eq "path") {
+ $subdirs{$1} = $3;
+ } elsif ($2 eq "url") {
+ my ($mod, $base) = ($1, $3);
+ next if ($base !~ /^\.\.\//);
+ $base = $my_repo_base.'/'.$base;
+ while ($base =~ s,/(?!\.\./)[^/]+/\.\./,/,g) {}
+ $subbases{$mod} = $base;
+ } elsif ($2 eq "update") {
+ push @subset, '-'.$1 if ($3 eq 'ignore');
+ }
+ }
my %include = ();
- my %exclude = ();
- my $include_all = 0;
foreach my $mod (@subset) {
if ($mod eq "all") {
- $include_all = 1;
+ map { $include{$_} = 1; } keys %subbases;
} elsif ($mod =~ s/^-//) {
- $exclude{$mod} = 1;
+ delete $include{$mod};
} else {
$include{$mod} = 1;
}
@@ -423,7 +399,7 @@ sub git_clone_all_submodules
next if ($line !~ /submodule\.([^.=]+)\.url=(.*)/);
my ($module, $url) = ($1, $2);
- if (defined($exclude{$module}) || (!$include_all && !defined($include{$module}))) {
+ if (!defined($include{$module})) {
$self->exe('git', 'config', '--remove-section', "submodule.$module");
next;
}
@@ -432,13 +408,13 @@ sub git_clone_all_submodules
$self->exe('git', 'config', "submodule.$module.ignore", 'all');
}
- $self->git_clone_one_submodule($module, $url);
+ $self->git_clone_one_submodule($subdirs{$module}, $subbases{$module}, $url);
if ($module eq "qtwebengine") {
$self->exe('git', 'submodule', 'update', $module);
my $orig_cwd = getcwd();
chdir($module) or confess "chdir $module: $OS_ERROR";
$self->exe('git', 'submodule', 'init');
- $self->git_clone_all_submodules("all");
+ $self->git_clone_all_submodules($subbases{$module}, "all");
chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR";
}
}
@@ -452,35 +428,26 @@ sub git_clone_all_submodules
sub git_add_remotes
{
- my ($self, $repo_basename) = @_;
-
- my $gerrit_repo_basename = $GERRIT_REPOS{$repo_basename};
- if ($gerrit_repo_basename) {
- my $gerrit_repo_url;
-
- # If given a username, make a "verbose" remote.
- # Otherwise, rely on proper SSH configuration.
- if ($self->{'codereview-username'}) {
- $gerrit_repo_url = $GERRIT_SSH_BASE;
- $gerrit_repo_url =~ s,\@USER\@,$self->{'codereview-username'}\@,;
- $gerrit_repo_url =~ s,\@PORT\@,:29418,;
- }
- else {
- $gerrit_repo_url = $GERRIT_SSH_BASE;
- $gerrit_repo_url =~ s,\@[^\@]+\@,,g;
- }
-
- $gerrit_repo_url .= $gerrit_repo_basename;
- $self->exe('git', 'config', 'remote.gerrit.url', $gerrit_repo_url);
- $self->exe('git', 'config', 'remote.gerrit.fetch', '+refs/heads/*:refs/remotes/gerrit/*', '/heads/');
+ my ($self, $gerrit_repo_basename) = @_;
+
+ my $gerrit_repo_url = $GERRIT_SSH_BASE;
+ # If given a username, make a "verbose" remote.
+ # Otherwise, rely on proper SSH configuration.
+ if ($self->{'codereview-username'}) {
+ $gerrit_repo_url =~ s,\@USER\@,$self->{'codereview-username'}\@,;
+ $gerrit_repo_url =~ s,\@PORT\@,:29418,;
+ } else {
+ $gerrit_repo_url =~ s,\@[^\@]+\@,,g;
}
- return;
+ $gerrit_repo_url .= $gerrit_repo_basename;
+ $self->exe('git', 'config', 'remote.gerrit.url', $gerrit_repo_url);
+ $self->exe('git', 'config', 'remote.gerrit.fetch', '+refs/heads/*:refs/remotes/gerrit/*', '/heads/');
}
sub git_clone_one_submodule
{
- my ($self, $submodule, $url) = @_;
+ my ($self, $submodule, $repo_basename, $url) = @_;
my $alternates = $self->{ 'alternates' };
my $mirror_url = $self->{ 'mirror-url' };
@@ -537,7 +504,7 @@ sub git_clone_one_submodule
$self->exe('git', 'config', 'commit.template', $template);
}
- $self->git_add_remotes($submodule);
+ $self->git_add_remotes($repo_basename);
if ($self->{'detach-alternates'}) {
$self->exe('git', 'repack', '-a');
@@ -591,9 +558,9 @@ sub run
$self->check_if_already_initialized;
- $self->git_clone_all_submodules(@{$self->{'module-subset'}});
+ $self->git_clone_all_submodules('qt/qt5', @{$self->{'module-subset'}});
- $self->git_add_remotes('qt5');
+ $self->git_add_remotes('qt/qt5');
$self->git_install_hooks;