HADOOP-17298. Backslash in username causes build failure in the environment started by start-build-env.sh. (#2367)

Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
tkuramoto33 2020-10-20 10:09:03 +09:00 committed by GitHub
parent d60d5fe43d
commit a2e7a073f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -66,13 +66,16 @@ if [ "$(uname -s)" = "Linux" ]; then
fi fi
fi fi
# Set the home directory in the Docker container.
DOCKER_HOME_DIR=${DOCKER_HOME_DIR:-/home/${USER_NAME}}
docker build -t "hadoop-build-${USER_ID}" - <<UserSpecificDocker docker build -t "hadoop-build-${USER_ID}" - <<UserSpecificDocker
FROM hadoop-build FROM hadoop-build
RUN rm -f /var/log/faillog /var/log/lastlog RUN rm -f /var/log/faillog /var/log/lastlog
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME} RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME} RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME} -d "${DOCKER_HOME_DIR}"
RUN echo "${USER_NAME} ALL=NOPASSWD: ALL" > "/etc/sudoers.d/hadoop-build-${USER_ID}" RUN echo "${USER_NAME} ALL=NOPASSWD: ALL" > "/etc/sudoers.d/hadoop-build-${USER_ID}"
ENV HOME /home/${USER_NAME} ENV HOME "${DOCKER_HOME_DIR}"
UserSpecificDocker UserSpecificDocker
@ -85,9 +88,9 @@ DOCKER_INTERACTIVE_RUN=${DOCKER_INTERACTIVE_RUN-"-i -t"}
# system. And this also is a significant speedup in subsequent # system. And this also is a significant speedup in subsequent
# builds because the dependencies are downloaded only once. # builds because the dependencies are downloaded only once.
docker run --rm=true $DOCKER_INTERACTIVE_RUN \ docker run --rm=true $DOCKER_INTERACTIVE_RUN \
-v "${PWD}:/home/${USER_NAME}/hadoop${V_OPTS:-}" \ -v "${PWD}:${DOCKER_HOME_DIR}/hadoop${V_OPTS:-}" \
-w "/home/${USER_NAME}/hadoop" \ -w "${DOCKER_HOME_DIR}/hadoop" \
-v "${HOME}/.m2:/home/${USER_NAME}/.m2${V_OPTS:-}" \ -v "${HOME}/.m2:${DOCKER_HOME_DIR}/.m2${V_OPTS:-}" \
-v "${HOME}/.gnupg:/home/${USER_NAME}/.gnupg${V_OPTS:-}" \ -v "${HOME}/.gnupg:${DOCKER_HOME_DIR}/.gnupg${V_OPTS:-}" \
-u "${USER_ID}" \ -u "${USER_ID}" \
"hadoop-build-${USER_ID}" "$@" "hadoop-build-${USER_ID}" "$@"