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'
78 -f Force initialization.
79 -q Quiet operation. Will exit cleanly if repository is already
83 -no-webkit Skip webkit and webkit examples submodules.
84 -no-update Skip the 'git submodule update' command.
86 Ignores submodules when doing operations on qt5 repo, such
87 as 'pull', 'fetch', 'diff' etc. Use
88 --ignore-submodules=none to override, when needed
91 -nokia-developer Switch to internal Nokia URLs.
92 -brisbane Switch to internal Nokia URLs, and setup the brisbane
93 mirrors. (Uses the -mirror and -mirror-webkit options.)
94 -ssh Use SSH protocol, for restrictive firewalls. Note that this
95 requires a user account with an uploaded SSH key on all
96 servers used. (Implies -nokia-developer!)
97 -http Use HTTP protocol, for restrictive firewalls. Note that this
98 only works with the external Gitorious server.
99 -alternates=<path to other Qt5 repo>
100 Adds alternates for each submodule to another full qt5
101 checkout. This makes this qt5 checkout very small, as it
102 will use the object store of the alternates before unique
103 objects are stored in its own object store.
104 PS: This option does not work with -no-update!
105 PSS:This will make this repo dependent on the alternate!
106 The dependency can be broken by running 'git repack -a'
107 in each submodule, where required.
108 -copy-objects Copies all objects from the alternates into the individual
109 repos, to ensure that the repositories are independent from
110 the source used as a reference for cloning.
111 -mirror=<url> Uses <url> as the base URL for cloning submodules.
112 -mirror=user\@machine/foo/bar
113 while for example clone qtbase from
114 user\@machine/foo/bar/qtbase.git
116 Uses <url> as the URL for cloning webkit.
124 } elsif ($arg eq "-q") {
126 } elsif ($arg eq "-brisbane" || $arg eq "-brisbane-nokia-developer") {
127 $nokia_developer = 1;
128 $mirror_url = "git://bq-git.apac.nokia.com/qtsoftware/qt/";
129 $mirror_webkit_url = "git://bq-git.apac.nokia.com/qtsoftware/research/gitorious-org-webkit-qtwebkit-mirror.git";
130 } elsif ($arg eq "-nokia-developer") {
131 $nokia_developer = 1;
132 $protocol = "internal";
133 } elsif ($arg eq "-ssh" || $arg eq "-ssh-protocol") {
135 } elsif ($arg eq "-http") {
136 if ($nokia_developer) {
137 print("*** Ignoring use of HTTP protocol, as it's only usable with external server\n");
141 } elsif ($arg eq "/?" || $arg eq "-?" || $arg eq "/h" || $arg eq "-h" || $arg eq "--help") {
144 } elsif ($arg eq "-no-webkit") {
146 } elsif ($arg eq "-no-update") {
148 } elsif ($arg eq "-ignore-submodules") {
149 $ignore_submodules = 1;
150 } elsif ($arg =~ /-alternates=(.*)/) {
152 } elsif ($arg eq "-copy-objects") {
153 $detach_alternates = 1;
154 } elsif ($arg =~ /-mirror=(.*)/) {
156 $mirror_url =~ s,\/\/+$,/,;
157 } elsif ($arg =~ /-mirror-webkit=(.*)/) {
158 $mirror_webkit_url = "$1"
160 print("*** Unknown option: $arg\n");
167 if (`git config --get submodule.qtbase.url`) {
169 my @configresult = `git config -l`;
170 foreach (@configresult) {
171 if (/(submodule\.[^.=]+)\.url=.*/) {
172 system_v("git config --remove-section $1");
177 print("Will not reinitialize already initialized repository (use -f to force)!\n");
183 $init_args = "-q" if ($quiet);
184 system_v("git submodule init $init_args");
186 system_v("git config --remove submodule.qtwebkit");
187 system_v("git config --remove submodule.qtwebkit-examples-and-demos");
190 my @configresult = `git config -l`;
191 my $proto = $protocols{$protocol};
192 foreach (@configresult) {
193 if (/(submodule\.[^.=]+\.url)=(.*)/) {
197 # WebKit is special, and has only external link.
198 if ($key ne "submodule.qtwebkit.url") {
199 # qt-labs projects are still hosted under qt internally.
200 $value =~ s,^git://gitorious\.org/qt-labs/,$proto/qt/, if ($protocol ne "http") ;
201 $value =~ s,^git://gitorious\.org/,$proto/,;
204 system_v("git config \"$key\" \"$value\"");
205 if ($ignore_submodules) {
206 $key =~ s,\.url,.ignore,;
207 system_v("git config \"$key\" \"all\"");
212 # manually clone each repo here, so we can easily use reference repos, mirrors and add all staging
215 @configresult = `git config -l`;
216 foreach (@configresult) {
217 if(/submodule\.([^.=]+)\.url=(.*)/){
222 if (-d "$alternates/$repo") {
223 $ref = "--reference $alternates/$repo";
225 print(" *** $alternates/$repo not found, ignoring alternate for this submodule\n");
228 if (($mirror_url && $repo ne "qtwebkit") || ($mirror_webkit_url && $repo eq "qtwebkit") {
229 my $mirror = $mirror_url.$repo;
230 $mirror .= ".git" unless (-d $mirror); # Support local disk mirror
231 $mirror = $mirror_webkit_url if ($repo eq "qtwebkit");
232 system_v("git clone $ref $mirror $repo");
233 chdir($repo) or die "'cd $repo' failed...";
234 system_v("git config remote.origin.url $url");
235 system_v("git remote add mirror $mirror");
236 chdir("..") or die "'cd ..' failed..";
238 system_v("git clone $ref $url $repo");
240 if ($detach_alternates) {
241 chdir($repo) or die "'cd $repo' failed...";
242 system_v("git repack -a");
243 unlink(".git/objects/info/alternates");
244 chdir("..") or die "'cd ..' failed..";
251 system_v("git submodule update");