Currently, the paths inside the container are hardcoded to mount
${KAS_WORK_DIR} to /work inside the container. This causes every path
printed inside the container to be an invalid path on the host.
Mounting ${KAS_WORK_DIR} as ${KAS_WORK_DIR} instead makes the paths
inside the container match the paths outside the container.
Having the paths be invalid can be inconvenient for a couple reasons:
- working in a git repo in the build folder from the host environment
causes git to complain about the paths being different and causes
other git tools like lazygit to not work at all. Forcing the developer
to interact with repos from inside the container.
- editors can not intelligently interact with the paths printed inside
the containers without workarounds to account for the difference in
paths.
Signed-off-by: Anakin Childerhose <
anakin.ch...@savoirfairelinux.com>
---
kas-container | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kas-container b/kas-container
index 476724c..e25007f 100755
--- a/kas-container
+++ b/kas-container
@@ -230,7 +230,7 @@ forward_dir()
if [ "${FW_DIR_REL}" = "$_varval" ]; then
KAS_RUNTIME_ARGS="${KAS_RUNTIME_ARGS} -v ${FW_DIR_REL}:$2:$3 -e $1=$2"
else
- KAS_RUNTIME_ARGS="${KAS_RUNTIME_ARGS} -e $1=/work/${FW_DIR_REL}"
+ KAS_RUNTIME_ARGS="${KAS_RUNTIME_ARGS} -e $1=${KAS_WORK_DIR}/${FW_DIR_REL}"
fi
}
@@ -584,7 +584,7 @@ else
KAS_FILES="$(echo "${KAS_FILES}" | sed 's|'"${KAS_REPO_DIR}"'/|/repo/|g')"
fi
set -- "$@" -v "${KAS_REPO_DIR}:/repo:${KAS_REPO_MOUNT_OPT}" \
- -v "${KAS_WORK_DIR}":/work:rw -e KAS_WORK_DIR=/work \
+ -v "${KAS_WORK_DIR}":"${KAS_WORK_DIR}":rw -e KAS_WORK_DIR="${KAS_WORK_DIR}" \
--workdir=/repo \
-e KAS_CONTAINER_SCRIPT_VERSION="${KAS_CONTAINER_SCRIPT_VERSION}" \
-e USER_ID="$(id -u)" -e GROUP_ID="$(id -g)" --rm --init
@@ -606,7 +606,7 @@ if git_com_dir=$(git -C "${KAS_REPO_DIR}" rev-parse --git-common-dir 2>/dev/null
-v "${KAS_GIT_OVERLAY_FILE}:/repo/.git:ro"
# if the workdir is the same as the repo dir, it is the same shared worktree
if [ "${KAS_WORK_DIR}" = "${KAS_REPO_DIR}" ]; then
- set -- "$@" -v "${KAS_GIT_OVERLAY_FILE}:/work/.git:ro"
+ set -- "$@" -v "${KAS_GIT_OVERLAY_FILE}:${KAS_WORK_DIR}/.git:ro"
fi
fi
--
2.51.0