1.查看最新源码repo仓库
git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest
cd .\manifest\
2.克隆所有仓库
python sync.py
import xml.dom.minidom
import os
from subprocess import call
# 保存源码路径
rootdir = "C:/Users/wdp/Desktop/source/android-12.0.0_r2"
# git路径
git = "C:/Program Files/Git/bin/git.exe"
dom = xml.dom.minidom.parse("C:/Users/wdp/Desktop/source/manifest/default.xml")
root = dom.documentElement
# 默认下载master分支最新代码
prefix = git + " clone https://aosp.tuna.tsinghua.edu.cn/"
# 只拉去最新一次commit,减小源码体积
# prefix = git + " clone --depth=1 https://aosp.tuna.tsinghua.edu.cn/"
suffix = ".git"
if not os.path.exists(rootdir):
os.mkdir(rootdir)
for node in root.getElementsByTagName("project"):
os.chdir(rootdir)
d = node.getAttribute("path")
last = d.rfind("/")
if last != -1:
d = rootdir + "/" + d[:last]
if not os.path.exists(d):
os.makedirs(d)
os.chdir(d)
cmd = prefix + node.getAttribute("name") + suffix
call(cmd)
3.单独克隆某个仓库
git clone https://aosp.tuna.tsinghua.edu.cn/platform/packages/apps/Launcher3.git