Paul Duffin | 512ba8f | 2020-05-06 12:55:46 +0000 | [diff] [blame] | 1 | Copyright (C) 2009 The Android Open Source Project |
| 2 | |
| 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | you may not use this file except in compliance with the License. |
| 5 | You may obtain a copy of the License at |
| 6 | |
| 7 | http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | |
| 9 | Unless required by applicable law or agreed to in writing, software |
| 10 | distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | See the License for the specific language governing permissions and |
| 13 | limitations under the License. |
| 14 | |
| 15 | |
| 16 | Subject: How to get the android source code using Cygwin and Git |
| 17 | Date: 2009/04/27 |
| 18 | Updated: 2009/05/21 |
| 19 | Updated: 2010/03/30 |
| 20 | |
| 21 | |
| 22 | Table 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 | ------------------------- |
| 30 | 1- Goals and Requirements |
| 31 | ------------------------- |
| 32 | |
| 33 | This document explains how to checkout the Android source from the git |
| 34 | repositories under Windows. |
| 35 | |
| 36 | As stated in development/docs/howto_build_SDK.txt, one can't build the whole |
| 37 | Android source code under Windows. You can only build the SDK tools for |
| 38 | Windows. |
| 39 | |
| 40 | There are a number of caveats in checking out the code from Git under Windows. |
| 41 | This document tries to explain them. |
| 42 | |
| 43 | First 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 | ----------------------------------- |
| 66 | 2- Getting the code, the simple way |
| 67 | ----------------------------------- |
| 68 | |
| 69 | Out 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 | |
| 74 | And you're done. You can build as explained in howto_build_SDK.txt and ignore |
| 75 | the rest of this document. |
| 76 | |
| 77 | |
| 78 | ------------- |
| 79 | 3- SSH issues |
| 80 | ------------- |
| 81 | |
| 82 | If you maintain your own private repository using an SSH server, you might get |
| 83 | some "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 | ------------------ |
| 91 | 4- Advanced Tricks |
| 92 | ------------------ |
| 93 | |
| 94 | There is one remaining issue with the default repo/git options: |
| 95 | |
| 96 | If you plan on contributing, you will notice that even after a fresh "repo |
| 97 | sync" 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 |
| 99 | which have the same name yet differ only by their case-sensitivity. Since the |
| 100 | Windows filesystem is not case-sensitive, this confuses Git. |
| 101 | |
| 102 | Solution: we can simply ignore these projects as they are not needed to build |
| 103 | the Windows SDK. |
| 104 | |
| 105 | To do this you just need to create a file .repo/local_manifest.xml that |
| 106 | provides 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 | |
| 113 | The other thing we can do is tell git not to track the files that cause |
| 114 | problems: |
| 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 | |
| 128 | Here's a script that takes care of all these details. It performs the repo |
| 129 | init, creates the appropriate local_manifest.xml, does a repo sync as |
| 130 | needed and tell git to ignore the offending files: |
| 131 | |
| 132 | ------------ |
| 133 | #!/bin/bash |
| 134 | |
| 135 | set -e # fail on errors |
| 136 | |
| 137 | URL=ssh://android-git.corp.google.com:29418/platform/manifest.git |
| 138 | BRANCH=donut |
| 139 | if [ "$1" == "-b" ]; then shift; BRANCH=$1; shift; fi |
| 140 | |
| 141 | # repo init if there's no .repo directory |
| 142 | if [[ ! -d .repo ]]; then |
| 143 | repo init -u $URL -b $BRANCH |
| 144 | fi |
| 145 | |
| 146 | # create a local_manifest to exclude projects that cause problems under Windows |
| 147 | # due to the case-insenstivines of the file system. |
| 148 | L=.repo/local_manifest.xml |
| 149 | if [[ ! -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> |
| 156 | EOF |
| 157 | fi |
| 158 | |
| 159 | # sync using the native ssh client if necessary |
| 160 | [[ $URL != ${URL/ssh/} ]] && export GIT_SSH=ssh |
| 161 | repo sync $@ |
| 162 | |
| 163 | |
| 164 | # These files cause trouble too, we need to ignore them |
| 165 | (cd bionic; |
| 166 | git 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; |
| 172 | git update-index --assume-unchanged \ |
| 173 | tests/print-X.new \ |
| 174 | tests/print-XX.new |
| 175 | ) |
| 176 | ------------ |
| 177 | |
| 178 | Simply 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 | |