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 $mirror_url = "git://bq-git.apac.nokia.com/qtsoftware/qt/";
149 $mirror_webkit_url = "git://bq-git.apac.nokia.com/qtsoftware/research/gitorious-org-webkit-qtwebkit-mirror.git";
150 } elsif ($arg eq "-nokia-developer") {
151 $nokia_developer = 1;
152 $protocol = "internal";
153 } elsif ($arg eq "-ssh" || $arg eq "-ssh-protocol") {
155 } elsif ($arg eq "-http") {
156 if ($nokia_developer) {
157 print("*** Ignoring use of HTTP protocol, as it's only usable with external server\n");
161 } elsif ($arg eq "/?" || $arg eq "-?" || $arg eq "/h" || $arg eq "-h" || $arg eq "--help") {
164 } elsif ($arg eq "-no-webkit") {
166 } elsif ($arg eq "-no-update") {
168 } elsif ($arg eq "-ignore-submodules") {
169 $ignore_submodules = 1;
170 } elsif ($arg =~ /-alternates=(.*)/) {
172 } elsif ($arg eq "-copy-objects") {
173 $detach_alternates = 1;
174 } elsif ($arg =~ /-mirror=(.*)/) {
176 $mirror_url =~ s,\/\/+$,/,;
177 } elsif ($arg =~ /-mirror-webkit=(.*)/) {
178 $mirror_webkit_url = "$1"
180 print("*** Unknown option: $arg\n");
187 if (`git config --get submodule.qtbase.url`) {
189 my @configresult = `git config -l`;
190 foreach (@configresult) {
191 if (/(submodule\.[^.=]+)\.url=.*/) {
192 system_v("git config --remove-section $1");
197 print("Will not reinitialize already initialized repository (use -f to force)!\n");
203 $init_args = "-q" if ($quiet);
204 system_v("git submodule init $init_args");
206 system_v("git config --remove submodule.qtwebkit");
207 system_v("git config --remove submodule.qtwebkit-examples-and-demos");
210 my @configresult = `git config -l`;
211 my $proto = $protocols{$protocol};
212 foreach (@configresult) {
213 if (/(submodule\.[^.=]+\.url)=(.*)/) {
217 # WebKit is special, and has only external link.
218 if ($key ne "submodule.qtwebkit.url") {
219 # qt-labs projects are still hosted under qt internally.
220 $value =~ s,^git://gitorious\.org/qt-labs/,${proto}qt/, if ($protocol ne "http") ;
221 $value =~ s,^git://gitorious\.org/,$proto,;
224 system_v("git config \"$key\" \"$value\"");
225 if ($ignore_submodules) {
226 $key =~ s,\.url,.ignore,;
227 system_v("git config \"$key\" \"all\"");
232 # manually clone each repo here, so we can easily use reference repos, mirrors and add all staging
235 @configresult = `git config -l`;
236 foreach (@configresult) {
237 if(/submodule\.([^.=]+)\.url=(.*)/){
242 if (-d "$alternates/$repo") {
243 $ref = "--reference $alternates/$repo";
245 print(" *** $alternates/$repo not found, ignoring alternate for this submodule\n");
250 if ($mirror_url && ($repo ne "qtwebkit")) {
251 my $mirror = $mirror_url.$repo;
252 $mirror .= ".git" unless (-d $mirror); # Support local disk mirror
253 } elsif ($mirror_webkit_url && ($repo eq "qtwebkit")) {
254 $mirror = $mirror_webkit_url;
257 my $do_clone = (! -d "$repo/.git");
258 system_v("git clone $ref " . ($mirror ? $mirror : $url) . " $repo") if ($do_clone);
259 chdir($repo) or die "'cd $repo' failed...";
260 system_v("git fetch " . ($mirror ? $mirror : $url)) if (!$do_clone);
263 system_v("git config remote.origin.url $url");
264 system_v("git remote add mirror $mirror");
267 # add missing staging repos as remotes
268 my @staging = grep(/^$repo/, keys %staging_repos);
269 my @current_remotes = `git remote show`;
270 chomp @current_remotes;
271 my %diff = map { $_ => 1 } @current_remotes;
272 my @add_staging = grep !$diff{"$_"}, @staging;
273 foreach (@add_staging) {
274 my $staging_repo = $_;
275 my $staging_repo_url = $staging_repos{$_};
277 $staging_repo_url =~ s,^git://gitorious\.org/qt-labs/,${proto}qt/, if ($protocol ne "http") ;
278 $staging_repo_url =~ s,^git://gitorious\.org/,$proto,;
280 system_v("git remote add $staging_repo $staging_repo_url");
283 if ($detach_alternates) {
284 system_v("git repack -a");
285 unlink(".git/objects/info/alternates");
287 chdir("..") or die "'cd ..' failed..";
290 system_v("git submodule update");