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