如何下载 Android 版谷歌源代码

发布于 2024-11-29 15:16:25 字数 1605 浏览 0 评论 0原文

如您所知,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无悔心 2024-12-06 15:16:25

通过一键,从此处下载最新代码作为 .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 here
https://android.googlesource.com/platform/frameworks/base/+archive/master.tar.gz, the android could be found under core folder

Edit
Alternative here:
http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/

Just select the version then a download options within.

愛放△進行李 2024-12-06 15:16:25

例如,如果您考虑这个其他程序“sympy” 它还需要 git bash 和 python,只需在启动 git bash 会话之前将 python 添加到您的 PATH 即可。

安装Python:

http://python.org/download/

下载“Python 2.7 Windows 安装程序”(或 Python 2.6 或 2.5)并运行它。
将python目录添加到系统环境路径变量
我的电脑 -> 高级 -> 环境变量 -> 路径 -> 编辑)。

请注意,repo 脚本本身必须位于路径中,如版本控制页面:

Repo 是我们在 Git 之上构建的存储库管理工具。 Repo 在必要时统一了许多 Git 存储库,上传到我们的修订控制系统,并自动化部分 Android 开发工作流程。
Repo 并不是要取代 Git,只是为了让在 Android 环境中更轻松地使用 Git。
repo 命令是一个可执行的 Python 脚本,您可以将其放在路径中的任何位置

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.

Install Python from:

http://python.org/download/

by downloading the "Python 2.7 Windows installer" (or Python 2.6 or 2.5) and running it.
Add python directory to your system environment path variable
(My Computer -> Advanced -> Environment Variables -> Path -> Edit).

Note that the repo script itself must be in the path, as mentioned in the Version Control page of android:

Repo is a repository management tool that we built on top of Git. Repo unifies the many Git repositories when necessary, does the uploads to our revision control system, and automates parts of the Android development workflow.
Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android.
The repo command is an executable Python script that you can put anywhere in your path.

蓝眸 2024-12-06 15:16:25

这个答案解释了如何修复这个错误:

fatal: unable to start c:\path\.repo\repo/main.py
fatal: [Errno 8] Exec format error

总结:我最终使用了Cygwin打包的python
详细信息:以下是完整的故事。

来自 repo 的提示bug跟踪是在v1.20中添加'/c/app/Python27/python':

  • line 136
    REPO_MAIN = '/c/app/Python27/python ' + S_repo + '/main.py'
  • v1.20 中的第 735 行(函数 main 的开头)
    wrapper_path = '/c/app/Python27/python ' + os.path.abspath(__file__)

但我们收到错误 TypeError: 强制转换为 Unicode: 需要字符串或缓冲区,未找到 NoneType< /code>

因此,我恢复了上面的这些更改,并执行了下面的其他更改(在版本 1.20 上):

  • 第 136 行,用双反斜杠替换了单斜杠:
    REPO_MAIN = S_repo + '\\main.py'
  • 第 766 行,添加 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,
    '--']
  • 第 776 行,将 os.execv(repo_main, me) 替换为
    os.execv('C:\\app\\Python27\\python.exe', me)

但是我们仍然得到一个错误:

$ Traceback (most recent call last):
  File "c:\path\.repo\repo\main.py", line 39, in <module>
    from subcmds.version import Version
  File "c:\path\.repo\repo\subcmds\__init__.py", line 36, in <module>
    ['%s' % name])
  File "c:\path\.repo\repo\subcmds\forall.py", line 17, in <module>
    import fcntl
ImportError: No module named fcntl

Python v2.7 fcntl 文档fcntl 是可用于平台仅限 Unix。

我最终再次恢复了 repo 脚本中的所有更改,并安装了 Cygwin,包括它的 python 和 git 包:它成功了。

但是,由于 MSysGit 无法识别 Cygwin 模拟的符号链接,因此我们必须使用 Cygwin git。而且 git 之上的 GUI 并不完全符合 Cygwin git...

(另请参阅 我的其他帖子)

编辑:
Cygwin 可以使用本机 NTFS 符号链接(只需设置 CYGWIN=winsymlinks:native 并成为管理员)。因此可以使用 MSysGit 以及基于它的任何其他 GUI :-)

This answer explains how to fix this error:

fatal: unable to start c:\path\.repo\repo/main.py
fatal: [Errno 8] Exec format 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 ':

  • line 136 in v1.20
    REPO_MAIN = '/c/app/Python27/python ' + S_repo + '/main.py'
  • line 735 in v1.20 (beginning of function 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):

  • line 136, replaced single slash by double back-slash:
    REPO_MAIN = S_repo + '\\main.py'
  • line 766, added python absolute path as first element of 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,
    '--']
  • line 776, replaced os.execv(repo_main, me) by
    os.execv('C:\\app\\Python27\\python.exe', me)

However we get still an error:

$ Traceback (most recent call last):
  File "c:\path\.repo\repo\main.py", line 39, in <module>
    from subcmds.version import Version
  File "c:\path\.repo\repo\subcmds\__init__.py", line 36, in <module>
    ['%s' % name])
  File "c:\path\.repo\repo\subcmds\forall.py", line 17, in <module>
    import fcntl
ImportError: No module named fcntl

The Python v2.7 fcntl documentation says fcntl is available for platform Unix only.

I finally reverted again all changes in repo script and installed Cygwin including its python and git packages: it succeeded as a charm.

But, as the symlinks simulated by Cygwin are not recognized by the MSysGit, we have to use the Cygwin git. And GUIs on top of git are not fully compliant with Cygwin git...

(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 :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文