From 0b91176586e2a69a437a45c05e0ccc631be536e2 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 8 Apr 2024 11:02:36 +0900 Subject: [PATCH] Prefetch "other_deps" with "pacman -Sw" --- update.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/update.py b/update.py index f78d334..9f2f1c1 100755 --- 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) -- 2.49.0