Downloading Android Source Code
| Git 是 Linux Torvalds 為了幫助管理 Linux 內(nèi)核開(kāi)發(fā)而開(kāi)發(fā)的一個(gè)開(kāi)放源碼的分布式版本控制軟件,它不同于Subversion、CVS這樣的集中式版本控制系統(tǒng)。在集中式版本控制系統(tǒng)中只有一個(gè)倉(cāng) 庫(kù)(repository),許多個(gè)工作目錄(working copy),而像Git這樣的分布式版本控制系統(tǒng)中(其他主要的分布式版本控制系統(tǒng)還有?BitKeeper?、?Mercurial?、?GNU Arch?、?Bazaar?、Darcs?、?SVK?、?Monotone?等),每一個(gè)工作目錄都包含一個(gè)完整倉(cāng)庫(kù),它們可以支持離線工作,本地提交可以稍后提交到服務(wù)器上。分布式系統(tǒng)理論上也比集中式的單服務(wù)器系統(tǒng)更健壯,單服務(wù)器系統(tǒng)一旦服務(wù)器出現(xiàn)問(wèn)題整個(gè)系統(tǒng)就不能運(yùn)行了,分布式系統(tǒng)通常不會(huì)因?yàn)橐粌蓚€(gè)節(jié)點(diǎn)而受到影響?。 因?yàn)锳ndroid是由kernel、Dalvik、Bionic、prebuilt、build等多個(gè)Git項(xiàng)目組成,所以Android項(xiàng)目編寫(xiě)了一個(gè)名為Repo的Python的腳本來(lái)統(tǒng)一管理這些項(xiàng)目的倉(cāng)庫(kù),使得Git的使用更加簡(jiǎn)單。 |
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?curl,?git?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中的單個(gè)項(xiàng)目,只要在項(xiàng)目目錄下執(zhí)行簡(jiǎn)單的?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.
如果需要某個(gè)branch的代碼,用git checkout即可。比如我們剛剛拿了kernel/common.get的代碼,那就先進(jìn)入到common目錄,然后用下面的命令:
git checkout origin/android-goldfish-2.6.27 -b goldfish?
這樣我們就在本地建立了一個(gè)名為goldfish的android-goldfish-2.6.27分支,代碼則已經(jīng)與android-goldgish-2.6.27同步。我們可以通過(guò)git branch來(lái)列出本地的所有分支。
C.
通過(guò)GitWeb下載代碼?
另外,如果只是需要主線上某個(gè)項(xiàng)目的代碼,也可以通過(guò)?GitWeb?下載,在shortlog利用關(guān)鍵字來(lái)搜索特定的版本,或者找?guī)讉€(gè)比較新的tag來(lái)下載還是很容易的。 Git最初是為L(zhǎng)inux內(nèi)核開(kāi)發(fā)而設(shè)計(jì),所以對(duì)其他平臺(tái)的支持并不好,尤其是Windows平臺(tái),必須要有Cygwin才可以。現(xiàn)在,得益于?msysgit?項(xiàng)目,我們已經(jīng)可以不需要Cygwin而使用Git了。另外,?Git Extensions?是一個(gè)非常好用的Windows Shell擴(kuò)展,它能與資源管理器緊密集成,甚至提供了Visual Studio插件。它的官方網(wǎng)站上有一分不錯(cuò)的?說(shuō)明文檔?,感興趣的朋友可以看一看。 至于Git的參考文檔,我推薦?Git Magic?,這里還有一個(gè)?Git Magic的中文版?。 獲取Anroid Linux Kernel過(guò)程: [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 這里會(huì)下載半天,下載完成之后: [root@localhost src]#?cd common [root@localhost common]#?lsarch ??? 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.
通過(guò)第三方repo下載代碼?
在獲取 Android 源碼的第一步,就是需要獲得 Git 和 Repo,在獲得 “repo” 的時(shí)候,就需要到 “kernel.org” 獲取:
curl http://android.git.kernel.org/repo >~/bin/repo
基于種種原因,你是無(wú)法同步的,會(huì)提示:
% 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即使你之前已經(jīng)獲取了 “repo”,而你在同步 Android 源碼時(shí)候也會(huì)提示:
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故本文這里就使用另外源,來(lái)取得 Android 源碼。
一、獲取 repo
這個(gè)是老外自己建立的,使用這個(gè)源可以獲得 repo,但是后續(xù)的源碼也是使用老外自己建立的。首先獲取 repo:
curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo
給 “repo” 增加相應(yīng)權(quán)限:chmod a+x ~/bin/repo
添加環(huán)境變量:PATH=~/bin:$PATH
這樣就獲取了第三方的 repo。
二、同步 Android 源碼
同樣是使用老外自己的源,首先進(jìn)入工作目錄:cd ~/android/system/
repo init -u git://codeaurora.org/platform/manifest.git可以查看所有分支
同步源碼:repo init -u git://codeaurora.org/platform/manifest.git -b gingerbread
查看分支時(shí)注意只有[New Branch]的才可以下載,[New Tag]的無(wú)法下載。
開(kāi)始同步:repo sync
這個(gè)是第三方的源碼,不知道其中會(huì)不會(huì)有什么問(wèn)題,我自己也同步了。請(qǐng)大家自己斟酌,這里僅僅是提供一種方法。
?For Detail:http://source.android.com/source/downloading.html
轉(zhuǎn)載于:https://www.cnblogs.com/qiengo/archive/2012/07/19/2598764.html
總結(jié)
以上是生活随笔為你收集整理的Downloading Android Source Code的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: jquery实现的3D缩略图悬停效果
- 下一篇: Android之Menu动态改变文字