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;
51 my $ignore_submodules = 0;
53 my $detach_alternates = 0;
55 my $mirror_webkit_url = "";
59 'internal' => 'git://scm.dev.nokia.troll.no/',
60 'ssh' => 'git@scm.dev.nokia.troll.no:',
61 'http' => 'http://git.gitorious.org/'
65 'qt3support-staging' => 'git://gitorious.org/qt/qt3support-staging.git',
66 'qtactiveqt-staging' => 'git://gitorious.org/qt/qtactiveqt-staging.git',
67 'qtbase-earth-staging' => 'git://gitorious.org/qt/qtbase-earth-staging.git',
68 'qtbase-staging' => 'git://gitorious.org/qt/qtbase-staging.git',
69 'qtdeclarative-staging' => 'git://gitorious.org/qt/qtdeclarative-staging.git',
70 'qtdoc-staging' => 'git://gitorious.org/qt/qtdoc-staging.git',
71 'qtmultimedia-staging' => 'git://gitorious.org/qt/qtmultimedia-staging.git',
72 'qtphonon-staging' => 'git://gitorious.org/qt/qtphonon-staging.git',
73 'qtqa-staging' => 'git://gitorious.org/qt/qtqa-staging.git',
74 'qtscript-staging' => 'git://gitorious.org/qt/qtscript-staging.git',
75 'qtsvg-staging' => 'git://gitorious.org/qt/qtsvg-staging.git',
76 'qttools-staging' => 'git://gitorious.org/qt/qttools-staging.git',
77 'qttranslations-staging' => 'git://gitorious.org/qt/qttranslations-staging.git',
78 'qtwebkit-examples-and-demos-staging' => 'git://gitorious.org/qt/qtwebkit-examples-and-demos-staging.git',
79 'qtxmlpatterns-staging' => 'git://gitorious.org/qt/qtxmlpatterns-staging.git',
98 -f Force initialization.
99 -q Quiet operation. Will exit cleanly if repository is already
103 -no-webkit Skip webkit and webkit examples submodules.
104 -no-update Skip the 'git submodule update' command.
106 Ignores submodules when doing operations on qt5 repo, such
107 as 'pull', 'fetch', 'diff' etc. Use
108 --ignore-submodules=none to override, when needed
111 -nokia-developer Switch to internal Nokia URLs.
112 -brisbane Switch to internal Nokia URLs, and setup the brisbane
113 mirrors. (Uses the -mirror and -mirror-webkit options.)
114 -ssh Use SSH protocol, for restrictive firewalls. Note that this
115 requires a user account with an uploaded SSH key on all
116 servers used. (Implies -nokia-developer!)
117 -http Use HTTP protocol, for restrictive firewalls. Note that this
118 only works with the external Gitorious server.
119 -alternates=<path to other Qt5 repo>
120 Adds alternates for each submodule to another full qt5
121 checkout. This makes this qt5 checkout very small, as it
122 will use the object store of the alternates before unique
123 objects are stored in its own object store.
124 PS: This option does not work with -no-update!
125 PSS:This will make this repo dependent on the alternate!
126 The dependency can be broken by running 'git repack -a'
127 in each submodule, where required.
128 -copy-objects Copies all objects from the alternates into the individual
129 repos, to ensure that the repositories are independent from
130 the source used as a reference for cloning.
131 -mirror=<url> Uses <url> as the base URL for cloning submodules.
132 -mirror=user\@machine/foo/bar
133 while for example clone qtbase from
134 user\@machine/foo/bar/qtbase.git
136 Uses <url> as the URL for cloning webkit.
144 } elsif ($arg eq "-q") {
146 } elsif ($arg eq "-brisbane" || $arg eq "-brisbane-nokia-developer") {
147 $nokia_developer = 1;
148 $protocol = "internal";
149 $mirror_url = "git://bq-git.apac.nokia.com/qtsoftware/qt/";
150 $mirror_webkit_url = "git://bq-git.apac.nokia.com/qtsoftware/research/gitorious-org-webkit-qtwebkit-mirror.git";
151 } elsif ($arg eq "-nokia-developer") {
152 $nokia_developer = 1;
153 $protocol = "internal";
154 } elsif ($arg eq "-ssh" || $arg eq "-ssh-protocol") {
156 } elsif ($arg eq "-http") {
157 if ($nokia_developer) {
158 print("*** Ignoring use of HTTP protocol, as it's only usable with external server\n");
162 } elsif ($arg eq "/?" || $arg eq "-?" || $arg eq "/h" || $arg eq "-h" || $arg eq "--help") {
165 } elsif ($arg eq "-no-webkit") {
167 } elsif ($arg eq "-no-update") {
169 } elsif ($arg eq "-ignore-submodules") {
170 $ignore_submodules = 1;
171 } elsif ($arg =~ /-alternates=(.*)/) {
173 } elsif ($arg eq "-copy-objects") {
174 $detach_alternates = 1;
175 } elsif ($arg =~ /-mirror=(.*)/) {
177 $mirror_url =~ s,\/\/+$,/,;
178 } elsif ($arg =~ /-mirror-webkit=(.*)/) {
179 $mirror_webkit_url = "$1"
181 print("*** Unknown option: $arg\n");
188 if (`git config --get submodule.qtbase.url`) {
190 my @configresult = `git config -l`;
191 foreach (@configresult) {
192 if (/(submodule\.[^.=]+)\.url=.*/) {
193 system_v("git config --remove-section $1");
198 print("Will not reinitialize already initialized repository (use -f to force)!\n");
204 $init_args = "-q" if ($quiet);
205 system_v("git submodule init $init_args");
207 system_v("git config --remove submodule.qtwebkit");
208 system_v("git config --remove submodule.qtwebkit-examples-and-demos");
211 my @configresult = `git config -l`;
212 my $proto = $protocols{$protocol};
213 foreach (@configresult) {
214 if (/(submodule\.[^.=]+\.url)=(.*)/) {
218 # WebKit is special, and has only external link.
219 if ($key ne "submodule.qtwebkit.url") {
220 # qt-labs projects are still hosted under qt internally.
221 $value =~ s,^git://gitorious\.org/qt-labs/,${proto}qt/, if ($protocol ne "http") ;
222 $value =~ s,^git://gitorious\.org/,$proto,;
225 system_v("git config \"$key\" \"$value\"");
226 if ($ignore_submodules) {
227 $key =~ s,\.url,.ignore,;
228 system_v("git config \"$key\" \"all\"");
233 # manually clone each repo here, so we can easily use reference repos, mirrors and add all staging
236 @configresult = `git config -l`;
237 foreach (@configresult) {
238 if(/submodule\.([^.=]+)\.url=(.*)/){
243 if (-d "$alternates/$repo") {
244 $ref = "--reference $alternates/$repo";
246 print(" *** $alternates/$repo not found, ignoring alternate for this submodule\n");
251 if ($mirror_url && ($repo ne "qtwebkit")) {
252 my $mirror = $mirror_url.$repo;
253 $mirror .= ".git" unless (-d $mirror); # Support local disk mirror
254 } elsif ($mirror_webkit_url && ($repo eq "qtwebkit")) {
255 $mirror = $mirror_webkit_url;
258 my $do_clone = (! -d "$repo/.git");
259 system_v("git clone $ref " . ($mirror ? $mirror : $url) . " $repo") if ($do_clone);
260 chdir($repo) or die "'cd $repo' failed...";
261 system_v("git fetch " . ($mirror ? $mirror : $url)) if (!$do_clone);
264 system_v("git config remote.origin.url $url");
265 system_v("git remote add mirror $mirror");
268 # add missing staging repos as remotes
269 my @staging = grep(/^$repo/, keys %staging_repos);
270 my @current_remotes = `git remote show`;
271 chomp @current_remotes;
272 my %diff = map { $_ => 1 } @current_remotes;
273 my @add_staging = grep !$diff{"$_"}, @staging;
274 foreach (@add_staging) {
275 my $staging_repo = $_;
276 my $staging_repo_url = $staging_repos{$_};
278 $staging_repo_url =~ s,^git://gitorious\.org/qt-labs/,${proto}qt/, if ($protocol ne "http") ;
279 $staging_repo_url =~ s,^git://gitorious\.org/,$proto,;
281 system_v("git remote add $staging_repo $staging_repo_url");
284 if ($detach_alternates) {
285 system_v("git repack -a");
286 unlink(".git/objects/info/alternates");
288 chdir("..") or die "'cd ..' failed..";
291 system_v("git submodule update");