blob: 10b8d0e648666b1389d3fad5392f4abe33895fc1 [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.title=Downloading the Source
2@jd:body
3
4<!--
Clay Murphy768b82a2013-11-12 11:32:41 -08005 Copyright 2013 The Android Open Source Project
Robert Ly35f2fda2013-01-29 16:27:05 -08006
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>
Clay Murphyd51ff422014-05-14 10:37:37 -070058$ curl https://storage.googleapis.com/git-repo-downloads/repo &gt; ~/bin/repo
Robert Ly35f2fda2013-01-29 16:27:05 -080059$ 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>
Robert Ly40e3b6d2013-04-17 18:12:10 -070066<p>
67 For version 1.19, the SHA-1 checksum for repo is 92cbad8c880f697b58ed83e348d06619f8098e6c
68</p>
Conley Owens8abcd422013-10-01 11:18:03 -070069<p>
70 For version 1.20, the SHA-1 checksum for repo is e197cb48ff4ddda4d11f23940d316e323b29671c
71</p>
Conley Owens0c1838b2014-01-30 16:06:33 -080072<p>
73 For version 1.21, the SHA-1 checksum for repo is b8bd1804f432ecf1bab730949c82b93b0fc5fede
74</p>
Robert Ly35f2fda2013-01-29 16:27:05 -080075<h2 id="initializing-a-repo-client">
76 Initializing a Repo client
77</h2>
78<p>
79 After installing Repo, set up your client to access the Android source repository:
80</p>
81<ol>
82 <li>
83 <p>
84 Create an empty directory to hold your working files. If you're using MacOS, this has to
85 be on a case-sensitive filesystem. Give it any name you like:
86 </p>
87<pre>
88$ mkdir WORKING_DIRECTORY
89$ cd WORKING_DIRECTORY
90</pre>
91 </li>
92 <li>
93 <p>
94 Run <code>repo init</code> to bring down the latest version of Repo with all its most
95 recent bug fixes. You must specify a URL for the manifest, which specifies where the
96 various repositories included in the Android source will be placed within your working
97 directory.
98 </p>
99<pre>
100$ repo init -u https://android.googlesource.com/platform/manifest
101</pre>
102 <p>
103 To check out a branch other than "master", specify it with -b:
104 </p>
105<pre>
106$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
107</pre>
108 </li>
109 <li>
110 <p>
111 When prompted, configure Repo with your real name and email address. To use the Gerrit
112 code-review tool, you will need an email address that is connected with a <a href=
113 "https://www.google.com/accounts">registered Google account</a>. Make sure this is a live
114 address at which you can receive messages. The name that you provide here will show up in
115 attributions for your code submissions.
116 </p>
117 </li>
118</ol>
119<p>
120 A successful initialization will end with a message stating that Repo is initialized in your
121 working directory. Your client directory should now contain a <code>.repo</code> directory
122 where files such as the manifest will be kept.
123</p>
124<h2 id="getting-the-files">
125 Downloading the Android Source Tree
126</h2>
127<p>
128 To pull down the Android source tree to your working directory from the repositories as
129 specified in the default manifest, run
130</p>
131<pre>$ repo sync</pre>
132<p>
133 The Android source files will be located in your working directory under their project names.
134 The initial sync operation will take an hour or more to complete. For more about <code>repo
135 sync</code> and other Repo commands, see the <a href="developing.html">Developing</a> section.
136</p>
137<h2 id="using-authentication">
138 Using Authentication
139</h2>
140<p>
141 By default, access to the Android source code is anonymous. To protect the servers against
142 excessive usage, each IP address is associated with a quota.
143</p>
144<p>
145 When sharing an IP address with other users (e.g. when accessing the source repositories from
146 beyond a NAT firewall), the quotas can trigger even for regular usage patterns (e.g. if many
147 users sync new clients from the same IP address within a short period).
148</p>
149<p>
150 In that case, it is possible to use authenticated access, which then uses a separate quota
151 for each user, regardless of the IP address.
152</p>
153<p>
154 The first step is to create a password from <a href=
155 "https://android.googlesource.com/new-password">the password generator</a> and to save it in
156 <code>~/.netrc</code> according to the instructions on that page.
157</p>
158<p>
159 The second step is to force authenticated access, by using the following manifest URI:
160 <code>https://android.googlesource.com/a/platform/manifest</code>. Notice how the
161 <code>/a/</code> directory prefix triggers mandatory authentication. You can convert an
162 existing client to use mandatory authentication with the following command:
163</p>
164<pre>
165$ repo init -u https://android.googlesource.com/a/platform/manifest
166</pre>
167<h2 id="troubleshooting-network-issues">
168 Troubleshooting network issues
169</h2>
170<p>
171 When downloading from behind a proxy (which is common in some corporate environments), it
172 might be necessary to explicitly specify the proxy that is then used by repo:
173</p>
174<pre>
175$ export HTTP_PROXY=http://&lt;proxy_user_id&gt;:&lt;proxy_password&gt;@&lt;proxy_server&gt;:&lt;proxy_port&gt;
176$ export HTTPS_PROXY=http://&lt;proxy_user_id&gt;:&lt;proxy_password&gt;@&lt;proxy_server&gt;:&lt;proxy_port&gt;
177</pre>
178<p>
179 More rarely, Linux clients experience connectivity issues, getting stuck in the middle of
180 downloads (typically during "Receiving objects"). It has been reported that tweaking the
181 settings of the TCP/IP stack and using non-parallel commands can improve the situation. You
182 need root access to modify the TCP setting:
183</p>
184<pre>
185$ sudo sysctl -w net.ipv4.tcp_window_scaling=0
186$ repo sync -j1
187</pre>
188<h2 id="using-a-local-mirror">
189 Using a local mirror
190</h2>
191<p>
192 When using several clients, especially in situations where bandwidth is scarce, it is better
193 to create a local mirror of the entire server content, and to sync clients from that mirror
194 (which requires no network access). The download for a full mirror is smaller than the
195 download of two clients, while containing more information.
196</p>
197<p>
198 These instructions assume that the mirror is created in <code>/usr/local/aosp/mirror</code>.
199 The first step is to create and sync the mirror itself, which uses close to 13GB of network
200 bandwidth and a similar amount of disk space. Notice the <code>--mirror</code> flag, which
201 can only be specified when creating a new client:
202</p>
203<pre>
204$ mkdir -p /usr/local/aosp/mirror
205$ cd /usr/local/aosp/mirror
206$ repo init -u https://android.googlesource.com/mirror/manifest --mirror
207$ repo sync
208</pre>
209<p>
210 Once the mirror is synced, new clients can be created from it. Note that it's important to
211 specify an absolute path:
212</p>
213<pre>$ mkdir -p /usr/local/aosp/master
214$ cd /usr/local/aosp/master
215$ repo init -u /usr/local/aosp/mirror/platform/manifest.git
216$ repo sync
217</pre>
218<p>
219 Finally, to sync a client against the server, the mirror needs to be synced against the
220 server, then the client against the mirror:
221</p>
222<pre>
223$ cd /usr/local/aosp/mirror
224$ repo sync
225$ cd /usr/local/aosp/master
226$ repo sync
227</pre>
228<p>
229 It's possible to store the mirror on a LAN server and to access it over NFS, SSH or Git. It's
230 also possible to store it on a removable drive and to pass that drive around between users or
231 between machines.
232</p>
233<h2 id="verifying-git-tags">
234 Verifying Git Tags
235</h2>
236<p>
237 Load the following public key into your GnuPG key database. The key is used to sign annotated
238 tags that represent releases.
239</p>
240<pre>
241$ gpg --import
242</pre>
243<p>
244 Copy and paste the key(s) below, then enter EOF (Ctrl-D) to end the input and process the
245 keys.
246</p>
247<pre>
248-----BEGIN PGP PUBLIC KEY BLOCK-----
249Version: GnuPG v1.4.2.2 (GNU/Linux)
250
251mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
252lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
2538tR1cXb197Ob8kOfQ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1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
270KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
271N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
272vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
273G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
274hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
275EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
276=Wi5D
277-----END PGP PUBLIC KEY BLOCK-----
278</pre>
279<p>
280 After importing the keys, you can verify any tag with
281</p>
282<pre>
283$ git tag -v TAG_NAME
284</pre>
285<p>
286 If you haven't <a href="initializing.html#ccache">set up ccache</a> yet, now would be a good
287 time to do it.
Conley Owens8abcd422013-10-01 11:18:03 -0700288</p>