如何下载 Android 版谷歌源代码
如您所知,https://android.googlesource.com/ 中有数百个项目的列表。我想将它们全部下载到 Windows 机器中。根据 Google 的文档,
To install, initialize, and configure Repo:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
To clone the entire platform, install repo, and run:
mkdir mydroid
cd mydroid
repo init -u https://android.googlesource.com/platform/manifest
repo sync
然而,在我的机器中,我无法在 Git Bash 中“repo init”,因为它说它没有 python。我安装了 python,但 git bash 无法识别它。 请注意,我也将 python 目录设置为系统路径。如果有人可以提供提示,我将不胜感激。谢谢
更新:我相信这是新版本的 Windows 版 Git Bash 的问题。系统路径根本不适用于 Git Bash - 我可以轻松测试系统路径是否与命令提示符一起使用。不管怎样,我尝试了这个,当然它实际上运行时出错了。
/c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
错误信息
$ /c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
Traceback (most recent call last):
File "../bin/repo", line 91, in <module>
import readline
ImportError: No module named readline
正常。我通过在 Windows 中安装 pyreadline 来解决此错误:
easy_install pyreadline
如果出现错误,则必须从 安装 setuptools
http://pypi.python.org/pypi/setuptools#files
最后再次运行命令以获取此信息:
$ repo init -u https://android.googlesource.com/platform/manifest
fatal: unable to start d:\mywork\dev\GoogleAndroid\working_dir\.repo\repo/main.py
fatal: [Errno 8] Exec format error
As you know, there is a list of several hundred projects in https://android.googlesource.com/. I'd like to download them all in windows machine. According to Google's document,
To install, initialize, and configure Repo:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
To clone the entire platform, install repo, and run:
mkdir mydroid
cd mydroid
repo init -u https://android.googlesource.com/platform/manifest
repo sync
In my machine, however, I cannot "repo init" in Git Bash because it says it does not have python. I have python installed but git bash does not recognize it. Note that I set the python directory to the system path too. If anybody can give a tip, I would appreciate it. Thanks
UPDATE: I believe it's problem with new version of Git Bash for Windows. System path is not applied to Git Bash at all - I could easily test if system path worked with command prompt. Anyway, I tried this instead and it actually ran with error of course.
/c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
The error message is
$ /c/python27/python.exe ../bin/repo init -u https://android.googlesource.com/platform/manifest
Traceback (most recent call last):
File "../bin/repo", line 91, in <module>
import readline
ImportError: No module named readline
OK. I passed this error by installing pyreadline in windows:
easy_install pyreadline
If you got an error, you must install setuptools from
http://pypi.python.org/pypi/setuptools#files
And finally ran the command again to get this:
$ repo init -u https://android.googlesource.com/platform/manifest
fatal: unable to start d:\mywork\dev\GoogleAndroid\working_dir\.repo\repo/main.py
fatal: [Errno 8] Exec format error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过一键,从此处下载最新代码作为
.tar.gz
文件https://android.googlesource.com/platform/frameworks /base/+archive/master.tar.gz,android可以在
core
文件夹下找到编辑
替代方案在这里:
http://grepcode.com/project /repository.grepcode.com/java/ext/com.google.android/android/
只需选择版本,然后选择其中的下载选项。
With one click, download the latest code as
.tar.gz
file, from herehttps://android.googlesource.com/platform/frameworks/base/+archive/master.tar.gz, the android could be found under
core
folderEdit
Alternative here:
http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/
Just select the version then a download options within.
例如,如果您考虑这个其他程序“sympy” 它还需要 git bash 和 python,只需在启动 git bash 会话之前将 python 添加到您的 PATH 即可。
http://python.org/download/
请注意,repo 脚本本身必须位于路径中,如版本控制页面:
If you consider, as an example, this other program "sympy" which also needs git bash and python, it is only a matter to add python to your PATH prior to launching the git bash session.
http://python.org/download/
Note that the repo script itself must be in the path, as mentioned in the Version Control page of android:
这个答案解释了如何修复这个错误:
总结:我最终使用了Cygwin打包的
python
。详细信息:以下是完整的故事。
来自
repo
的提示bug跟踪是在v1.20中添加'/c/app/Python27/python'
:REPO_MAIN = '/c/app/Python27/python ' + S_repo + '/main.py'
main
的开头)wrapper_path = '/c/app/Python27/python ' + os.path.abspath(__file__)
但我们收到错误
TypeError: 强制转换为 Unicode: 需要字符串或缓冲区,未找到 NoneType< /code>
因此,我恢复了上面的这些更改,并执行了下面的其他更改(在版本 1.20 上):
REPO_MAIN = S_repo + '\\main.py'
python
绝对路径作为me
的第一个元素:me = ['C:\\app\\Python27\\python.exe', repo_main,
'--repo-dir=%s' % rel_repo_dir,
'--wrapper-version=%s' % ver_str,
'--wrapper-path=%s' %wrapper_path,
'--']
os.execv(repo_main, me)
替换为os.execv('C:\\app\\Python27\\python.exe', me)
但是我们仍然得到一个错误:
Python v2.7
fcntl
文档 说fcntl
是可用于平台仅限 Unix。我最终再次恢复了 repo 脚本中的所有更改,并安装了 Cygwin,包括它的 python 和 git 包:它成功了。
但是,由于 MSysGit 无法识别 Cygwin 模拟的符号链接,因此我们必须使用 Cygwingit
。而且git
之上的 GUI 并不完全符合 Cygwingit
...(另请参阅 我的其他帖子)
编辑:
Cygwin 可以使用本机 NTFS 符号链接(只需设置
CYGWIN=winsymlinks:native
并成为管理员)。因此可以使用 MSysGit 以及基于它的任何其他 GUI :-)This answer explains how to fix this error:
Summary: I finally used the
python
packaged by Cygwin.Details: Below is the full story.
The tip from the
repo
bug tracking is to add'/c/app/Python27/python '
:REPO_MAIN = '/c/app/Python27/python ' + S_repo + '/main.py'
main
)wrapper_path = '/c/app/Python27/python ' + os.path.abspath(__file__)
But we get the error
TypeError: coercing to Unicode: need string or buffer, NoneType found
Therefore I reverted these changes above and performed the other changes below (on version 1.20):
REPO_MAIN = S_repo + '\\main.py'
python
absolute path as first element ofme
:me = ['C:\\app\\Python27\\python.exe', repo_main,
'--repo-dir=%s' % rel_repo_dir,
'--wrapper-version=%s' % ver_str,
'--wrapper-path=%s' % wrapper_path,
'--']
os.execv(repo_main, me)
byos.execv('C:\\app\\Python27\\python.exe', me)
However we get still an error:
The Python v2.7
fcntl
documentation saysfcntl
is available for platform Unix only.I finally reverted again all changes in
repo
script and installed Cygwin including itspython
andgit
packages: it succeeded as a charm.But, as the symlinks simulated by Cygwin are not recognized by the MSysGit, we have to use the Cygwingit
. And GUIs on top ofgit
are not fully compliant with Cygwingit
...(see also my other post)
Edit:
Cygwin can use native NTFS symlinks (just set
CYGWIN=winsymlinks:native
and be Admin). Therefore MSysGit can be used and any other GUI based on it :-)