• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Copyright (C) 2009 The Android Open Source Project
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7     http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14
15
16Subject: How to get the android source code using Cygwin and Git
17Date:    2009/04/27
18Updated: 2009/05/21
19Updated: 2010/03/30
20
21
22Table of content:
23  1- Goals and Requirements
24  2- Getting the code, the simple way
25  3- SSH issues
26  4- Advanced Tricks
27
28
29-------------------------
301- Goals and Requirements
31-------------------------
32
33This document explains how to checkout the Android source from the git
34repositories under Windows.
35
36As stated in development/docs/howto_build_SDK.txt, one can't build the whole
37Android source code under Windows. You can only build the SDK tools for
38Windows.
39
40There are a number of caveats in checking out the code from Git under Windows.
41This document tries to explain them.
42
43First you will need to meet the following requirements:
44- You must have Cygwin installed. But wait! You CANNOT use the latest Cygwin 1.7.
45  Instead you MUST use the "legacy Cygwin 1.5" that you can find at this page:
46
47    http://cygwin.org/win-9x.html
48
49  Don't mind the page title, just grab setup-legacy.exe and it will works just fine
50  under XP or Vista.
51
52- You must install Cyginw using the "Unix / Binary" mode.
53  If you don't do that, git will fail to properly compute some SHA1 keys.
54
55- You need the "git" and "curl" packages to checkout the code.
56  If you plan to contribute, you might want to get "gitk" also.
57
58  Note: if you want to build the SDK, check the howto_build_SDK.txt file
59  for a list of extra required packages.
60  The short summary is that you need at least these:
61    autoconf, bison, curl, flex, gcc, g++, git, gnupg, make, mingw-zlib, python, unzip, zip
62  and you must avoid the "readline" package.
63
64
65-----------------------------------
662- Getting the code, the simple way
67-----------------------------------
68
69Out of the box, "repo" and "git" will work just fine under Cygwin:
70
71  $ repo init -u git://android.git.kernel.org/platform/manifest.git
72  $ repo sync
73
74And you're done. You can build as explained in howto_build_SDK.txt and ignore
75the rest of this document.
76
77
78-------------
793- SSH issues
80-------------
81
82If you maintain your own private repository using an SSH server, you might get
83some "mux/ssh" errors. In this case try this:
84
85  $ repo init -u ssh://my.private.ssh.repo/platform/manifest.git
86  $ export GIT_SSH=ssh
87  $ repo sync
88
89
90------------------
914- Advanced Tricks
92------------------
93
94There is one remaining issue with the default repo/git options:
95
96If you plan on contributing, you will notice that even after a fresh "repo
97sync" some projects are marked as having modified files. This happens on the
98"bionic" and the "external/iptables" project. The issue is that they have files
99which have the same name yet differ only by their case-sensitivity. Since the
100Windows filesystem is not case-sensitive, this confuses Git.
101
102Solution: we can simply ignore these projects as they are not needed to build
103the Windows SDK.
104
105To do this you just need to create a file .repo/local_manifest.xml that
106provides a list of projects to ignore:
107
108<?xml version="1.0" encoding="UTF-8"?>
109<manifest>
110  <remove-project name="platform/external/iptables" />
111</manifest>
112
113The other thing we can do is tell git not to track the files that cause
114problems:
115
116  cd bionic
117  git update-index --assume-unchanged \
118    libc/kernel/common/linux/netfilter/xt_CONNMARK.h \
119    libc/kernel/common/linux/netfilter/xt_MARK.h \
120    libc/kernel/common/linux/netfilter_ipv6/ip6t_HL.h
121
122  cd external/tcpdump;
123  git update-index --assume-unchanged \
124    tests/print-X.new \
125    tests/print-XX.new
126
127
128Here's a script that takes care of all these details. It performs the repo
129init, creates the appropriate local_manifest.xml, does a repo sync as
130needed and tell git to ignore the offending files:
131
132------------
133#!/bin/bash
134
135set -e  # fail on errors
136
137URL=ssh://android-git.corp.google.com:29418/platform/manifest.git
138BRANCH=donut
139if [ "$1" == "-b" ]; then shift; BRANCH=$1; shift; fi
140
141# repo init if there's no .repo directory
142if [[ ! -d .repo ]]; then
143    repo init -u $URL -b $BRANCH
144fi
145
146# create a local_manifest to exclude projects that cause problems under Windows
147# due to the case-insenstivines of the file system.
148L=.repo/local_manifest.xml
149if [[ ! -f $L ]]; then
150
151    cat > $L <<EOF
152<?xml version="1.0" encoding="UTF-8"?>
153<manifest>
154<remove-project name="platform/external/iptables" />
155</manifest>
156EOF
157fi
158
159# sync using the native ssh client if necessary
160[[ $URL != ${URL/ssh/} ]] && export GIT_SSH=ssh
161repo sync $@
162
163
164# These files cause trouble too, we need to ignore them
165(cd bionic;
166git update-index --assume-unchanged \
167    libc/kernel/common/linux/netfilter/xt_CONNMARK.h \
168    libc/kernel/common/linux/netfilter/xt_MARK.h \
169    libc/kernel/common/linux/netfilter_ipv6/ip6t_HL.h
170)
171(cd external/tcpdump;
172git update-index --assume-unchanged \
173    tests/print-X.new \
174    tests/print-XX.new
175)
176------------
177
178Simply extract this to a "my_sync.sh" file and try the following:
179  $ mkdir android_src
180  $ cd android_src
181  $ chmod +x mysync.sh
182  $ ./mysync.sh
183
184
185-end-
186
187
188
189
190