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?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中的單個項目,只要在項目目錄下執行簡單的?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才可以?,F在,得益于?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]#?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.
通過第三方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
總結
以上是生活随笔為你收集整理的Downloading Android Source Code的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jquery实现的3D缩略图悬停效果
- 下一篇: KMP算法详解 网络上转的。。。仰慕此人