2 #############################################################################
4 ## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ## All rights reserved.
6 ## Contact: Nokia Corporation (qt-info@nokia.com)
8 ## This file is part of the utilities of the Qt Toolkit.
10 ## $QT_BEGIN_LICENSE:LGPL$
11 ## No Commercial Usage
12 ## This file contains pre-release code and may not be distributed.
13 ## You may use this file in accordance with the terms and conditions
14 ## contained in the Technology Preview License Agreement accompanying
17 ## GNU Lesser General Public License Usage
18 ## Alternatively, this file may be used under the terms of the GNU Lesser
19 ## General Public License version 2.1 as published by the Free Software
20 ## Foundation and appearing in the file LICENSE.LGPL included in the
21 ## packaging of this file. Please review the following information to
22 ## ensure the GNU Lesser General Public License version 2.1 requirements
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ## In addition, as a special exception, Nokia gives you certain additional
26 ## rights. These rights are described in the Nokia Qt LGPL Exception
27 ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ## If you have questions regarding the use of this file, please contact
30 ## Nokia at qt-info@nokia.com.
41 #############################################################################
48 my $nokia_developer = 0;
49 my $brisbane_mirror = 0;
52 my $ignore_submodules = 0;
56 'internal' => 'git://scm.dev.nokia.troll.no',
57 'ssh' => 'git@scm.dev.nokia.troll.no',
58 'http' => 'http://git.gitorious.org'
73 print("$0 <options>\n");
74 print(" -f Force initialization.\n");
75 print(" -q Quiet operation. Will exit cleanly if repository is already\n");
76 print(" initialized.\n\n");
78 print("Module options\n");
79 print(" -no-webkit Skip webkit and webkit examples submodules.\n");
80 print(" -no-update Skip the 'git submodule update' command.\n");
81 print(" -ignore-submodules\n");
82 print(" Ignores submodules when doing operations on qt5 repo, such\n");
83 print(" as 'pull', 'fetch', 'diff' etc. Use\n");
84 print(" --ignore-submodules=none to override, when needed\n\n");
86 print("Repository options:\n");
87 print(" -nokia-developer Switch to internal Nokia URLs.\n");
88 print(" -brisbane Switch to internal Nokia URLs, and setup the brisbane\n");
90 print(" -ssh Use SSH protocol, for restrictive firewalls. Note that this\n");
91 print(" requires a user account with an uploaded SSH key on all\n");
92 print(" servers used. (Implies -nokia-developer!)\n");
93 print(" -http Use HTTP protocol, for restrictive firewalls. Note that this\n");
94 print(" only works with the external Gitorious server.\n");
101 } elsif ($arg eq "-q") {
103 } elsif ($arg eq "-brisbane" || $arg eq "-brisbane-nokia-developer") {
104 $nokia_developer = 1;
105 $brisbane_mirror = 1;
106 } elsif ($arg eq "-nokia-developer") {
107 $nokia_developer = 1;
108 $protocol = "internal";
109 } elsif ($arg eq "-ssh" || $arg eq "-ssh-protocol") {
111 } elsif ($arg eq "-http") {
112 if ($nokia_developer || $brisbane_mirror) {
113 print("*** Ignoring use of HTTP protocol, as it's only usable with external server\n");
117 } elsif ($arg eq "/?" || $arg eq "-?" || $arg eq "/h" || $arg eq "-h" || $arg eq "--help") {
120 } elsif ($arg eq "-no-webkit") {
122 } elsif ($arg eq "-no-update") {
124 } elsif ($arg eq "-ignore-submodules") {
125 $ignore_submodules = 1;
127 print("*** Unknown option: $arg\n");
134 if (`git config --get submodule.qtbase.url`) {
136 my @configresult = `git config -l`;
137 foreach (@configresult) {
138 if (/(submodule\.[^.=]+)\.url=.*/) {
139 system_v("git config --remove-section $1");
144 print("Will not reinitialize already initialized repository (use -f to force)!\n");
150 $init_args = "-q" if ($quiet);
151 system_v("git submodule init $init_args");
153 system_v("git config --remove submodule.qtwebkit");
154 system_v("git config --remove submodule.qtwebkit-examples-and-demos");
157 my @configresult = `git config -l`;
158 my $proto = $protocols{$protocol};
159 foreach (@configresult) {
160 if (/(submodule\.[^.=]+\.url)=(.*)/) {
164 # WebKit is special, and has only external link.
165 if ($key ne "submodule.qtwebkit.url") {
166 # qt-labs projects are still hosted under qt internally.
167 $value =~ s,^git://gitorious\.org/qt-labs/,$proto/qt/, if ($protocol ne "http") ;
168 $value =~ s,^git://gitorious\.org/,$proto/,;
171 system_v("git config \"$key\" \"$value\"");
172 if ($ignore_submodules) {
173 $key =~ s,\.url,.ignore,;
174 system_v("git config \"$key\" \"all\"");
179 if ($nokia_developer) {
180 if ($brisbane_mirror) {
181 my $mirror_url = "git://bq-git.apac.nokia.com/qtsoftware/qt/";
182 my %exceptions = ("qtwebkit", "git://bq-git.apac.nokia.com/qtsoftware/research/gitorious-org-webkit-qtwebkit-mirror.git");
183 my @configresult2 = `git config -l`;
184 foreach (@configresult2) {
185 if(/submodule\.([^.=]+)\.url=(.*)/){
189 no warnings 'uninitialized';
190 if($exceptions{$repo} ne undef){
191 $this_mirror_url = $exceptions{$repo};
193 $this_mirror_url = "$mirror_url$repo.git";
195 print("Using mirror $this_mirror_url to clone $url\n");
196 unless ($no_update) {
197 system_v("git clone $this_mirror_url $repo");
198 chdir($repo) or die "cd failed";
199 system_v("git config remote.origin.url $url");
200 system_v("git remote add mirror $this_mirror_url");
201 chdir("..") or die "cd fail";
209 system_v("git submodule update");