Commit bc2315d8 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

for preferred protocol look into .git/config

parent 114aa078
......@@ -55,7 +55,7 @@ def cloneandcheckout(name,item):
os.chdir(cwd)
else:
#check for https or git
cwd = os.getcwd()
os.chdir(cwd+"/"+name)
read_remote = subprocess.check_output("git remote -v",shell=True)
......@@ -63,7 +63,7 @@ def cloneandcheckout(name,item):
print(bcolors.WARNING+"Changing git remote to "+item[0]+bcolors.ENDC)
shout("git remote set-url origin "+item[0])
os.chdir(cwd)
if item[2]!="":
print(" Already cloned - checked out at "+item[1]+" "+item[2])
else:
......@@ -81,12 +81,12 @@ def copy_eclipse_settings(name):
print(" Copying up files for Eclipse project")
print(bcolors.WARNING+" Copying "+name+"/"+EPS+" to "+name+"/"+bcolors.ENDC)
shout("rsync -av "+name+"/"+EPS+"/ "+name+"/")
if not os.path.isdir(name+"/"+EPS):
print("Not copying up files for Eclipse project: not an Eclipse project")
elif os.path.isfile(name+"/.project"):
print("Not copying up files for Eclipse project: .project is already there")
def read_local_conf(conf_file,pattern):
ret = []
......@@ -117,9 +117,31 @@ def read_local_conf_dev(conf_file,pattern):
ret = line.split("=")[1].strip().strip("\"")
return ret
# reads protocol from the current repository and converts all other projects to this protocol
# https - user/password access
# git - key-based access
def read_git_proto(conf_file,pattern):
ret = "0"
if os.path.isfile(conf_file):
with open(conf_file,"r") as f:
lines = f.readlines()
for line in lines:
if len(line)!=0:
if line.strip()[0]!="#":
pars = line.strip().split("=")
if (len(pars)>1):
# simple test
if pars[0].strip()=='url':
test = pars[1].find(pattern)
if test!=-1:
ret = "1"
print("ogogo! "+pars[1].strip())
return ret
def update_branch(names_from_conf,name_from_list,pars,git_proto):
# GIT host is defined in projects.json,
# GIT host is defined in projects.json,
# https or git is defined in local.conf
# get host
s0 = re.search("^(https:\/\/|git@)(.+)(\/|:)Elphel.*",pars[0])
......@@ -134,7 +156,7 @@ def update_branch(names_from_conf,name_from_list,pars,git_proto):
tmp = "git@"+host+":Elphel"
if pars[0].find(tmp)!=-1:
pars[0] = "https://"+host+"/Elphel"+pars[0][len(tmp):]
for p in names_from_conf:
if name_from_list in p:
pars[1] = p[1]
......@@ -155,12 +177,15 @@ else:
print("ok")
project_branches = read_local_conf("poky/build/conf/local.conf","ELPHEL393_branches")
git_proto = read_local_conf_dev("poky/build/conf/local.conf","ELPHEL393_DEV")
#git_proto = read_local_conf_dev("poky/build/conf/local.conf","ELPHEL393_DEV")
git_proto = read_git_proto(".git/config","git@")
i=0
for p,v in Projects.items():
i = i + 1
print bcolors.BOLDWHITE+"Step "+str(i)+": "+p+bcolors.ENDC
if isinstance(v,dict):
#create dir
if not os.path.isdir(p):
......@@ -168,15 +193,15 @@ for p,v in Projects.items():
os.mkdir(p)
else:
print(" "+p+" exists")
cwd = os.getcwd()
os.chdir(cwd+"/"+p)
for k,l in v.items():
print("\n"+bcolors.BOLDWHITE+"*"+bcolors.ENDC+" "+k)
cloneandcheckout(k,update_branch(project_branches,k,l,git_proto))
copy_eclipse_settings(k)
#special case for x393 fpga project
if k=="x393":
if os.path.isfile(k+"/py393/generate_c.sh"):
......@@ -188,11 +213,11 @@ for p,v in Projects.items():
if os.path.isdir(cwd+"/linux-elphel/src/drivers/elphel"):
shout("rsync -a "+k+"/py393/generated/ "+cwd+"/linux-elphel/src/drivers/elphel")
os.chdir(cwd)
elif isinstance(v,list):
cloneandcheckout(p,update_branch(project_branches,p,v,git_proto))
copy_eclipse_settings(p)
else:
print("Error?")
......@@ -256,7 +281,7 @@ BBLAYERS = " \\
{0}/meta/meta-openembedded/meta-webserver \\
"
""".format(path))
with open(local_conf,"a") as f:
f.write("""\
......@@ -264,8 +289,8 @@ MACHINE ?= "elphel393"
MIRRORS =+ "http://.*/.* http://mirror.elphel.com/elphel393_mirror/ \\n "
# Elphel's default git server.
# Affected recipes:
# * u-boot-ezynq.inc,
# Affected recipes:
# * u-boot-ezynq.inc,
# * elphel-python-extensions_*.bb
# * linux-xlnx_4.0.bbappend
ELPHELGITHOST = "git.elphel.com"
......@@ -285,7 +310,7 @@ ELPHELGITHOST = "git.elphel.com"
# ELPHEL393_DEV = "1"
# To change git host edit: projects.json (a copy of projects-default.json)
# New git host must match "^(https:\/\/|git@)(.+)(\/|:)Elphel.*", e.g.:
# New git host must match "^(https:\/\/|git@)(.+)(\/|:)Elphel.*", e.g.:
# "https://something.com/Elphel/someproject" or
# "git@something.com:Elphel/someproject"
......@@ -313,7 +338,7 @@ if missing_bblayers_conf==0:
shout("cp "+bblayers_conf+" "+bblayers_conf+"_default")
shout("cp "+bblayers_conf+"_bkp "+bblayers_conf)
print("NOTE: If anything breaks after running setup.py, compare your bblayers.conf and bblayers.conf_default")
if missing_local_conf==0:
print("restoring "+local_conf)
shout("cp "+local_conf+" "+local_conf+"_default")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment