|  | Copyright (C) 2009 The Android Open Source Project | 
|  |  | 
|  | Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | you may not use this file except in compliance with the License. | 
|  | You may obtain a copy of the License at | 
|  |  | 
|  | http://www.apache.org/licenses/LICENSE-2.0 | 
|  |  | 
|  | Unless required by applicable law or agreed to in writing, software | 
|  | distributed under the License is distributed on an "AS IS" BASIS, | 
|  | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | See the License for the specific language governing permissions and | 
|  | limitations under the License. | 
|  |  | 
|  |  | 
|  | Subject: How to get the android source code using Cygwin and Git | 
|  | Date:    2009/04/27 | 
|  | Updated: 2009/05/21 | 
|  | Updated: 2010/03/30 | 
|  |  | 
|  |  | 
|  | Table of content: | 
|  | 1- Goals and Requirements | 
|  | 2- Getting the code, the simple way | 
|  | 3- SSH issues | 
|  | 4- Advanced Tricks | 
|  |  | 
|  |  | 
|  | ------------------------- | 
|  | 1- Goals and Requirements | 
|  | ------------------------- | 
|  |  | 
|  | This document explains how to checkout the Android source from the git | 
|  | repositories under Windows. | 
|  |  | 
|  | As stated in development/docs/howto_build_SDK.txt, one can't build the whole | 
|  | Android source code under Windows. You can only build the SDK tools for | 
|  | Windows. | 
|  |  | 
|  | There are a number of caveats in checking out the code from Git under Windows. | 
|  | This document tries to explain them. | 
|  |  | 
|  | First you will need to meet the following requirements: | 
|  | - You must have Cygwin installed. But wait! You CANNOT use the latest Cygwin 1.7. | 
|  | Instead you MUST use the "legacy Cygwin 1.5" that you can find at this page: | 
|  |  | 
|  | http://cygwin.org/win-9x.html | 
|  |  | 
|  | Don't mind the page title, just grab setup-legacy.exe and it will works just fine | 
|  | under XP or Vista. | 
|  |  | 
|  | - You must install Cyginw using the "Unix / Binary" mode. | 
|  | If you don't do that, git will fail to properly compute some SHA1 keys. | 
|  |  | 
|  | - You need the "git" and "curl" packages to checkout the code. | 
|  | If you plan to contribute, you might want to get "gitk" also. | 
|  |  | 
|  | Note: if you want to build the SDK, check the howto_build_SDK.txt file | 
|  | for a list of extra required packages. | 
|  | The short summary is that you need at least these: | 
|  | autoconf, bison, curl, flex, gcc, g++, git, gnupg, make, mingw-zlib, python, unzip, zip | 
|  | and you must avoid the "readline" package. | 
|  |  | 
|  |  | 
|  | ----------------------------------- | 
|  | 2- Getting the code, the simple way | 
|  | ----------------------------------- | 
|  |  | 
|  | Out of the box, "repo" and "git" will work just fine under Cygwin: | 
|  |  | 
|  | $ repo init -u git://android.git.kernel.org/platform/manifest.git | 
|  | $ repo sync | 
|  |  | 
|  | And you're done. You can build as explained in howto_build_SDK.txt and ignore | 
|  | the rest of this document. | 
|  |  | 
|  |  | 
|  | ------------- | 
|  | 3- SSH issues | 
|  | ------------- | 
|  |  | 
|  | If you maintain your own private repository using an SSH server, you might get | 
|  | some "mux/ssh" errors. In this case try this: | 
|  |  | 
|  | $ repo init -u ssh://my.private.ssh.repo/platform/manifest.git | 
|  | $ export GIT_SSH=ssh | 
|  | $ repo sync | 
|  |  | 
|  |  | 
|  | ------------------ | 
|  | 4- Advanced Tricks | 
|  | ------------------ | 
|  |  | 
|  | There is one remaining issue with the default repo/git options: | 
|  |  | 
|  | If you plan on contributing, you will notice that even after a fresh "repo | 
|  | sync" some projects are marked as having modified files. This happens on the | 
|  | "bionic" and the "external/iptables" project. The issue is that they have files | 
|  | which have the same name yet differ only by their case-sensitivity. Since the | 
|  | Windows filesystem is not case-sensitive, this confuses Git. | 
|  |  | 
|  | Solution: we can simply ignore these projects as they are not needed to build | 
|  | the Windows SDK. | 
|  |  | 
|  | To do this you just need to create a file .repo/local_manifest.xml that | 
|  | provides a list of projects to ignore: | 
|  |  | 
|  | <?xml version="1.0" encoding="UTF-8"?> | 
|  | <manifest> | 
|  | <remove-project name="platform/external/iptables" /> | 
|  | </manifest> | 
|  |  | 
|  | The other thing we can do is tell git not to track the files that cause | 
|  | problems: | 
|  |  | 
|  | cd bionic | 
|  | git update-index --assume-unchanged \ | 
|  | libc/kernel/common/linux/netfilter/xt_CONNMARK.h \ | 
|  | libc/kernel/common/linux/netfilter/xt_MARK.h \ | 
|  | libc/kernel/common/linux/netfilter_ipv6/ip6t_HL.h | 
|  |  | 
|  | cd external/tcpdump; | 
|  | git update-index --assume-unchanged \ | 
|  | tests/print-X.new \ | 
|  | tests/print-XX.new | 
|  |  | 
|  |  | 
|  | Here's a script that takes care of all these details. It performs the repo | 
|  | init, creates the appropriate local_manifest.xml, does a repo sync as | 
|  | needed and tell git to ignore the offending files: | 
|  |  | 
|  | ------------ | 
|  | #!/bin/bash | 
|  |  | 
|  | set -e  # fail on errors | 
|  |  | 
|  | URL=ssh://android-git.corp.google.com:29418/platform/manifest.git | 
|  | BRANCH=donut | 
|  | if [ "$1" == "-b" ]; then shift; BRANCH=$1; shift; fi | 
|  |  | 
|  | # repo init if there's no .repo directory | 
|  | if [[ ! -d .repo ]]; then | 
|  | repo init -u $URL -b $BRANCH | 
|  | fi | 
|  |  | 
|  | # create a local_manifest to exclude projects that cause problems under Windows | 
|  | # due to the case-insenstivines of the file system. | 
|  | L=.repo/local_manifest.xml | 
|  | if [[ ! -f $L ]]; then | 
|  |  | 
|  | cat > $L <<EOF | 
|  | <?xml version="1.0" encoding="UTF-8"?> | 
|  | <manifest> | 
|  | <remove-project name="platform/external/iptables" /> | 
|  | </manifest> | 
|  | EOF | 
|  | fi | 
|  |  | 
|  | # sync using the native ssh client if necessary | 
|  | [[ $URL != ${URL/ssh/} ]] && export GIT_SSH=ssh | 
|  | repo sync $@ | 
|  |  | 
|  |  | 
|  | # These files cause trouble too, we need to ignore them | 
|  | (cd bionic; | 
|  | git update-index --assume-unchanged \ | 
|  | libc/kernel/common/linux/netfilter/xt_CONNMARK.h \ | 
|  | libc/kernel/common/linux/netfilter/xt_MARK.h \ | 
|  | libc/kernel/common/linux/netfilter_ipv6/ip6t_HL.h | 
|  | ) | 
|  | (cd external/tcpdump; | 
|  | git update-index --assume-unchanged \ | 
|  | tests/print-X.new \ | 
|  | tests/print-XX.new | 
|  | ) | 
|  | ------------ | 
|  |  | 
|  | Simply extract this to a "my_sync.sh" file and try the following: | 
|  | $ mkdir android_src | 
|  | $ cd android_src | 
|  | $ chmod +x mysync.sh | 
|  | $ ./mysync.sh | 
|  |  | 
|  |  | 
|  | -end- | 
|  |  | 
|  |  | 
|  |  | 
|  |  |