android最新源码(4.4.2_r1版本以上)下载

来源:互联网 发布:java数据库连接池比较 编辑:程序博客网 时间:2024/05/26 17:47

来源:http://blog.csdn.net/zeroboundary/article/details/17555183

android最新源码(4.4.2_r1版本以上)下载

参考:http://source.android.com/source/downloading.html

红色字体表示多项选择中,我所做的选择

 

(我百度云盘地址:http://pan.baidu.com/s/1hqABuc8) 

 

安装curl工具

$       sudo apt-get install curl

 

git工具的安装(按照如下方式安装最新版)

增加ppa

$      sudo apt-add-repository ppa:git-core/ppa

$      sudo apt-get update

$      sudo apt-get install git

git的版本号就是最新的

$      git --version

git version 1.8.5.2

错误:sudo apt-add-repository ppa:git-core/ppa时出现错误:gpg: requesting keyE1DF1F24from hkp server keyserver.ubuntu.com / gpgkeys: HTTP fetch error 7: couldn't connect to host

原因:keyserver.ubuntu.com使用非标准的11371端口,而一般公司的防火墙都屏蔽掉了该端口,而允许标准的80端口。

所以可以以如下方式强行使用80端口添加软件源:

$       sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 E1DF1F24

绿色部分是你要请求的Key.

 

repo工具的下载

google是这样告诉我们的:

$       curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

$       chmod a+x ~/bin/repo

但是好像是不能访问

解决方法:http://code.google.com/p/git-repo/downloads/detail?name=repo-1.12这个链接提供下载repo

也可以通过下面命令得到:

$       curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo

我是用在http后面加了个s下载的1.20,居然可以,没有其他版本出的错误

$      curl https://commondatastorage.googleapis.com/git-repo-downloads/repo > ./repo

具体的repo版本可以去查看http://code.google.com/p/git-repo/downloads页面上的信息,下载那个版本都行。

修改执行权限

$       chmod a+x repo

 

repo init创建仓库

初始化android 源代码,下载最新代码

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

或者像这样取得某个分支如android-4.4.2_r1

$       ./repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.2_r1

如果需要下载其他分支将android-4.4.2_r1改成其他分支名称就可以了。分支名称请在https://android.googlesource.com/platform/manifest/+refs里面查看branch

 

执行repo sync 进行同步

$       ./repo sync

 

使用repo sync同步下载代码时因为网络原因可能会经常断线,可以使用下面的脚本来做个脚本文件,让它中断后,又自动下载

创建脚本download.sh

#!/bin/bash

echo "=========start repo sync=============="

./repo sync

while [ $? == 1 ]; do

echo "======sync failed, re-sync again======"

sleep 3

./repo sync

done

chomd a+x download.sh让其可以运,然后终端输入./download.sh就可以开始下载了,用这一步代替官方文档里的repo sync。当连接不上终端时休息3毫秒然后再自动repo sync

 

下载完成后,下一步就是编译了

 

补充:

对于我网盘下载的内容同步出源码的方法如下:

 

 

Usinga local mirror

When using several clients, especially in situationswhere bandwidth is scarce, it is better to create a local mirror of the entire servercontent, and to sync clients from that mirror (which requires no network access).The download for a full mirror is smaller than the download of two clients, whilecontaining more information.

These instructions assume that the mirror iscreated in /usr/local/aosp/mirror. The first step is to create and sync the mirroritself, which uses close to 13GB of network bandwidth and a similar amount of diskspace. Notice the --mirror flag, which can only be specified when creating a newclient:

$      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 the mirror:

$      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 a removabledrive and to pass that drive around between users or between machines.

 

 2. kernel下载
            内核的下载不需要repo这个工具,仅仅使用git的clone命令就可以了,不过一样面临地址被封需要绕过的问题。kernel代码大概600多M,比较小一点。
            $ git clone https://android.googlesource.com/kernel/common.git kernel
            命令行最后面的kernel的意思是保存在这个文件夹下,所以可以自行命名,系统会帮你创建出来的
            当然,还有其他的内核可以下载,从字面上看,msm应该是针对高通芯片的,omap是针对TI芯片的,samsung是针对三星芯片,tegra则是nVidia公司的芯片。
            $ git clone https://android.googlesource.com/kernel/goldfish.git
            $ git clone https://android.googlesource.com/kernel/msm.git
            $ git clone https://android.googlesource.com/kernel/omap.git
            $ git clone https://android.googlesource.com/kernel/samsung.git
            $ git clone https://android.googlesource.com/kernel/tegra.git


            下载完了之后可以用ls命令看一下,是不是kernel没看到任何代码?试着运行一下git的列出分支命令
            $ git branch -a,你会看到一系列分支,其中打*的分支是当前分支(刚下载完就是master啦),这个时候你切换一下分支,切换到你想要的分支代码就会出现了,我使用的是remotes/origin/android-2.6.39分支


            最后一点,如果需要代码和kernel同时下载,在./repo/manifests/default.xml文件中增加如下语句:
            <project path="kernel/common" name="kernel/common" revision="android-2.6.39"/>

0 0
原创粉丝点击