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;
54 my $mirror_webkit_url = "";
58 'internal' => 'git://scm.dev.nokia.troll.no',
59 'ssh' => 'git@scm.dev.nokia.troll.no',
60 'http' => 'http://git.gitorious.org'
75 print("$0 <options>\n");
76 print(" -f Force initialization.\n");
77 print(" -q Quiet operation. Will exit cleanly if repository is already\n");
78 print(" initialized.\n\n");
80 print("Module options\n");
81 print(" -no-webkit Skip webkit and webkit examples submodules.\n");
82 print(" -no-update Skip the 'git submodule update' command.\n");
83 print(" -ignore-submodules\n");
84 print(" Ignores submodules when doing operations on qt5 repo, such\n");
85 print(" as 'pull', 'fetch', 'diff' etc. Use\n");
86 print(" --ignore-submodules=none to override, when needed\n\n");
88 print("Repository options:\n");
89 print(" -nokia-developer Switch to internal Nokia URLs.\n");
90 print(" -brisbane Switch to internal Nokia URLs, and setup the brisbane\n");
91 print(" mirrors. (Uses the -mirror and -mirror-webkit options.)\n");
92 print(" -ssh Use SSH protocol, for restrictive firewalls. Note that this\n");
93 print(" requires a user account with an uploaded SSH key on all\n");
94 print(" servers used. (Implies -nokia-developer!)\n");
95 print(" -http Use HTTP protocol, for restrictive firewalls. Note that this\n");
96 print(" only works with the external Gitorious server.\n");
97 print(" -alternates=<path to other Qt5 repo>\n");
98 print(" Adds alternates for each submodule to another full qt5\n");
99 print(" checkout. This makes this qt5 checkout very small, as it\n");
100 print(" will use the object store of the alternates before unique\n");
101 print(" objects are stored in its own object store.\n");
102 print(" PS: This option does not work with -no-update!\n");
103 print(" PSS:This will make this repo dependent on the alternate!\n");
104 print(" The dependency can be broken by running 'git repack -a'\n");
105 print(" in each submodule, where required.\n");
106 print(" -mirror=<url> Uses <url> as the base URL for cloning submodules.\n");
107 print(" -mirror=user\@machine/foo/bar\n");
108 print(" while for example clone qtbase from\n");
109 print(" user\@machine/foo/bar/qtbase.git\n");
110 print(" -mirror-webkit=<url>\n");
111 print(" Uses <url> as the URL for cloning webkit.\n");
118 } elsif ($arg eq "-q") {
120 } elsif ($arg eq "-brisbane" || $arg eq "-brisbane-nokia-developer") {
121 $nokia_developer = 1;
122 $mirror_url = "git://bq-git.apac.nokia.com/qtsoftware/qt/";
123 $mirror_webkit_url = "git://bq-git.apac.nokia.com/qtsoftware/research/gitorious-org-webkit-qtwebkit-mirror.git";
124 } elsif ($arg eq "-nokia-developer") {
125 $nokia_developer = 1;
126 $protocol = "internal";
127 } elsif ($arg eq "-ssh" || $arg eq "-ssh-protocol") {
129 } elsif ($arg eq "-http") {
130 if ($nokia_developer) {
131 print("*** Ignoring use of HTTP protocol, as it's only usable with external server\n");
135 } elsif ($arg eq "/?" || $arg eq "-?" || $arg eq "/h" || $arg eq "-h" || $arg eq "--help") {
138 } elsif ($arg eq "-no-webkit") {
140 } elsif ($arg eq "-no-update") {
142 } elsif ($arg eq "-ignore-submodules") {
143 $ignore_submodules = 1;
144 } elsif ($arg =~ /-alternates=(.*)/) {
146 } elsif ($arg =~ /-mirror=(.*)/) {
148 $mirror_url =~ s,\/\/+$,/,;
149 } elsif ($arg =~ /-mirror-webkit=(.*)/) {
150 $mirror_webkit_url = "$1"
152 print("*** Unknown option: $arg\n");
159 if (`git config --get submodule.qtbase.url`) {
161 my @configresult = `git config -l`;
162 foreach (@configresult) {
163 if (/(submodule\.[^.=]+)\.url=.*/) {
164 system_v("git config --remove-section $1");
169 print("Will not reinitialize already initialized repository (use -f to force)!\n");
175 $init_args = "-q" if ($quiet);
176 system_v("git submodule init $init_args");
178 system_v("git config --remove submodule.qtwebkit");
179 system_v("git config --remove submodule.qtwebkit-examples-and-demos");
182 my @configresult = `git config -l`;
183 my $proto = $protocols{$protocol};
184 foreach (@configresult) {
185 if (/(submodule\.[^.=]+\.url)=(.*)/) {
189 # WebKit is special, and has only external link.
190 if ($key ne "submodule.qtwebkit.url") {
191 # qt-labs projects are still hosted under qt internally.
192 $value =~ s,^git://gitorious\.org/qt-labs/,$proto/qt/, if ($protocol ne "http") ;
193 $value =~ s,^git://gitorious\.org/,$proto/,;
196 system_v("git config \"$key\" \"$value\"");
197 if ($ignore_submodules) {
198 $key =~ s,\.url,.ignore,;
199 system_v("git config \"$key\" \"all\"");
204 # manually clone each repo here, so we can easily use reference repos, mirrors and add all staging
207 @configresult = `git config -l`;
208 foreach (@configresult) {
209 if(/submodule\.([^.=]+)\.url=(.*)/){
214 if (-d "$alternates/$repo") {
215 $ref = "--reference $alternates/$repo";
217 print(" *** $alternates/$repo not found, ignoring alternate for this submodule\n");
220 if (($mirror_url && $repo ne "qtwebkit") || ($mirror_webkit_url && $repo eq "qtwebkit") {
221 my $mirror = $mirror_url.$repo;
222 $mirror .= ".git" unless (-d $mirror); # Support local disk mirror
223 $mirror = $mirror_webkit_url if ($repo eq "qtwebkit");
224 system_v("git clone $ref $mirror $repo");
225 chdir($repo) or die "'cd $repo' failed...";
226 system_v("git config remote.origin.url $url");
227 system_v("git remote add mirror $mirror");
228 chdir("..") or die "'cd ..' failed..";
230 system_v("git clone $ref $url $repo");
237 system_v("git submodule update");