Skip to content

Commit

Permalink
kas-docker: Translate all kas files into containter paths
Browse files Browse the repository at this point in the history
Ensure that all file elements of the kas file parameter are properly
canonicalized and mapped onto the container volume. This is important
when kas-docker is called using relative paths while PWD is not the
repository root.

Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
jan-kiszka authored and Daniel Wagner committed Jan 2, 2019
1 parent 70c568f commit dabda76
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions kas-docker
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,19 @@ while [ $# -gt 0 ]; do
shift 1
;;
*)
KAS_FILE=$1
FILE=$(echo ${KAS_FILE} | cut -d ':' -f 1)
if ! FIRST_KAS_FILE=$(readlink -e $FILE); then
echo "Error: configuration file '$FILE' not found"
exit 1
fi
KAS_FILES=
for FILE in $(IFS=':'; echo $1); do
if ! REAL_FILE=$(realpath -qe $FILE); then
echo "Error: configuration file '${FILE}' not found"
exit 1
fi
if [ -z "${KAS_FILES}" ]; then
FIRST_KAS_FILE=${REAL_FILE}
KAS_FILES=${REAL_FILE}
else
KAS_FILES=${KAS_FILES}:${REAL_FILE}
fi
done
shift 1
;;
esac
Expand All @@ -163,7 +170,7 @@ REPO_DIR=$(git -C ${KAS_FILE_DIR} rev-parse --show-toplevel 2>/dev/null) \
|| REPO_DIR=$(hg --cwd ${KAS_FILE_DIR} root 2>/dev/null) \
|| REPO_DIR=${KAS_FILE_DIR}

KAS_FILE=/repo/$(echo ${KAS_FILE} | sed 's|'${REPO_DIR}'/||g;s|:|:/repo/|g')
KAS_FILES=/repo/$(echo ${KAS_FILES} | sed 's|'${REPO_DIR}'/||g;s|:|:/repo/|g')

trace mkdir -p ${KAS_WORK_DIR}

Expand Down Expand Up @@ -213,4 +220,4 @@ for var in SHELL TERM KAS_DISTRO KAS_MACHINE KAS_TARGET KAS_TASK \
done

trace docker run "$@" ${ISAR_ARGS} ${USER_ARGS} \
${DOCKER_IMAGE} ${CMD} ${KAS_OPTIONS} ${KAS_FILE}
${DOCKER_IMAGE} ${CMD} ${KAS_OPTIONS} ${KAS_FILES}

0 comments on commit dabda76

Please sign in to comment.