问题
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
回答1:
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.
回答2:
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.
回答3:
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 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,
'--']
- line 776, replaced
os.execv(repo_main, me)
byos.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 :-)
来源:https://stackoverflow.com/questions/7047902/how-to-download-google-source-code-for-android