Add opt to link "$HOME/.cargo/registry" on build

Set "link_cargo_registry = true" in an "[[entry]]" to link
"$HOME/.cargo/registry" to the build's chroot.
This commit is contained in:
Stephen Seo 2023-02-27 18:21:59 +09:00
parent d96ffb7d9e
commit a3e5c88835

View file

@ -1066,6 +1066,12 @@ def update_pkg_list(
nowstring = datetime.datetime.now(datetime.timezone.utc).strftime( nowstring = datetime.datetime.now(datetime.timezone.utc).strftime(
"%Y-%m-%d_%H-%M-%S_%Z" "%Y-%m-%d_%H-%M-%S_%Z"
) )
if "link_cargo_registry" in pkg_state[pkg]:
command_list.insert(2, "-d")
command_list.insert(
3,
f'{os.environ["HOME"]}/.cargo/registry:/build/.cargo/registry',
)
# log_print(f"Using command list: {command_list + post_command_list}") # DEBUG # log_print(f"Using command list: {command_list + post_command_list}") # DEBUG
with open( with open(
os.path.join( os.path.join(
@ -1276,7 +1282,7 @@ def print_state_info_and_get_update_list(pkg_state: dict[str, Any]):
to_update = [] to_update = []
log_print("package state:") log_print("package state:")
for (pkg_name, pkg_dict) in pkg_state.items(): for pkg_name, pkg_dict in pkg_state.items():
if "state" in pkg_dict: if "state" in pkg_dict:
log_print(f" {pkg_name:40}: {pkg_dict['state']}") log_print(f" {pkg_name:40}: {pkg_dict['state']}")
if pkg_dict["state"] == "install": if pkg_dict["state"] == "install":
@ -1485,6 +1491,12 @@ if __name__ == "__main__":
pkg_state[entry["name"]]["skip_branch_up_to_date"] = True pkg_state[entry["name"]]["skip_branch_up_to_date"] = True
else: else:
pkg_state[entry["name"]]["skip_branch_up_to_date"] = False pkg_state[entry["name"]]["skip_branch_up_to_date"] = False
if (
"link_cargo_registry" in entry
and type(entry["link_cargo_registry"]) is bool
and entry["link_cargo_registry"]
):
pkg_state[entry["name"]]["link_cargo_registry"] = True
other_state["chroot"] = d["chroot"] other_state["chroot"] = d["chroot"]
other_state["pkg_out_dir"] = d["pkg_out_dir"] other_state["pkg_out_dir"] = d["pkg_out_dir"]
other_state["repo"] = d["repo"] other_state["repo"] = d["repo"]