Downloading Android Source Code

Git 是 Linux Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的分布式版本控制软件,它不同于Subversion、CVS这样的集中式版本控制系统。在集中式版本控制系统中只有一个仓 库(repository),许多个工作目录(working copy),而像Git这样的分布式版本控制系统中(其他主要的分布式版本控制系统还有 BitKeeper 、 Mercurial 、 GNU Arch 、 Bazaar 、Darcs 、 SVK 、 Monotone 等),每一个工作目录都包含一个完整仓库,它们可以支持离线工作,本地提交可以稍后提交到服务器上。分布式系统理论上也比集中式的单服务器系统更健壮,单服务器系统一旦服务器出现问题整个系统就不能运行了,分布式系统通常不会因为一两个节点而受到影响 。
因为Android是由kernel、Dalvik、Bionic、prebuilt、build等多个Git项目组成,所以Android项目编写了一个名为Repo的Python的脚本来统一管理这些项目的仓库,使得Git的使用更加简单。

From the detail of android Git repositories,see https://android.googlesource.com/

 

A.

1.Install GIT.

  Download and install GIT for your development system. GIT 1.7.11.2 for Windows.

2.Install Repo.

  Google Official Doc:http://source.android.com/source/downloading.html

  Download and setup the repo tool, as described on the Android open source project site.

  Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Version Control.]

  Note: Developers using Windows must use a Linux compatibility package, such as cygwin, to install and run repo. Within your compatibility environment, you must install curlgit and python to be able to download and use the repo tool.

  To install:first ensure the bin folder in your current user's root directory(Create it if none.If you don't know where to create bin folder,you can try cd ~/bin and check the hint.my is c/User/aa/bin),then add (~/bin) to the PATH environment variables,download Repo by curl and save it to ~/bin/repo.

  curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

