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;
57 'internal' => 'git://scm.dev.nokia.troll.no',
58 'ssh' => 'git@scm.dev.nokia.troll.no',
59 'http' => 'http://git.gitorious.org'
74 print("$0 <options>\n");
75 print(" -f Force initialization.\n");
76 print(" -q Quiet operation. Will exit cleanly if repository is already\n");
77 print(" initialized.\n\n");
79 print("Module options\n");
80 print(" -no-webkit Skip webkit and webkit examples submodules.\n");
81 print(" -no-update Skip the 'git submodule update' command.\n");
82 print(" -ignore-submodules\n");
83 print(" Ignores submodules when doing operations on qt5 repo, such\n");
84 print(" as 'pull', 'fetch', 'diff' etc. Use\n");
85 print(" --ignore-submodules=none to override, when needed\n\n");
87 print("Repository options:\n");
88 print(" -nokia-developer Switch to internal Nokia URLs.\n");
89 print(" -brisbane Switch to internal Nokia URLs, and setup the brisbane\n");
91 print(" -ssh Use SSH protocol, for restrictive firewalls. Note that this\n");
92 print(" requires a user account with an uploaded SSH key on all\n");
93 print(" servers used. (Implies -nokia-developer!)\n");
94 print(" -http Use HTTP protocol, for restrictive firewalls. Note that this\n");
95 print(" only works with the external Gitorious server.\n");
96 print(" -alternates=<path to other Qt5 repo>\n");
97 print(" Adds alternates for each submodule to another full qt5\n");
98 print(" checkout. This makes this qt5 checkout very small, as it\n");
99 print(" will use the object store of the alternates before unique\n");
100 print(" objects are stored in its own object store.\n");
101 print(" PS: This option does not work with -no-update!\n");
102 print(" PSS:This will make this repo dependent on the alternate!\n");
103 print(" The dependency can be broken by running 'git repack -a'\n");
104 print(" in each submodule, where required.\n");
111 } elsif ($arg eq "-q") {
113 } elsif ($arg eq "-brisbane" || $arg eq "-brisbane-nokia-developer") {
114 $nokia_developer = 1;
115 $brisbane_mirror = 1;
116 } elsif ($arg eq "-nokia-developer") {
117 $nokia_developer = 1;
118 $protocol = "internal";
119 } elsif ($arg eq "-ssh" || $arg eq "-ssh-protocol") {
121 } elsif ($arg eq "-http") {
122 if ($nokia_developer || $brisbane_mirror) {
123 print("*** Ignoring use of HTTP protocol, as it's only usable with external server\n");
127 } elsif ($arg eq "/?" || $arg eq "-?" || $arg eq "/h" || $arg eq "-h" || $arg eq "--help") {
130 } elsif ($arg eq "-no-webkit") {
132 } elsif ($arg eq "-no-update") {
134 } elsif ($arg eq "-ignore-submodules") {
135 $ignore_submodules = 1;
136 } elsif ($arg =~ /-alternates=(.*)/) {
139 print("*** Unknown option: $arg\n");
146 if (`git config --get submodule.qtbase.url`) {
148 my @configresult = `git config -l`;
149 foreach (@configresult) {
150 if (/(submodule\.[^.=]+)\.url=.*/) {
151 system_v("git config --remove-section $1");
156 print("Will not reinitialize already initialized repository (use -f to force)!\n");
162 $init_args = "-q" if ($quiet);
163 system_v("git submodule init $init_args");
165 system_v("git config --remove submodule.qtwebkit");
166 system_v("git config --remove submodule.qtwebkit-examples-and-demos");
169 my @configresult = `git config -l`;
170 my $proto = $protocols{$protocol};
171 foreach (@configresult) {
172 if (/(submodule\.[^.=]+\.url)=(.*)/) {
176 # WebKit is special, and has only external link.
177 if ($key ne "submodule.qtwebkit.url") {
178 # qt-labs projects are still hosted under qt internally.
179 $value =~ s,^git://gitorious\.org/qt-labs/,$proto/qt/, if ($protocol ne "http") ;
180 $value =~ s,^git://gitorious\.org/,$proto/,;
183 system_v("git config \"$key\" \"$value\"");
184 if ($ignore_submodules) {
185 $key =~ s,\.url,.ignore,;
186 system_v("git config \"$key\" \"all\"");
191 # manually clone each repo here, so we can easily use reference repos, mirrors and add all staging
194 @configresult = `git config -l`;
195 foreach (@configresult) {
196 if(/submodule\.([^.=]+)\.url=(.*)/){
201 if (-d "$alternates/$repo") {
202 $ref = "--reference $alternates/$repo";
204 print(" *** $alternates/$repo not found, ignoring alternate for this submodule\n");
207 system_v("git clone $ref $url $repo");
213 if ($nokia_developer) {
214 if ($brisbane_mirror) {
215 my $mirror_url = "git://bq-git.apac.nokia.com/qtsoftware/qt/";
216 my %exceptions = ("qtwebkit", "git://bq-git.apac.nokia.com/qtsoftware/research/gitorious-org-webkit-qtwebkit-mirror.git");
217 my @configresult2 = `git config -l`;
218 foreach (@configresult2) {
219 if(/submodule\.([^.=]+)\.url=(.*)/){
223 no warnings 'uninitialized';
224 if($exceptions{$repo} ne undef){
225 $this_mirror_url = $exceptions{$repo};
227 $this_mirror_url = "$mirror_url$repo.git";
229 print("Using mirror $this_mirror_url to clone $url\n");
230 unless ($no_update) {
231 system_v("git clone $this_mirror_url $repo");
232 chdir($repo) or die "cd failed";
233 system_v("git config remote.origin.url $url");
234 system_v("git remote add mirror $this_mirror_url");
235 chdir("..") or die "cd fail";
243 system_v("git submodule update");