import xml.dom.minidom
import os
from subprocess import call
"""
git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git
克隆manifest.git仓库,可以git branch -a 查看所有Android源码的分支。
git checkout 切换到自己想要下载的对应源码分支。
这时可以看到manifest/default.xml该文件里面就有对应的project name,这些都是仓库名,利用python脚本来组件git clone 仓库命令。
"""
# 1. 修改为源码要保存的路径
rootdir = "E:/Android_Source"
# 2. 设置 git 安装的路径
git = "C:/Users/asus/AppData/Local/GitHub/PortableGit_d76a6a98c9315931ec4927243517bc09e9b731a0/mingw32/libexec/git-core/git.exe"
# 3. 修改为第一步中 manifest 中 default.xml 保存的路径
dom = xml.dom.minidom.parse("E:/Android_Source/manifest/default.xml")
root = dom.documentElement
#prefix = git + " clone https://android.googlesource.com/"
# 4. 没有梯子使用清华源下载
prefix = git + " clone 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)
Android 源码拉取脚本
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 服务器环境 *PHP 5.4*Nginx 1.8.0*GIT version 2.9.4(#git --versi...
- 前言 最近在自学Python,正好2014 CSDN博客之星投票搞得如火如荼,拿来练练手。 环境:Win7 6...
- 今天遇到了用命令文件拉取svn上的代码,在终端中提示如下问题 原因:我的Mac中之前装了多个版本的Xcode,近期...
- #!/bin/bash yum install rpm -y rpm -Uvh http://ftp.riken....