Raphael | 5ea4287 | 2009-04-27 15:01:16 -0700 | [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 | |
| 19 | |
| 20 | |
| 21 | Table of content: |
| 22 | 1- Goals and Requirements |
| 23 | 2- Getting the code, the simple way |
| 24 | 3- SSH issues |
| 25 | 4- Advanced Tricks |
| 26 | |
| 27 | |
| 28 | ------------------------- |
| 29 | 1- Goals and Requirements |
| 30 | ------------------------- |
| 31 | |
| 32 | This document explains how to checkout the Android source from the git |
| 33 | repositories under Windows. |
| 34 | |
| 35 | As stated in development/docs/howto_build_SDK.txt, one can't build the whole |
| 36 | Android source code under Windows. You can only build a the SDK tools for |
| 37 | Windows. |
| 38 | |
| 39 | There are a number of caveats in checking out the code from Git under Windows. |
| 40 | This document tries to explain them. |
| 41 | |
| 42 | First you will need to meet the following requirements: |
| 43 | - You must have Cygwin installed. |
| 44 | See http://www.cygwin.com/ |
| 45 | |
| 46 | - You must install Cyginw using the "Unix / Binary" mode. |
| 47 | If you don't do that, git will fail to properly compute some SHA1 keys. |
| 48 | |
| 49 | - You need the "git" and "curl" packages to checkout the code. |
| 50 | If you plan to contribute, you might want to get "gitk" also. |
| 51 | |
| 52 | Note: if you want to build the SDK, check the howto_build_SDK.txt file |
| 53 | for a list of extra required packages. |
| 54 | |
| 55 | |
| 56 | ----------------------------------- |
| 57 | 2- Getting the code, the simple way |
| 58 | ----------------------------------- |
| 59 | |
| 60 | Out of the box, "repo" and "git" will work just fine under Cygwin: |
| 61 | |
| 62 | $ repo init -u git://android.git.kernel.org/platform/manifest.git |
| 63 | $ repo sync |
| 64 | |
| 65 | And you're done. You can build as explained in howto_build_SDK.txt and ignore |
| 66 | the rest of this document. |
| 67 | |
| 68 | |
| 69 | ------------- |
| 70 | 3- SSH issues |
| 71 | ------------- |
| 72 | |
| 73 | If you maintain your own private repository using an SSH server, you might get |
| 74 | some "mux/ssh" errors. In this case try this: |
| 75 | |
| 76 | $ repo init -u ssh://my.private.ssh.repo/platform/manifest.git |
| 77 | $ export GIT_SSH=ssh |
| 78 | $ repo sync |
| 79 | |
| 80 | |
| 81 | ------------------ |
| 82 | 4- Advanced Tricks |
| 83 | ------------------ |
| 84 | |
| 85 | There are two remaining issues with the default repo/git options: |
| 86 | |
| 87 | A- If you plan on contributing, you will notice that even after a fresh "repo |
| 88 | sync" some projects are marked as having modified files. This happens on the |
| 89 | "bionic" and the "external/iptables" project. The issue is that they have files |
| 90 | which have the same name yet differ only by their case-sensitivity. Since the |
| 91 | Windows filesystem is not case-sensitive, this confuses Git. |
| 92 | |
| 93 | Solution: we can simply ignore these projects as they are not needed to build |
| 94 | the Windows SDK. |
| 95 | |
| 96 | To do this you just need to create a file .repo/local_manifest.xml that |
| 97 | provides a list of projects to ignore: |
| 98 | |
| 99 | <?xml version="1.0" encoding="UTF-8"?> |
| 100 | <manifest> |
| 101 | <remove-project name="platform/bionic" /> |
| 102 | <remove-project name="platform/external/iptables" /> |
| 103 | </manifest> |
| 104 | |
| 105 | |
| 106 | B- The other issue is that by default repo maintains around 100+ git projects. |
| 107 | However most of these are not needed to build the Windows SDK. We can easily |
Raphael | 68fee20 | 2009-04-28 12:11:03 -0700 | [diff] [blame] | 108 | reduce this list to around 70 projects, which will make your repo syncs a lot |
Raphael | 5ea4287 | 2009-04-27 15:01:16 -0700 | [diff] [blame] | 109 | faster. |
| 110 | |
Raphael | 68fee20 | 2009-04-28 12:11:03 -0700 | [diff] [blame] | 111 | Solution: Simply ignore all projects bionic, bootable/*, hardware/* and most |
| 112 | external projects. For external, we still need a handful of projects for the |
| 113 | SDK -- things like the emulator or sqlite can be quite useful :-) |
Raphael | 5ea4287 | 2009-04-27 15:01:16 -0700 | [diff] [blame] | 114 | |
| 115 | Here's a script that takes care of all these details. It performs the repo |
| 116 | init, creates the appropriate local_manifest.xml and does a repo sync as |
| 117 | needed: |
| 118 | |
| 119 | ------------ |
| 120 | #!/bin/bash |
| 121 | |
| 122 | set -e # fail on errors |
| 123 | |
| 124 | URL=git://android.git.kernel.org/platform/manifest.git |
| 125 | BRANCH=donut |
| 126 | |
Raphael | 68fee20 | 2009-04-28 12:11:03 -0700 | [diff] [blame] | 127 | # repo init if there's no .repo directory |
| 128 | if [[ ! -d .repo ]]; then |
Raphael | 5ea4287 | 2009-04-27 15:01:16 -0700 | [diff] [blame] | 129 | repo init -u $URL -b $BRANCH |
Raphael | 68fee20 | 2009-04-28 12:11:03 -0700 | [diff] [blame] | 130 | fi |
Raphael | 5ea4287 | 2009-04-27 15:01:16 -0700 | [diff] [blame] | 131 | |
Raphael | 68fee20 | 2009-04-28 12:11:03 -0700 | [diff] [blame] | 132 | # create a local_manifest to exclude projects not useful to the Windows SDK |
| 133 | L=.repo/local_manifest.xml |
| 134 | if [[ ! -f $L ]]; then |
Raphael | 5ea4287 | 2009-04-27 15:01:16 -0700 | [diff] [blame] | 135 | M=.repo/manifest.xml |
Raphael | 5ea4287 | 2009-04-27 15:01:16 -0700 | [diff] [blame] | 136 | |
| 137 | cat > $L <<EOF |
| 138 | <?xml version="1.0" encoding="UTF-8"?> |
| 139 | <manifest> |
| 140 | EOF |
| 141 | |
Raphael | 68fee20 | 2009-04-28 12:11:03 -0700 | [diff] [blame] | 142 | for i in $(sed -sn '/external\/\(apache\|expat\|g\|libpng\|pr\|qemu\|sqlite\|tag\|zlib\)/d;/\(bionic\|bootable\|cts\|external\|hardware\).* name/s/^.*name="\([^"]\+\)".*/\1/p' $M) ; do |
Raphael | 5ea4287 | 2009-04-27 15:01:16 -0700 | [diff] [blame] | 143 | echo "Ignore project $i" |
| 144 | echo " <remove-project name=\"$i\" />" >> $L |
| 145 | done |
| 146 | |
| 147 | cat >> $L <<EOF2 |
| 148 | </manifest> |
| 149 | EOF2 |
| 150 | fi |
| 151 | |
| 152 | [[ $URL != ${URL/ssh/} ]] && export GIT_SSH=ssh |
| 153 | repo sync |
| 154 | ------------ |
| 155 | |
| 156 | |
| 157 | Simply extract this to a "my_sync.sh" file and try the following: |
| 158 | $ mkdir android_src |
| 159 | $ cd android_src |
| 160 | $ chmod +x mysync.sh |
| 161 | $ ./mysync.sh |
| 162 | |
| 163 | |
| 164 | -end- |
| 165 | |
| 166 | |
| 167 | |
| 168 | |