You can also download it manually,and put it in the  appointed folder.Just need to open the address in browser 
https://dl-ssl.google.com/dl/googlesource/git-repo/repo.
If the link if out of date,go to google official site to update it.(http://source.android.com/source/downloading.html)
Ensure it has executable access:
  chmod a+x ~/bin/repo

  

 3.Initialize Repository.

 If you want the lastest main source code,you need repo.Create a directory first,for example,~/android,enter and repo init.

  repo init -u git://android.git.kernel.org/platform/manifest.git 

 If you want a branch instead of main,you need -b to specify the branch name:

  repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake 

    repo init -u http://android.git.kernel.org/platform/manifest.git -b cupcake 

 Use git branch to list all the branch.

 However,an error occurs when I use it:

  

 It need the python interpreter.Now I run it in Git Bash.I switch to Cygwin Terminal and add a new environment variable C:\Users\aa\bin.Then it works well.

  

  unable to connect to android.git.kernel.org may also occurs.It is because there are too many servers which provider downloads at port:80.You need to replace the git with http:

  

 It may takes a long time,depends on you internet.You will see  repo initialized in /android at last.

  

 About the email and name ,you can set it by:

git config --global user.email "[email=xxxxx@xxxxxxx]xxxxx@xxxxxxx[/email]"
git config --global user.name "xxxxxx"

4.Synchronization(download)

 Modify file .repo/manifests/default.xml,replace the fetch="git://android.git.kernel.org/"  with fetch="http://android.git.kernel.org/".(I skip this step.)

 repo sync

 repo sync project1 project2 …

 如果是同步Android中的单个项目,只要在项目目录下执行简单的 git pull  即可。

B.

If you just need the code of some project,like kernel/common. Use Git directly。

  git clone git://android.git.kernel.org/kernel/common.git 
In the consideration of the whole download of Linux Kernel,it may take a long time also.

如果需要某个branch的代码,用git checkout即可。比如我们刚刚拿了kernel/common.get的代码,那就先进入到common目录,然后用下面的命令:
  git checkout origin/android-goldfish-2.6.27 -b goldfish 
这样我们就在本地建立了一个名为goldfish的android-goldfish-2.6.27分支,代码则已经与android-goldgish-2.6.27同步。我们可以通过git branch来列出本地的所有分支。

C.

通过GitWeb下载代码 

另外,如果只是需要主线上某个项目的代码,也可以通过 GitWeb 下载,在shortlog利用关键字来搜索特定的版本,或者找几个比较新的tag来下载还是很容易的。
Git最初是为Linux内核开发而设计,所以对其他平台的支持并不好,尤其是Windows平台,必须要有Cygwin才可以。现在,得益于 msysgit 项目,我们已经可以不需要Cygwin而使用Git了。另外, Git Extensions 是一个非常好用的Windows Shell扩展,它能与资源管理器紧密集成,甚至提供了Visual Studio插件。它的官方网站上有一分不错的 说明文档 ,感兴趣的朋友可以看一看。
至于Git的参考文档,我推荐 Git Magic ,这里还有一个 Git Magic的中文版 。
获取Anroid Linux Kernel过程:
[root@localhost ~]# mkdir bin
[root@localhost ~]# curl http://android.git.kernel.org/repo >~/bin/repo
[root@localhost bin]# cd bin/
[root@localhost bin]# chmod a+x ~/bin/repo
[root@localhost bin]# cd /usr/local/src/
[root@localhost src]# mkdir project-android
[root@localhost src]# cd project-android/
[root@localhost project-android]# git clone git://android.git.kernel.org/kernel/common.git
这里会下载半天,下载完成之后:
[root@localhost src]# cd common
[root@localhost common]# ls
arch     CREDITS        drivers   include Kbuild MAINTAINERS net             samples   sound
block    crypto         firmware init     kernel Makefile     README          scripts   usr
COPYING Documentation fs        ipc      lib     mm           REPORTING-BUGS security virt 
[root@localhost common]# git branch -a
* android-2.6.27
diff
remotes/origin/HEAD -> origin/android-2.6.27 
remotes/origin/android-2.6.25
remotes/origin/android-2.6.27
remotes/origin/android-2.6.29
remotes/origin/android-goldfish-2.6.27
remotes/origin/android-goldfish-2.6.29

D.

通过第三方repo下载代码 

在获取 Android 源码的第一步,就是需要获得 Git 和 Repo,在获得 “repo” 的时候,就需要到 “kernel.org” 获取:

curl http://android.git.kernel.org/repo >~/bin/repo

基于种种原因,你是无法同步的,会提示:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (7) couldn't connect to host

即使你之前已经获取了 “repo”,而你在同步 Android 源码时候也会提示:

android.git.kernel.org[0: 130.239.17.13]: errno=Connection refused
android.git.kernel.org[0: 199.6.1.173]: errno=Connection refused
android.git.kernel.org[0: 2001:6b0:e:4017:1972:112:1:0]: errno=Network is unreachable
android.git.kernel.org[0: 2001:500:60:10:1972:112:1:0]: errno=Network is unreachable
fatal: unable to connect a socket (Network is unreachable)
error: Cannot fetch platform/bionic

故本文这里就使用另外源,来取得 Android 源码。

一、获取 repo

  这个是老外自己建立的,使用这个源可以获得 repo,但是后续的源码也是使用老外自己建立的。首先获取 repo:

  curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo

  给 “repo” 增加相应权限:chmod a+x ~/bin/repo

  添加环境变量:PATH=~/bin:$PATH

  这样就获取了第三方的 repo。

二、同步 Android 源码

  同样是使用老外自己的源,首先进入工作目录:cd ~/android/system/

  repo init -u git://codeaurora.org/platform/manifest.git可以查看所有分支

  同步源码:repo init -u git://codeaurora.org/platform/manifest.git -b gingerbread

    查看分支时注意只有[New Branch]的才可以下载,[New Tag]的无法下载。

  开始同步:repo sync

  这个是第三方的源码,不知道其中会不会有什么问题,我自己也同步了。请大家自己斟酌,这里仅仅是提供一种方法。

 For Detail:http://source.android.com/source/downloading.html

转载于:https://www.cnblogs.com/qiengo/archive/2012/07/19/2598764.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/260620.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

javascript是一门多线程的语言_Javascript:10天设计一门语言

演进和使用的JavaScript是早在1995年开发的一种语言,真的是刚刚起步。网景公司在1995年四月聘请Brendan Eich ,他被告知,他有10天时间创造并制作了一种将在Netscape的浏览器中运行,以原型为工作方式的编程语言。那时候&#xff0c…

第5章 Python 数字图像处理(DIP) - 图像复原与重建6 - 椒盐噪声

标题椒盐噪声椒盐噪声 如果kkk是一幅数字图像中表示灰度值的比特数,则灰度值可能是[0,2k−1][0, 2^k -1][0,2k−1]。椒盐噪声的PDF为: P(z){Ps,z2k−1Pp,z01−(PsPp),zV(5.16)P(z) \begin{cases} P_s, & z 2^k -1 \\ P_p, & z0 \\ 1-(P_s P_…

python if elif else_Python3使用独立的if语句与使用if-elif-else结构的不同之处

Python3使用独立的if语句与使用if-elif-else结构的不同之处 if-eliff-else结构功能强大,但是仅适合用于只有一个条件满足的情况:遇到通过了的测试后,Python就跳过余下的测试。 然而,有时候必须检查你关心的所有条件。在这种情况下…

算法导论读书笔记(8)

算法导论读书笔记(8) 目录 计数排序 计数排序的简单Java实现基数排序 基数排序的简单Java实现桶排序计数排序 计数排序 假设 n 个输入元素中的每一个都是介于0到 k 之间的整数,此处 k 为某个整数。当 k O ( n )时,计数排序的运行…

Keras 深度学习框架中文文档

2019独角兽企业重金招聘Python工程师标准>>> Keras深度学习框架中文文档 Keras官网:http://keras.io/Github项目:https://github.com/fchollet/keras中文文档主页:http://keras-cn.readthedocs.io/en/latest/Github中文文档&#…

KMP算法详解 网络上转的。。。仰慕此人

原网址http://www.matrix67.com/blog/archives/115 如果机房马上要关门了,或者你急着要和MM约会,请直接跳到第六个自然段。 我们这里说的KMP不是拿来放电影的(虽然我很喜欢这个软件),而是一种算法。KMP算法是拿来处…

求一个二维数组外围元素之和_C++数组作为函数的参数(学习笔记:第6章 04)...

数组作为函数的参数[1]数组元素作实参,与单个变量一样。数组名作参数,形、实参数都应是数组名(实质上是地址,关于地址详见后续章节),类型要一样,传送的是数组首地址。对形参数组的改变会直接影响…

android p wifi一直在扫描_Android再次解读萤石云视频

点击上方蓝字关注 ??前言我之前写过一篇萤石云的集成文章,很多人问我有没有demo, 今天我再次总结一下, 并加个些功能。集成步骤视频预览播放视频放大缩小视频的质量切换截图之前的文章大家可以看下面的链接:https://mp.weixin.q…

第5章 Python 数字图像处理(DIP) - 图像复原与重建7 - 周期噪声 余弦噪声生成方法

标题周期噪声周期噪声 周期噪声通常是在获取图像期间由电气或机电干扰产生的 def add_sin_noise(img, scale1, angle0):"""add sin noise for imageparam: img: input image, 1 channel, dtypeuint8param: scale: sin scaler, smaller than 1, will enlarge, …

python写文字方法_Transcrypt: 用Python写js的方法

Transcrypt是一个很有意思的工具: 它让你告别手写繁复的JavaScript代码,使用相对简明清晰的Python代替这一工作。 之后使用这个工具,可以把Python编写的代码转换成JavaScript。 1. 为什么不直接写JavsScript? JavaScript本身不算是很难的编程…

第5章 Python 数字图像处理(DIP) - 图像复原与重建8 - 估计噪声参数

标题估计噪声参数估计噪声参数 周期噪声的参数通常是通过检测图像的傅里叶谱来估计的。 只能使用由传感器生成的图像时,可由一小片恒定的背景灰度来估计PDF的参数。 来自图像条带的数据的最简单用途是,计算灰度级的均值和方差。考虑由SSS表示的一个条…

python 随机获取数组元素_Python创建二维数组的正确姿势

List (列表)是 Python 中最基本的数据结构。在用法上,它有点类似数组,因为每个列表都有一个下标,下标从 0 开始。因此,我们可以使用 list[1] 来获取下标对应的值。如果我们深入下列表的底层原理&#xff0c…

Qt学习笔记1

1.Qt引用API时,QString到LPCWSTR的转换: ::GetPrivateProfileIntW(QString(tr("相关设置")).utf16(),QString(tr("时间间隔")).utf16(),5,filePath.utf16())); 2.引用LPRECT时: RECTappRect; ::GetWindowRect(AppWnd,(LP…

在ubunut下使用pycharm和eclipse进行python远程调试

我比较喜欢Pycharm,因为这个是JetBrains公司出的python IDE工具,该公司下的java IDE工具——IDEA,无论从界面还是操作上都甩eclipse几条街,但项目组里有些人使用eclipse比较久了,一时让他们转pycharm比较困难&#xff…

CSS:页脚紧贴底部

2019独角兽企业重金招聘Python工程师标准>>> 我的练习来源于《CSS揭秘》这本书第7章-41紧贴底部的页脚这部分内容以及书中提到的链接。 方案一 描述:以下方案简单、干净、现代并且没有hack,适用于IE8, Chrome, Firefox, Opera等浏览器&#x…

第5章 Python 数字图像处理(DIP) - 图像复原与重建9 - 空间滤波 - 均值滤波器 - 算术平均、几何平均、谐波平均、反谐波平均滤波器

标题只存在噪声的复原 - 空间滤波均值滤波器算术平均滤波器几何均值滤波器谐波平均滤波器反(逆)谐波平均滤波器只存在噪声的复原 - 空间滤波 仅被加性噪声退化 g(x,y)f(x,y)η(x,y)(5.21)g(x, y) f(x, y) \eta(x, y) \tag{5.21}g(x,y)f(x,y)η(x,y)(5…

librosa能量_librosa与python_speech_features

在语音识别领域,比较常用的两个模块就是librosa和python_speech_features了。最近也是在做音乐方向的项目,借此做一下笔记,并记录一些两者的差别。下面是两模块的官方文档LibROSA - librosa 0.6.3 documentation​librosa.github.ioWelcome t…

java Unicode转码

1 //中文转UNICODE2 public static String chinaToUnicode(String str) {3 String result "";4 for (int i 0; i < str.length(); i) {5 int chr1 (char) str.charAt(i);6 if (chr1 > 19968 && ch…

oracle-备份工具exp-imp

虽然是按照用户的方式导出的&#xff0c;但导入之前&#xff0c;还是必须要有相同的用户存在&#xff0c;删除用户以后&#xff0c;是无法进行导入的 --重新创建回zlm用户 SQL> create user zlm identified by zlm; 尽管zlm用户的默认表空间是USERS&#xff0c;但是用imp导入…

继承String?

不能继承&#xff0c;因为 public final class String extends Objectimplements Serializable, Comparable<String>, CharSequence final修饰的类是不能被继承的转载于:https://www.cnblogs.com/crane-practice/p/3666006.html