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