Skip to content

Commit a2e7a07

Browse files
authored
HADOOP-17298. Backslash in username causes build failure in the environment started by start-build-env.sh. (#2367)
Signed-off-by: Akira Ajisaka <[email protected]>
1 parent d60d5fe commit a2e7a07

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

start-build-env.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ if [ "$(uname -s)" = "Linux" ]; then
6666
fi
6767
fi
6868

69+
# Set the home directory in the Docker container.
70+
DOCKER_HOME_DIR=${DOCKER_HOME_DIR:-/home/${USER_NAME}}
71+
6972
docker build -t "hadoop-build-${USER_ID}" - <<UserSpecificDocker
7073
FROM hadoop-build
7174
RUN rm -f /var/log/faillog /var/log/lastlog
7275
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
73-
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME}
76+
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME} -d "${DOCKER_HOME_DIR}"
7477
RUN echo "${USER_NAME} ALL=NOPASSWD: ALL" > "/etc/sudoers.d/hadoop-build-${USER_ID}"
75-
ENV HOME /home/${USER_NAME}
78+
ENV HOME "${DOCKER_HOME_DIR}"
7679
7780
UserSpecificDocker
7881

@@ -85,9 +88,9 @@ DOCKER_INTERACTIVE_RUN=${DOCKER_INTERACTIVE_RUN-"-i -t"}
8588
# system. And this also is a significant speedup in subsequent
8689
# builds because the dependencies are downloaded only once.
8790
docker run --rm=true $DOCKER_INTERACTIVE_RUN \
88-
-v "${PWD}:/home/${USER_NAME}/hadoop${V_OPTS:-}" \
89-
-w "/home/${USER_NAME}/hadoop" \
90-
-v "${HOME}/.m2:/home/${USER_NAME}/.m2${V_OPTS:-}" \
91-
-v "${HOME}/.gnupg:/home/${USER_NAME}/.gnupg${V_OPTS:-}" \
91+
-v "${PWD}:${DOCKER_HOME_DIR}/hadoop${V_OPTS:-}" \
92+
-w "${DOCKER_HOME_DIR}/hadoop" \
93+
-v "${HOME}/.m2:${DOCKER_HOME_DIR}/.m2${V_OPTS:-}" \
94+
-v "${HOME}/.gnupg:${DOCKER_HOME_DIR}/.gnupg${V_OPTS:-}" \
9295
-u "${USER_ID}" \
9396
"hadoop-build-${USER_ID}" "$@"

0 commit comments

Comments
 (0)