Home | History | Annotate | Download | only in porting
      1 page.title=Getting Source Code
      2 pdk.version=1.0
      3 doc.type=porting
      4 @jd:body
      5 
      6 <a name="toc"/>
      7 <div style="padding:10px">
      8 <a href="#androidSourceSetupBuildGitSetup">Introduction</a><br/>
      9 <a href="#androidSourceSetupBuildGitSetupInstall">Installing and Configuring Git</a><br/>
     10 <a href="#androidSourceSetupBuildGitSetupServer">Establishing Server Access</a><br/><div style="padding-left:40px">
     11 
     12 <a href="#androidSourceSetupBuildGitSetupServerRSAKeys">Generating RSA Keys</a><br/>
     13 <a href="#androidSourceSetupBuildGitSetupServerVerifyConnection">Verifying a Connection to the Git Server</a><br/></div>
     14 <a href="#androidSourceSetupGetCode">Downloading Code</a><br/>
     15 <a href="#androidSourceSetupExtractingPatch">Extracting an Android Patch</a><br/></div>
     16 
     17 <a name="androidSourceSetupBuildGitSetup"></a><h2>Introduction</h2>
     18 
     19 <p>Android relies on Git, a version control system, to install the Android platform. You will need to install Git 1.5.2 or greater in order to access the source tree. Please visit <a href="http://git.or.cz/">http://git.or.cz/</a> for more information regarding Git.</p>
     20 <p>Git permits you to control access to working directories, and we recommend that you use it to limit Android repository access to only a few people within your organization (please refer to your Google NDA for potential contractual restraints on sharing Android source access). </p>
     21 <p>You may clone Google's repository to a local copy for sharing internally (see Git documentation for details).</p>
     22 
     23 
     24 <a name="androidSourceSetupBuildGitSetupInstall"></a><h2>Installing and Configuring Git</h2>
     25 
     26 <p>To install the Git package, execute:</p>
     27 <pre class="prettyprint">
     28 % sudo apt-get install git-core
     29 </pre>
     30 
     31 
     32 <a name="androidSourceSetupBuildGitSetupServer"></a><h2>Establishing Server Access</h2>
     33 
     34 <p>Once Git is cleanly installed, you need to establish a connection with Google's Git server, a connection that requires an RSA key in order to authenticate requests.</p>
     35 
     36 
     37 <a name="androidSourceSetupBuildGitSetupServerRSAKeys"></a><h3>Generating RSA Keys</h3>
     38 
     39 <p>Each developer must have a unique RSA key in order to access Android source code. To generate an RSA key: </p>
     40 <p>
     41 <ol>
     42 <li>Type:<br/>
     43 <pre class="prettyprint">% ssh-keygen -t rsa -C  email (a] domain.com</pre><br/>
     44 You must use a valid email address to create your key.</li>
     45 <li>When prompted, indicate the file to which you wish to write your key (<code>id_rsa</code> in this example).</li>
     46 <li>When prompted, associate a passphrase with your key.</li>
     47 <li>Upon success, you should have two files saved to the designated directory:  </li>
     48 <ul>
     49   <li><code>id_rsa</code>: This file contains the private half of your RSA key. You shouldn't share this file with anyone. </li>
     50   <li><code>id_rsa.pub</code>: This is the public half or your RSA key and you should send it to your Google technical account manager.</li>
     51   </ul>
     52 </ol>
     53 </p>
     54 <p>Send your Google Account Manager your public key file in order to establish Git server access. </p>
     55 
     56 
     57 <a name="androidSourceSetupBuildGitSetupServerVerifyConnection"></a><h3>Verifying a Connection to the Git Server</h3>
     58 
     59 <p>Once you have generated an RSA key and shared the public file with Google, you can test your connection with the Git server with the following command:</p>
     60 <pre class="prettyprint">
     61 % ssh  android-git.ext.google.com
     62 </pre>
     63 
     64 <p>You should receive one of the following results:</p>
     65 
     66 <table border=1 cellpadding=2 cellspacing=0>
     67  <tbody><tr>
     68   <th scope="col">Result</th>
     69   <th scope="col">Cause</th>
     70   <th  scope="col">Action</th>
     71  </tr>
     72   <tr>
     73     <td>
     74 <code>fatal: What do you think I am? A shell?<BR>
     75 Connection to android-git closed.</code>
     76 </pre>	</td>
     77     <td>Success</td>
     78     <td>None. You successfully connected to the Git server. (You should not have shell access and it's expected to receive this error.)</td>
     79   </tr>
     80   <tr>
     81     <td>ssh hangs and eventually times out. </td>
     82     <td>Your setup is failing to locate and establish a basic connection. </td>
     83     <td>Google needs to debug network settings. </td>
     84   </tr>
     85   <tr>
     86     <td>Error: Permission denied &lt;public key&gt; </td>
     87     <td>Either you are not using the matching username or the RSA private key does not match the public key. </td>
     88     <td>Try executing:<BR> 
     89 	<code>
     90 % ssh $USER@android-
     91   git.ext.google.com
     92 </code></td>
     93   </tr>
     94 </table>
     95 
     96 
     97 <a name="androidSourceSetupGetCode"></a><h2>Downloading Code</h2>
     98 
     99 <p>Android source code is maintained in two repositories: <code>device</code> and <code>kernel</code>. The <code>device</code> repository includes the Android framework (things like the Activity Manager, Window Manager, Telephony Manager, View System, etc.). The <code>kernel</code> repository includes the core code necessary to run the operating system (things like the Display Driver, Camera Driver, Keypad Driver, Power Management, etc.). (Please see <a href="http://code.google.com/android/what-is-android.html">What is Android?</a> for details.)</p>
    100 
    101 <p>Save device and kernel code at the same directory level, for example:</p>
    102 <p>
    103 <ul><li><code>/home/joe/android/device</code></li>
    104 <li><code>/home/joe/android/kernel</code></li>
    105 </ul></p>
    106 <p><b>Device Code</b></p>
    107 <p>To download device code, you need your username and a unique <code>&lt;path&gt;</code> string supplied by Google to execute the following:</p>
    108 <pre class="prettyprint">
    109 % git-clone $USER (a] android-git.ext.google.com:&lt;path&gt;/device.git
    110 </pre>
    111 
    112 <p><b>Kernel Code</b></p>
    113 <p>To download kernel code, you need your username and a unique <code>&lt;path&gt;</code> string supplied by Google to execute the following:</p>
    114 <pre class="prettyprint">
    115 % git-clone $USER (a] android-git.ext.google.com:&lt;path&gt;/kernel.git
    116 </pre>
    117  
    118 
    119 
    120 <a name="androidSourceSetupExtractingPatch"></a><h2>Extracting an Android Patch</h2>
    121 
    122 <p>You likely already have Linux running on your platform and only need to integrate Android-specific changes. The following directions describe how to extract an Android patch.</p>
    123 <ol>
    124   <li>Download a generic version  of the Linux kernel that matches the Linux version downloaded with the Android Kernel code.</li>
    125   <li>Run <code>diff</code> on the two kernel packages to get Android-specific changes.</li>
    126   <li>Apply the patch to your target kernel and build.</li>
    127 </ol>
    128 
    129