故事
故事是这样的,同事那边有android source code,做成镜像的方式,使用repo的方式稍微有不一样的地方,记录一下
该mirror的目录结构如下:
android-mirror.git
├── accessories
│ └── manifest.git
├── device
├── git-repo.git
├── kernel
├── mirror
│ └── manifest.git
├── platform
│ ├── abi
│ ├── art.git
│ ├── bionic.git
│ ├── bootable
│ ├── build.git
│ ├── cts.git
│ ├── dalvik-snapshot.git
│ ├── dalvik.git
│ ├── dalvik2.git
│ ├── developers
│ ├── development.git
│ ├── docs
│ ├── external
│ ├── frameworks
│ ├── gdk.git
│ ├── hardware
│ ├── libcore-snapshot.git
│ ├── libcore.git
│ ├── libcore2.git
│ ├── libnativehelper.git
│ ├── manifest.git
│ ├── motodev.git
│ ├── ndk.git
│ ├── packages
│ ├── pdk.git
│ ├── prebuilt.git
│ ├── prebuilts
│ ├── sdk.git
│ ├── system
│ ├── tools
│ └── vendor
├── toolchain
│ ├── avr-libc.git
│ ├── ...
└── tools
└── repo.git
mkdir /Volume/googleshared
mount -t smbfs -o //10.58.51.1/googleshared /Volume/googleshared
如何将这个镜像repo init呢?
按照source.android.com的命令依葫芦画瓢:
repo init -u /Volumes/googleshared/android/android-mirror.git/platform/manifest.git
上面成功执行之前需要解决几个问题:
repo可能会提示连接 gerrit.googlesource.com/git-repo 失败,需要修改repo:
#REPO_URL = 'https://gerrit.googlesource.com/git-repo'
REPO_URL = '/Volumes/googleshared/android/android-mirror.git/git-repo.git'
有更优雅的方式
对于repo如何使用镜像,Google官方文档(
using repo)没有给出,但仔细看一下repo的源码,(参考
老罗:Android源代码仓库及其管理工具Repo分析),repo init是有很多参数的(参考repo代码: $ANDROID_REPO_TOP/.repo/repo/subcmds/init.py ,函数名:
_Option,其中:
- `--mirror`表示生成镜像
- `--reference`表示从镜像初始化repo,和`--mirror`对应
我使用的这个镜像应该是`--mirror`参数生成的,所以使用这个镜像可以这样:
repo init -u /Volumes/googleshared/android/android-mirror.git/platform/manifest.git --reference
(上面的命令未验证过)
其他插曲
插曲1
找不到gpg命令,需要安装(mac系统)
brew install gpg
插曲2: repo sync之后在mac系统无法编译
repo sync之后发现在mac系统无法编译,原因应该是这个镜像是在linux环境下生成的,`repo init`的时候,会自动选择linux的编译环境。参考repo代码: $ANDROID_REPO_TOP/.repo/repo/subcmds/init.py , g.add_option('-p', '--platform',
dest='platform', default='auto',
help='restrict manifest projects to ones with a specified '
'platform group [auto|all|none|linux|darwin|...]',
metavar='PLATFORM')
如果没有`-p`或者`--platform`这个参数,会自动选择当前操作系统的编译环境
所以生成镜像的时候,可以选择所有平台(此命令未验证):
repo init -u https://android.googlesource.com/platform/manifest --mirror <strong>-p all</strong>