- 注册时间
- 2013-4-19
- 最后登录
- 2024-9-26
- 阅读权限
- 200
- 积分
- 6404
- 精华
- 0
- 帖子
- 640
|
# coding=utf8
#repo sync for android x86 source code
#
#
# 1.cts 1.1G
# 2.
import re
import os
taggetTags = 'android-9.0.0_r54'
# 9.0-r2 和之前8不同分支待refs/tags/
x86TaggetTags = 'android-x86-9.0-r2'
def _GitCloneX86(line):
#匹配有path的,注意其中'kernel','LLVM90'需要特殊处理
#git clone https://scm.osdn.net/gitroot/android-x86/external-llvm.git --depth 1 -b android-x86-9.0-r2 external/llvm90
m = re.match(r'.+name=\"(\S+)\".+path=\"(\S+)\".+upstream=\"(\S+)\"', line)
if m:
print 'get name : %s , path : %s , upstream : %s ' % (m.group(1) , m.group(2) , m.group(3))
gitPath = m.group(2).replace('/', '-')
cmd = 'git clone https://scm.osdn.net/gitroot/android-x86/{0}.git --depth 1 -b {1} {2} \n'.format(gitPath, x86TaggetTags, m.group(2))
print cmd
os.system(cmd)
with open("x86PathCloned.txt","a") as x86PathClonedFile:
x86PathClonedFile.write(line)
x86PathClonedFile.write(cmd)
return
#匹配不包含path的
m = re.match(r'.+name=\"(\S+)\".+upstream=\"(\S+)\"', line)
if m:
print 'get name : %s , upstream : %s ' % (m.group(1) , m.group(2) )
gitPath = m.group(1).replace('/', '-')
cmd = 'git clone https://scm.osdn.net/gitroot/android-x86/{0}.git --depth 1 -b {1} {2} \n'.format(gitPath, x86TaggetTags, m.group(1))
print cmd
os.system(cmd)
with open("x86NoPathCloned.txt","a") as x86NoPathClonedFile:
x86NoPathClonedFile.write(line)
x86NoPathClonedFile.write(cmd)
else:
#剩下没有匹配的
with open("x86UnCloned.txt","a") as x86UnClonedFile:
x86UnClonedFile.write(line)
return
def _GitCloneAndroid(line):
#匹配有path的 'platform/build'和'platform/build/soong' 最好repo方式
m = re.match(r'.+name=\"(\S+)\".+path=\"(\S+)\".+upstream=\"(\S+)\"', line)
if m:
print 'get name : %s , path : %s , upstream : %s ' % (m.group(1) , m.group(2) , m.group(3))
cmd = 'git clone https://android.googlesource.com/{0} --depth 1 -b {1} {2}'.format(m.group(1), taggetTags, m.group(2))
print cmd
os.system(cmd)
return
#匹配不包含path的
m = re.match(r'.+name=\"(\S+)\".+upstream=\"(\S+)\"', line)
if m:
print 'get name : %s , upstream : %s ' % (m.group(1) , m.group(2) )
cmd = 'git clone https://android.googlesource.com/{0} --depth 1 -b {1} {2} \n'.format(m.group(1), taggetTags, m.group(1))
print cmd
os.system(cmd)
else:
#剩下没有匹配的
with open("androidUnCloned.txt","a") as androidUnClonedFile:
androidUnClonedFile.write(line)
return
#clone 之后需要reset到对应的revision版本
def _GitCloneMaster(line):
#匹配有path的 x86_64-linux-glibc2.11-4.6 这个需要特殊处理
#git clone https://android.googlesource.com ... linux-glibc2.11-4.6 --depth 1 -b master prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6
m = re.match(r'.+name=\"(\S+)\".+path=\"(\S+)\".+upstream=\"(\S+)\"', line)
if m:
print 'get name : %s , path : %s , upstream : %s ' % (m.group(1) , m.group(2) , m.group(3))
cmd = 'git clone https://android.googlesource.com/{0} --depth 1 -b master {1}'.format(m.group(1), m.group(2))
print cmd
#os.system(cmd)
return
#分类判断每一行类型
def _GetType(line):
if "remote=\"x86\"" in line:
with open("x86.txt","a") as x86File:
x86File.write(line)
_GitCloneX86(line)
return
if "android-9.0.0_r54" in line:
with open("android.txt","a") as androidFile:
androidFile.write(line)
_GitCloneAndroid(line)
return
if "master" in line:
with open("master.txt","a") as masterFile:
masterFile.write(line)
return
with open("unCloneLine.txt","a") as unCloneFile:
unCloneFile.write(line)
#os.remove("*.txt")
#程序入口
f = open("android-x86-9.0-r2.xml")
while True:
line = f.readline()
if line:
_GetType(line)
else:
break
f.close()
|
|