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