page.title=Getting Source Code pdk.version=1.0 doc.type=porting @jd:body
Introduction
Installing and Configuring Git
Establishing Server Access
Generating RSA Keys
Verifying a Connection to the Git Server
Downloading Code
Extracting an Android Patch

Introduction

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 http://git.or.cz/ for more information regarding Git.

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).

You may clone Google's repository to a local copy for sharing internally (see Git documentation for details).

Installing and Configuring Git

To install the Git package, execute:

% sudo apt-get install git-core

Establishing Server Access

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.

Generating RSA Keys

Each developer must have a unique RSA key in order to access Android source code. To generate an RSA key:

  1. Type:
    % ssh-keygen -t rsa -C  email@domain.com

    You must use a valid email address to create your key.
  2. When prompted, indicate the file to which you wish to write your key (id_rsa in this example).
  3. When prompted, associate a passphrase with your key.
  4. Upon success, you should have two files saved to the designated directory:

Send your Google Account Manager your public key file in order to establish Git server access.

Verifying a Connection to the Git Server

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:

% ssh  android-git.ext.google.com

You should receive one of the following results:

Result Cause Action
fatal: What do you think I am? A shell?
Connection to android-git closed.
Success None. You successfully connected to the Git server. (You should not have shell access and it's expected to receive this error.)
ssh hangs and eventually times out. Your setup is failing to locate and establish a basic connection. Google needs to debug network settings.
Error: Permission denied <public key> Either you are not using the matching username or the RSA private key does not match the public key. Try executing:
% ssh $USER@android- git.ext.google.com

Downloading Code

Android source code is maintained in two repositories: device and kernel. The device repository includes the Android framework (things like the Activity Manager, Window Manager, Telephony Manager, View System, etc.). The kernel 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 What is Android? for details.)

Save device and kernel code at the same directory level, for example:

Device Code

To download device code, you need your username and a unique <path> string supplied by Google to execute the following:

% git-clone $USER@android-git.ext.google.com:<path>/device.git

Kernel Code

To download kernel code, you need your username and a unique <path> string supplied by Google to execute the following:

% git-clone $USER@android-git.ext.google.com:<path>/kernel.git

Extracting an Android Patch

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.

  1. Download a generic version of the Linux kernel that matches the Linux version downloaded with the Android Kernel code.
  2. Run diff on the two kernel packages to get Android-specific changes.
  3. Apply the patch to your target kernel and build.