litex_setup: raise exception on update if repository has been been initialized.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Sun, 12 Apr 2020 17:46:56 +0000 (19:46 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Sun, 12 Apr 2020 17:46:56 +0000 (19:46 +0200)
litex_setup.py

index 60582955eff27fee1c177284a913ff8894b0e98c..991c23ac4a358563c95a44431fb948fa75495020 100755 (executable)
@@ -85,14 +85,15 @@ if len(sys.argv) < 2:
 if "init" in sys.argv[1:]:
     os.chdir(os.path.join(current_path))
     for name in repos.keys():
-        url, need_recursive, need_develop = repos[name]
-        # clone repo (recursive if needed)
-        print("[cloning " + name + "]...")
-        full_url = url + name
-        opts = "--recursive" if need_recursive else ""
-        subprocess.check_call(
-            "git clone " + full_url + " " + opts,
-            shell=True)
+        if not os.path.exists(name):
+            url, need_recursive, need_develop = repos[name]
+            # clone repo (recursive if needed)
+            print("[cloning " + name + "]...")
+            full_url = url + name
+            opts = "--recursive" if need_recursive else ""
+            subprocess.check_call(
+                "git clone " + full_url + " " + opts,
+                shell=True)
 
 # Repositories installation
 if "install" in sys.argv[1:]:
@@ -120,6 +121,8 @@ if "install" in sys.argv[1:]:
 # Repositories update
 if "update" in sys.argv[1:]:
     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
         print("[updating " + name + "]...")
         os.chdir(os.path.join(current_path, name))