litex_setup: raise exception on update if repository has been been initialized.

This commit is contained in:
Florent Kermarrec 2020-04-12 19:46:56 +02:00
parent 4fe31f0760
commit a8bf02167a
1 changed files with 11 additions and 8 deletions

View File

@ -85,14 +85,15 @@ if len(sys.argv) < 2:
if "init" in sys.argv[1:]: if "init" in sys.argv[1:]:
os.chdir(os.path.join(current_path)) os.chdir(os.path.join(current_path))
for name in repos.keys(): for name in repos.keys():
url, need_recursive, need_develop = repos[name] if not os.path.exists(name):
# clone repo (recursive if needed) url, need_recursive, need_develop = repos[name]
print("[cloning " + name + "]...") # clone repo (recursive if needed)
full_url = url + name print("[cloning " + name + "]...")
opts = "--recursive" if need_recursive else "" full_url = url + name
subprocess.check_call( opts = "--recursive" if need_recursive else ""
"git clone " + full_url + " " + opts, subprocess.check_call(
shell=True) "git clone " + full_url + " " + opts,
shell=True)
# Repositories installation # Repositories installation
if "install" in sys.argv[1:]: if "install" in sys.argv[1:]:
@ -120,6 +121,8 @@ if "install" in sys.argv[1:]:
# Repositories update # Repositories update
if "update" in sys.argv[1:]: if "update" in sys.argv[1:]:
for name in repos.keys(): for name in repos.keys():
if not os.path.exists(name):
raise Exception("{} not initialized, please (re)-run init and install first.".format(name))
# update # update
print("[updating " + name + "]...") print("[updating " + name + "]...")
os.chdir(os.path.join(current_path, name)) os.chdir(os.path.join(current_path, name))