]> git.seodisparate.com - AnotherAURHelper/commitdiff
Add some path validation/dir-creation
authorStephen Seo <seo.disparate@gmail.com>
Sat, 4 Jun 2022 08:15:52 +0000 (17:15 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 4 Jun 2022 08:15:52 +0000 (17:15 +0900)
update.py

index 6a9a170dc4dd207a0c295bad6c66edf75e3fe4f7..97972468a47654ccae2dbdda8e82fb9cfc35e83e 100755 (executable)
--- a/update.py
+++ b/update.py
@@ -849,10 +849,6 @@ def update_pkg_list(
 
         pkg_state[pkg]["build_status"] = "success"
 
-        log_print("Ensuring pkgs directory exists...")
-        if not os.path.exists(other_state['pkg_out_dir']):
-            pkg_out_dir_path = Path(other_state['pkg_out_dir'])
-            pkg_out_dir_path.mkdir(parents=True)
         log_print("Moving pkg to pkgs directory...")
         for f in pkg_list:
             log_print(f'Moving "{f}"...')
@@ -958,6 +954,30 @@ def test_gpg_passphrase(signing_gpg_dir, signing_key_fp, passphrase):
     return True
 
 
+def validate_and_verify_paths(other_state):
+    if not os.path.exists(other_state['chroot']):
+        log_print(f"ERROR: chroot at "{other_state['chroot']}" does not exist")
+        sys.exit(1)
+    log_print("Ensuring pkgs directory exists...")
+    if not os.path.exists(other_state['pkg_out_dir']):
+        pkg_out_dir_path = Path(other_state['pkg_out_dir'])
+        pkg_out_dir_path.mkdir(parents=True)
+    if not os.path.exists(other_state['gpg_home']):
+        log_print(f"ERROR: checkingGPG at "{other_state['gpg_home']}" does not exist")
+        sys.exit(1)
+    log_print("Ensuring logs directory exists...")
+    if other_state['logs_dir'] is None:
+        log_print('ERROR: "logs_dir" was not specified!')
+        sys.exit(1)
+    if not os.path.exists(other_state['logs_dir']):
+        logs_dir_path = Path(other_state['logs_dir'])
+        logs_dir_path.mkdir(parents=True)
+    log_print("Ensuring clones directory exists...")
+    if not os.path.exists(other_state['clones_dir']):
+        clones_dir_path = Path(other_state['clones_dir'])
+        clones_dir_path.mkdir(parents=True)
+
+
 if __name__ == "__main__":
     editor = None
     parser = argparse.ArgumentParser(description="Update AUR pkgs")
@@ -1121,6 +1141,8 @@ if __name__ == "__main__":
         log_print('ERROR: At least "--config" or "--pkg" must be specified')
         sys.exit(1)
 
+    validate_and_verify_paths(other_state)
+
     if args.editor is not None:
         editor = args.editor