From 0ad48b4ca216e41e0d4ec9fe0fadc6cceac356c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Iwanicki?= Date: Wed, 8 Jan 2025 10:36:50 +0100 Subject: [PATCH 1/2] dcuc: fix file mounting in add_bind_mount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add_bind_mount was run in subshell so changes to e.g. DOCKER_ARGS were not visible after finishing Signed-off-by: Michał Iwanicki --- dcuc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dcuc b/dcuc index e7b3fc8..775ad17 100755 --- a/dcuc +++ b/dcuc @@ -15,20 +15,18 @@ COMMAND_ARGS=() # Function to add a bind mount for a file add_bind_mount() { local FILE_PATH=$1 - local ABS_PATH="" - local DIR_PATH="" + local ABS_PATH ABS_PATH=$(realpath "$FILE_PATH") - DIR_PATH=$(dirname "$ABS_PATH") - DOCKER_ARGS+=("-v" "$DIR_PATH:$DIR_PATH") - echo "$ABS_PATH" + FILENAME="$(basename "$ABS_PATH")" + DOCKER_ARGS+=( '-v' "$ABS_PATH":/"${FILENAME}" ) } # Iterate over the command line arguments for ARG in "$@"; do if [[ -f "$ARG" ]]; then # Convert the file path to an absolute path and add a bind mount - ABS_PATH=$(add_bind_mount "$ARG") - COMMAND_ARGS+=("$ABS_PATH") + add_bind_mount "$ARG" + COMMAND_ARGS+=("/$FILENAME") else COMMAND_ARGS+=("$ARG") fi @@ -38,4 +36,4 @@ if [[ -v CI ]]; then ../dcu "${COMMAND_ARGS[@]}" else docker run -t --rm -v "${SCRIPT_DIR}:${SCRIPT_DIR}" "${DOCKER_ARGS[@]}" -w "${SCRIPT_DIR}" $DOCKER_IMAGE ./dcu "${COMMAND_ARGS[@]}" -fi \ No newline at end of file +fi From ce30ac1d761e828c5902e8ef37b1f05a538b2751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Iwanicki?= Date: Wed, 15 Jan 2025 13:44:31 +0100 Subject: [PATCH 2/2] dcuc: deal with CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Iwanicki --- dcuc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dcuc b/dcuc index 775ad17..29a76e6 100755 --- a/dcuc +++ b/dcuc @@ -24,9 +24,13 @@ add_bind_mount() { # Iterate over the command line arguments for ARG in "$@"; do if [[ -f "$ARG" ]]; then - # Convert the file path to an absolute path and add a bind mount - add_bind_mount "$ARG" - COMMAND_ARGS+=("/$FILENAME") + if [[ -v CI ]]; then + COMMAND_ARGS+=("$(realpath "$ARG")") + else + # Convert the file path to an absolute path and add a bind mount + add_bind_mount "$ARG" + COMMAND_ARGS+=("/$FILENAME") + fi else COMMAND_ARGS+=("$ARG") fi