]> git.seodisparate.com/gitweb - AnotherAURHelper/commitdiff
Prefetch "other_deps" with "pacman -Sw"
authorStephen Seo <seo.disparate@gmail.com>
Mon, 8 Apr 2024 02:02:36 +0000 (11:02 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 8 Apr 2024 02:02:36 +0000 (11:02 +0900)
update.py

index f78d334f62654f5aa37e824ce7ccf3e8c8a07980..9f2f1c1bec98c22ef4c80ad0afa626506b5337de 100755 (executable)
--- a/update.py
+++ b/update.py
@@ -742,6 +742,13 @@ def get_pkgbuild_version(
                     f'{os.environ["HOME"]}/.cargo/git:/build/.cargo/git',
                 )
             for dep in pkg_state[pkg]["other_deps"]:
+                prefetch_result = prefetch_dependency(dep, other_state)
+                if prefetch_result != "fetched":
+                    log_print(
+                        'ERROR: Failed to prefetch dep "{}"'.format(dep),
+                        other_state=other_state,
+                    )
+                    return False, None, None, None
                 dep_fullpath = get_latest_pkg(dep, "/var/cache/pacman/pkg")
                 if not dep_fullpath:
                     log_print(
@@ -1375,6 +1382,15 @@ def update_pkg_list(
         ]
         failure = False
         for dep in pkg_state[pkg]["other_deps"]:
+            prefetch_result = prefetch_dependency(dep, other_state)
+            if prefetch_result != "fetched":
+                log_print(
+                    'ERROR: Failed to prefetch dep "{}"'.format(dep),
+                    other_state=other_state,
+                )
+                failure = True
+                pkg_state[pkg]["build_status"] = "get_dep_fail"
+                break
             dep_fullpath = get_latest_pkg(dep, "/var/cache/pacman/pkg")
             if not dep_fullpath:
                 log_print(
@@ -2030,6 +2046,22 @@ def prepare_user_chroot(other_state: [str, Any]):
     return True
 
 
+def prefetch_dependency(pkg_name, other_state: [str, Any]):
+    """Returns "fetched" on success."""
+    log_print(
+        f'Prefetching package "{pkg_name}" with "pacman -Sw"...',
+        other_state=other_state,
+    )
+    try:
+        subprocess.run(
+            ("/usr/bin/env", "sudo", "pacman", "--noconfirm", "-Sw", pkg_name),
+            check=True,
+        )
+    except subprocess.CalledProcessError:
+        return "fail"
+    return "fetched"
+
+
 def main():
     """The main function."""
     signal.signal(signal.SIGINT, signal_handler)