From 3519ec1fc503d2c5346275e6b6bba4c01db60855 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Jun 2026 23:54:29 +0000 Subject: [PATCH] Handle relative symlink targets robustly in cache tar logic --- install_and_cache_pkgs.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/install_and_cache_pkgs.sh b/install_and_cache_pkgs.sh index b943a5c..00ac7f7 100755 --- a/install_and_cache_pkgs.sh +++ b/install_and_cache_pkgs.sh @@ -106,7 +106,7 @@ for installed_package in ${installed_packages}; do get_tar_relpath "${f}" if [ -L "${f}" ]; then symlink_path="${f}" - # Guard against circular links while still supporting deep alternatives chains. + # Guard against circular links; 40 is intentionally high for alternatives chains. max_symlink_depth=40 for i in $(seq 1 ${max_symlink_depth}); do if [ ! -L "${symlink_path}" ]; then @@ -119,7 +119,12 @@ for installed_package in ${installed_packages}; do target_path="${target}" ;; *) - target_path="$(dirname "${symlink_path}")/${target}" + target_dir="$(dirname "${symlink_path}")" + if [ "${target_dir}" = "/" ]; then + target_path="/${target}" + else + target_path="${target_dir}/${target}" + fi ;; esac