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