To install Repo:
1.
Makesure you have a bin/ directory in your home directory and that it is includedin your path:
2.
$ mkdir ~/bin $ PATH=~/bin:$PATH
3.
4.
Downloadthe Repo tool and ensure that it is executable:
5.
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo
error:
you can try:curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" >~/bin/repo
6.
For version 1.17, the SHA-1 checksum for repois ddd79b6d5a7807e911b524cb223bc3544b661c28
For version 1.19, the SHA-1 checksum for repois 92cbad8c880f697b58ed83e348d06619f8098e6c
For version 1.20, the SHA-1 checksum for repois e197cb48ff4ddda4d11f23940d316e323b29671c
For version 1.21, the SHA-1 checksum for repois b8bd1804f432ecf1bab730949c82b93b0fc5fede
For version 1.22, the SHA-1 checksum for repois da0514e484f74648a890c0467d61ca415379f791
Initializinga Repo client
After installing Repo, set up your client toaccess the Android source repository:
1.
Createan empty directory to hold your working files. If you're using MacOS, this hasto be on a case-sensitive filesystem. Give it any name you like:
2.
$ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY
3.
4.
Run repo init
to bring down the latest versionof Repo with all its most recent bug fixes. You must specify a URL for themanifest, which specifies where the various repositories included in theAndroid source will be placed within your working directory.
5.
$ repo init -u https://android.googlesource.com/platform/manifest
errer:
fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable
you can try:
1, 先按官网的步骤一步步执行
2,当遇到上述问题后,用浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录;
3, 点击网页上的“允许访问”,得到类似的结果:
machine android.googlesource.com login git-<userName>.gmail.com password <password> machine android-review.googlesource.com login git-<userName>.gmail.com password <password>
将上边的两行追加到~/.netrc文件结尾。(如果你的linux系统中从来没有建立过此文件,就在home目录下建立.netrc文件,将上面的信息加到新建的文件中去),
4,下载地址的URI更改为https://android.googlesource.com/a/platform/manifest(中间加上了“/a”)。
因为访问基本是匿名的,为了防止连接过多,对同一IP地址的连接数做了一定的限制。用gmail帐号进行认证。
在公司网络内或者用虚拟机下载的话,会经常遇到这问题。
6.
7.
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
8.
9.
Whenprompted, configure Repo with your real name and email address. To use theGerrit code-review tool, you will need an email address that is connected witha registered Googleaccount. Make sure this is a live address atwhich you can receive messages. The name that you provide here will show up inattributions for your code submissions.
10.
A successful initialization will end with amessage stating that Repo is initialized in your working directory. Your clientdirectory should now contain a .repo
directorywhere files such as the manifest will be kept.
Downloadingthe Android Source Tree
To pull down the Android source tree to yourworking directory from the repositories as specified in the default manifest,run
$ repo sync
error:
fatal: '../platform/abi/cpp.git' does not appear to be a git repository fatal: Could not read from remote repository.
You can try:
打开.repo目录下的manifest.xml文件(命令vim manifest.xml)并找到fetch属性,在我的文件中显示fetch="..",将fetch修改为fetch="git://Android.git.linaro.org/",保存并退出
The Android source files will be located inyour working directory under their project names. The initial sync operationwill take an hour or more to complete. For more about repo sync
and other Repo commands, seethe Developing section.
UsingAuthentication
By default, access to the Android source codeis anonymous. To protect the servers against excessive usage, each IP addressis associated with a quota.
When sharing an IP address with other users(e.g. when accessing the source repositories from beyond a NAT firewall), thequotas can trigger even for regular usage patterns (e.g. if many users sync newclients from the same IP address within a short period).
In that case, it is possible to useauthenticated access, which then uses a separate quota for each user,regardless of the IP address.
The first step is to create a passwordwith the password generator andfollow the instructions on the password generator page.
The second step is to force authenticatedaccess, by using the following manifest URI:https://android.googlesource.com/a/platform/manifest
.Notice how the /a/
directoryprefix triggers mandatory authentication. You can convert an existing client touse mandatory authentication with the following command:
$ repo init -u https://android.googlesource.com/a/platform/manifest
Troubleshootingnetwork issues
When downloading from behind a proxy (which iscommon in some corporate environments), it might be necessary to explicitlyspecify the proxy that is then used by repo:
$ 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>
More rarely, Linux clients experienceconnectivity issues, getting stuck in the middle of downloads (typically during"Receiving objects"). It has been reported that tweaking the settingsof the TCP/IP stack and using non-parallel commands can improve the situation.You need root access to modify the TCP setting:
$ sudo sysctl -w net.ipv4.tcp_window_scaling=0 $ repo sync -j1
Usinga local mirror
When using several clients, especially insituations where bandwidth is scarce, it is better to create a local mirror ofthe entire server content, and to sync clients from that mirror (which requiresno network access). The download for a full mirror is smaller than the downloadof two clients, while containing more information.
These instructions assume that the mirror iscreated in /usr/local/aosp/mirror
.The first step is to create and sync the mirror itself. Notice the --mirror
flag, which can be specified onlywhen 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 synced, new clients can becreated from it. Note that it's important to 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 a client against the server,the mirror needs to be synced against the server, then the client against themirror:
$ cd /usr/local/aosp/mirror $ repo sync $ cd /usr/local/aosp/master $ repo sync
It's possible to store the mirror on a LAN serverand to access it over NFS, SSH or Git. It's also possible to store it on aremovable drive and to pass that drive around between users or betweenmachines.
else
Only dowload kernel:
git clone https://android.googlesource.com/kernel/msm
git branch -a
我们选择使用的android5.1 ,所以
git checkout remotes/origin/android-msm-shamu-3.10-lollipop-mr1