Android AOSP code download

download source code

 

The Android source tree is in a Git repository hosted by Google. The Git repository contains metadata about the Android source code, including what changes were made to the source code and when they were changed. This page describes how to download the source tree for a specific Android codeline.

To start with a device-specific factory image instead of downloading source code, see Choosing a device build .

Initialize the Repo client 

After installing the Repo launcher , set up your client to access the Android source code repository:

  1. Create an empty directory to hold your working files. Give it any name you like:

    mkdir WORKING_DIRECTORY
    cd WORKING_DIRECTORY
    
  2. Configure Git with your real name and email address. To use the Gerrit code review tool, you need an email address associated with a registered Google Account . Make sure this is a valid address where you can receive mail. The name you provide here will appear in the attribution information for the code you submit.

    git config --global user.name Your Name
    git config --global user.email [email protected]
    
  3. Run  repo init to get the latest version of the Repo with its latest bug fixes. The manifest file specifies where the various code libraries included in the Android source code will be placed in the working directory, and you must specify a URL for the manifest file.

    repo init at https://android.googlesource.com/platform/manifest
    

    To check out the master branch, run the following command:

    repo init -u https://android.googlesource.com/platform/manifest -b master
    

    To check out a branch other than master, specify  -b this branch with . See source tags and build for a list of branches .

    for Python 2

    WARNING : Support for Python 2 ended on January 1, 2020, see  Sunsetting Python 2 (Python 2 deprecation) for details. All major Linux distributions are stopping support for Python 2 packages. Google strongly recommends that you migrate all scripts to Python 3.

    Note : AOSP comes with its own copies of Python 2 and Python 3 packages, and you can use the versions included in the source tree (eg  SEPolicy ). Google is in the process of converting all scripts in the Android source tree to Python 3, and may discard embedded copies of Python 2.

    See Migrating Python 2 Code to Python 3  and Recommendations for Deprecating Your Python 2 Code for more details .

    for Python 3

    If you receive the " /usr/bin/env 'python' no such file or directory" error message, use one of the following solutions:

    If your Ubuntu 20.04.2 LTS is a fresh install (as opposed to an upgrade) of a Linux distribution:

    sudo ln -s /usr/bin/python3 /usr/bin/python

    If you're using Git 2.19 or later, you can  repo init specify at execution time  --partial- clone, which takes advantage of Git's partial cloning feature, downloading Git objects only when needed instead of everything. Since using partial cloning means that many operations must communicate with the server, if you are a developer and use a low-latency network, use the following command:

    repo init -u https://android.googlesource.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M
    

    Windows OS only: If you get an error message telling you that you cannot create a symlink (which will cause  repo init the run to fail), see the GitHub  symlink documentation to create a symlink, or enable support for symlinks. If you are not an administrator, see the section Allowing non-admins to create symbolic links .

After successful initialization, a message will appear telling you that Repo has finished initializing in your working directory. Your client directory now contains a  .repo directory, which is where files such as manifests live.

Download the Android source tree 

To download the Android source tree from the repository specified in the default manifest to the working directory, run the following command:

repo sync

For faster syncing, pass  -c(current branch) and  -jthreadcount tag:

repo sync -c -j8

The Android source code files are downloaded to the working directory under the corresponding project name.

To suppress output, pass  -q the (quiet) flag. See  the Repo command reference documentation for all options .

use authentication 

By default, access to the Android source code is anonymous. To prevent the server from being overused, each IP address has an associated quota.

Quotas may be triggered even in regular usage patterns when an IP address is shared with other users (for example, when accessing a source code repository across a NAT firewall), for example, when many users sync new Quotas may be triggered when the client.

In this case, you can use the access method that requires authentication. Such access uses a separate quota for each user, regardless of IP address.

First, generate a password using a password generator , then follow the instructions on the password generator page.

Next, use the manifest URI  https://android.googlesource.com/a/platform/manifest to enforce authenticated access. Note  /a/ how the directory prefix triggers mandatory authentication. You can convert an existing client to use mandatory authentication with the following command:

repo init at https://android.googlesource.com/a/platform/manifest

Troubleshoot network issues 

If you are downloading content using a proxy (common in some enterprise environments), you may need to explicitly specify which proxy the Repo will use:

export HTTP_PROXY=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port>
export HTTPS_PROXY=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port>

On a rare occasion, a Linux client has connection issues and gets stuck during a download (usually during "receiving objects"). It is recommended that you adjust the settings of the TCP/IP stack and use non-parallel commands, which can improve the situation. You must have root privileges to modify TCP settings:

sudo sysctl -w net.ipv4.tcp_window_scaling=0
repo sync -j1

Use a local mirror 

When you're working with multiple clients (especially if you're running low on bandwidth), it's best to create a local mirror of the entire contents of the server, and sync the clients from that mirror (no network access required). A full image is a smaller download than two clients and contains more information.

The following instructions assume the image was created in  /usr/local/aosp/mirror . First, the mirror itself is created and synchronized. Note  --mirror the flag, which can only be specified when creating a new client:

mkdir -p /usr/local/aosp/mirror
cd /usr/local/aosp/mirror
repo init -u https://android.googlesource.com/mirror/manifest --mirror
repo sync

Once the mirror is synchronized, you can create new clients from the mirror. Note that you must specify an absolute path:

mkdir -p /usr/local/aosp/master
cd /usr/local/aosp/master
repo init -u /usr/local/aosp/mirror/platform/manifest.git
repo sync

Finally, to sync the client with the server, sync the mirror with the server, and then sync the client with the mirror:

cd /usr/local/aosp/mirror
repo sync
cd /usr/local/aosp/master
repo sync

You can store the image on a LAN server and access it via NFS, SSH or Git. You can also store it on a removable memory drive and pass the drive between users or computers.

Validate Git tags 

Load the following public keys into your GnuPG key database. This key is used to sign annotated tags representing versions.

gpg --import

Copy and paste the key below, then type  EOF ( Ctrl-D ) to end typing and process the key.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciET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PUBLIC KEY BLOCK-----

After importing the key, you can verify any token with the following command:

git tag -v TAG_NAME

Get the proprietary binaries

You can't just use AOSP from pure source code, you also need to run other hardware-dependent proprietary libraries (such as proprietary libraries for hardware graphics acceleration). For download links to additional resources and device binaries , see the sections below.

Some devices pack these proprietary binaries into their  /vendor partitions.

Download proprietary binaries

For supported devices running a tagged branch of the AOSP release, you can  download the relevant official binaries from Google's drivers page. With these binaries, you will have access to more hardware features that are closed source. To build the master branch of AOSP, use the binary preview . When building the master branch for a device, use the binaries for the latest numbered version or binaries with the latest date.

Extract the proprietary binaries

Each set of binaries is a self-extracting script in a tarball. Unzip each tarball, run the included self-extracting script from the root of the source tree, and confirm that you agree to the terms of the accompanying license agreement. Binaries and their corresponding makefiles will be installed in the source tree  vendor/ hierarchy.

to clean up

To ensure that newly installed binaries are effectively adopted after unpacking, delete all existing output from previous builds with the following command:

make clobber

Guess you like

Origin blog.csdn.net/chanimei_11/article/details/124782366