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