blob: 7376d4134230de66b2a153bed8de068997d40a32 [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.title=Downloading the Source
2@jd:body
3
4<!--
5 Copyright 2010 The Android Open Source Project
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18-->
19<div id="qv-wrapper">
20 <div id="qv">
21 <h2>In this document</h2>
22 <ol id="auto-toc">
23 </ol>
24 </div>
25</div>
26
27<p>
28 The Android source tree is located in a Git repository hosted by Google. This document
29 describes how to download the source tree for a specific Android code-line.
30</p>
31<h2 id="installing-repo">
32 Installing Repo
33</h2>
34<p>
35 Repo is a tool that makes it easier to work with Git in the context of Android. For more
36 information about Repo, see the <a href="developing.html">Developing</a> section.
37</p>
38<p>
39 To install Repo:
40</p>
41<ol>
42 <li>
43 <p>
44 Make sure you have a bin/ directory in your home directory and that it is included in
45 your path:
46 </p>
47 <pre>
48<code>$ mkdir ~/bin
49$ PATH=~/bin:$PATH
50</code>
51</pre>
52 </li>
53 <li>
54 <p>
55 Download the Repo tool and ensure that it is executable:
56 </p>
57 <pre>
58$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo &gt; ~/bin/repo
59$ chmod a+x ~/bin/repo
60</pre>
61 </li>
62</ol>
63<p>
64 For version 1.17, the SHA-1 checksum for repo is ddd79b6d5a7807e911b524cb223bc3544b661c28
65</p>
66<h2 id="initializing-a-repo-client">
67 Initializing a Repo client
68</h2>
69<p>
70 After installing Repo, set up your client to access the Android source repository:
71</p>
72<ol>
73 <li>
74 <p>
75 Create an empty directory to hold your working files. If you're using MacOS, this has to
76 be on a case-sensitive filesystem. Give it any name you like:
77 </p>
78<pre>
79$ mkdir WORKING_DIRECTORY
80$ cd WORKING_DIRECTORY
81</pre>
82 </li>
83 <li>
84 <p>
85 Run <code>repo init</code> to bring down the latest version of Repo with all its most
86 recent bug fixes. You must specify a URL for the manifest, which specifies where the
87 various repositories included in the Android source will be placed within your working
88 directory.
89 </p>
90<pre>
91$ repo init -u https://android.googlesource.com/platform/manifest
92</pre>
93 <p>
94 To check out a branch other than "master", specify it with -b:
95 </p>
96<pre>
97$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
98</pre>
99 </li>
100 <li>
101 <p>
102 When prompted, configure Repo with your real name and email address. To use the Gerrit
103 code-review tool, you will need an email address that is connected with a <a href=
104 "https://www.google.com/accounts">registered Google account</a>. Make sure this is a live
105 address at which you can receive messages. The name that you provide here will show up in
106 attributions for your code submissions.
107 </p>
108 </li>
109</ol>
110<p>
111 A successful initialization will end with a message stating that Repo is initialized in your
112 working directory. Your client directory should now contain a <code>.repo</code> directory
113 where files such as the manifest will be kept.
114</p>
115<h2 id="getting-the-files">
116 Downloading the Android Source Tree
117</h2>
118<p>
119 To pull down the Android source tree to your working directory from the repositories as
120 specified in the default manifest, run
121</p>
122<pre>$ repo sync</pre>
123<p>
124 The Android source files will be located in your working directory under their project names.
125 The initial sync operation will take an hour or more to complete. For more about <code>repo
126 sync</code> and other Repo commands, see the <a href="developing.html">Developing</a> section.
127</p>
128<h2 id="using-authentication">
129 Using Authentication
130</h2>
131<p>
132 By default, access to the Android source code is anonymous. To protect the servers against
133 excessive usage, each IP address is associated with a quota.
134</p>
135<p>
136 When sharing an IP address with other users (e.g. when accessing the source repositories from
137 beyond a NAT firewall), the quotas can trigger even for regular usage patterns (e.g. if many
138 users sync new clients from the same IP address within a short period).
139</p>
140<p>
141 In that case, it is possible to use authenticated access, which then uses a separate quota
142 for each user, regardless of the IP address.
143</p>
144<p>
145 The first step is to create a password from <a href=
146 "https://android.googlesource.com/new-password">the password generator</a> and to save it in
147 <code>~/.netrc</code> according to the instructions on that page.
148</p>
149<p>
150 The second step is to force authenticated access, by using the following manifest URI:
151 <code>https://android.googlesource.com/a/platform/manifest</code>. Notice how the
152 <code>/a/</code> directory prefix triggers mandatory authentication. You can convert an
153 existing client to use mandatory authentication with the following command:
154</p>
155<pre>
156$ repo init -u https://android.googlesource.com/a/platform/manifest
157</pre>
158<h2 id="troubleshooting-network-issues">
159 Troubleshooting network issues
160</h2>
161<p>
162 When downloading from behind a proxy (which is common in some corporate environments), it
163 might be necessary to explicitly specify the proxy that is then used by repo:
164</p>
165<pre>
166$ export HTTP_PROXY=http://&lt;proxy_user_id&gt;:&lt;proxy_password&gt;@&lt;proxy_server&gt;:&lt;proxy_port&gt;
167$ export HTTPS_PROXY=http://&lt;proxy_user_id&gt;:&lt;proxy_password&gt;@&lt;proxy_server&gt;:&lt;proxy_port&gt;
168</pre>
169<p>
170 More rarely, Linux clients experience connectivity issues, getting stuck in the middle of
171 downloads (typically during "Receiving objects"). It has been reported that tweaking the
172 settings of the TCP/IP stack and using non-parallel commands can improve the situation. You
173 need root access to modify the TCP setting:
174</p>
175<pre>
176$ sudo sysctl -w net.ipv4.tcp_window_scaling=0
177$ repo sync -j1
178</pre>
179<h2 id="using-a-local-mirror">
180 Using a local mirror
181</h2>
182<p>
183 When using several clients, especially in situations where bandwidth is scarce, it is better
184 to create a local mirror of the entire server content, and to sync clients from that mirror
185 (which requires no network access). The download for a full mirror is smaller than the
186 download of two clients, while containing more information.
187</p>
188<p>
189 These instructions assume that the mirror is created in <code>/usr/local/aosp/mirror</code>.
190 The first step is to create and sync the mirror itself, which uses close to 13GB of network
191 bandwidth and a similar amount of disk space. Notice the <code>--mirror</code> flag, which
192 can only be specified when creating a new client:
193</p>
194<pre>
195$ mkdir -p /usr/local/aosp/mirror
196$ cd /usr/local/aosp/mirror
197$ repo init -u https://android.googlesource.com/mirror/manifest --mirror
198$ repo sync
199</pre>
200<p>
201 Once the mirror is synced, new clients can be created from it. Note that it's important to
202 specify an absolute path:
203</p>
204<pre>$ mkdir -p /usr/local/aosp/master
205$ cd /usr/local/aosp/master
206$ repo init -u /usr/local/aosp/mirror/platform/manifest.git
207$ repo sync
208</pre>
209<p>
210 Finally, to sync a client against the server, the mirror needs to be synced against the
211 server, then the client against the mirror:
212</p>
213<pre>
214$ cd /usr/local/aosp/mirror
215$ repo sync
216$ cd /usr/local/aosp/master
217$ repo sync
218</pre>
219<p>
220 It's possible to store the mirror on a LAN server and to access it over NFS, SSH or Git. It's
221 also possible to store it on a removable drive and to pass that drive around between users or
222 between machines.
223</p>
224<h2 id="verifying-git-tags">
225 Verifying Git Tags
226</h2>
227<p>
228 Load the following public key into your GnuPG key database. The key is used to sign annotated
229 tags that represent releases.
230</p>
231<pre>
232$ gpg --import
233</pre>
234<p>
235 Copy and paste the key(s) below, then enter EOF (Ctrl-D) to end the input and process the
236 keys.
237</p>
238<pre>
239-----BEGIN PGP PUBLIC KEY BLOCK-----
240Version: GnuPG v1.4.2.2 (GNU/Linux)
241
242mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
243lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
2448tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
245u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
246wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
247/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
248jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
249MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
250b/aF/ygcR8mh5hgUfpF9IpXdkn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4KLM=
267=Wi5D
268-----END PGP PUBLIC KEY BLOCK-----
269</pre>
270<p>
271 After importing the keys, you can verify any tag with
272</p>
273<pre>
274$ git tag -v TAG_NAME
275</pre>
276<p>
277 If you haven't <a href="initializing.html#ccache">set up ccache</a> yet, now would be a good
278 time to do it.
279</p>