提交 2314d770 编写于 作者: L Liu Jiaming 提交者: Xiangquan Xiao

bazel: introduce "--output_user_root" startup option

上级 29c7693f
.cache
docs
docker
scripts
...@@ -70,3 +70,6 @@ docs/demo_guide/*.record ...@@ -70,3 +70,6 @@ docs/demo_guide/*.record
# Bash Environment # Bash Environment
.dev_bash_hist .dev_bash_hist
# bazel cache and others
.cache/
...@@ -298,7 +298,8 @@ function warn_proprietary_sw() { ...@@ -298,7 +298,8 @@ function warn_proprietary_sw() {
} }
function release() { function release() {
RELEASE_DIR="${HOME}/.cache/apollo_release" CACHE_DIR="/apollo/.cache"
RELEASE_DIR="${CACHE_DIR}/apollo_release"
if [ -d "${RELEASE_DIR}" ]; then if [ -d "${RELEASE_DIR}" ]; then
rm -rf "${RELEASE_DIR}" rm -rf "${RELEASE_DIR}"
fi fi
......
...@@ -79,8 +79,8 @@ function start_build_docker() { ...@@ -79,8 +79,8 @@ function start_build_docker() {
function gen_docker() { function gen_docker() {
IMG="apolloauto/apollo:run-${MACHINE_ARCH}-20181017_1330" IMG="apolloauto/apollo:run-${MACHINE_ARCH}-20181017_1330"
RELEASE_DIR=${HOME}/.cache/apollo_release CACHE_ROOT_DIR="${DIR}/.cache"
APOLLO_DIR="${RELEASE_DIR}/apollo" APOLLO_DIR="${CACHE_ROOT_DIR}/apollo_release/apollo"
if [ ! -d "${APOLLO_DIR}" ]; then if [ ! -d "${APOLLO_DIR}" ]; then
echo "Release directory does not exist!" echo "Release directory does not exist!"
...@@ -102,7 +102,7 @@ function gen_docker() { ...@@ -102,7 +102,7 @@ function gen_docker() {
-d \ -d \
--name apollo_release \ --name apollo_release \
--net host \ --net host \
-v $HOME/.cache:/root/mnt \ -v ${CACHE_ROOT_DIR}:/root/mnt \
-w /apollo \ -w /apollo \
"$IMG" "$IMG"
...@@ -112,16 +112,11 @@ function gen_docker() { ...@@ -112,16 +112,11 @@ function gen_docker() {
RELEASE_TGZ="apollo_release.tar.gz" RELEASE_TGZ="apollo_release.tar.gz"
SEC_RELEASE_TGZ="sec_apollo_release.tar.gz" SEC_RELEASE_TGZ="sec_apollo_release.tar.gz"
if [ -e "$HOME/.cache/$RELEASE_TGZ" ]; then [ -e "${CACHE_ROOT_DIR}/${RELEASE_TGZ}" ] && rm -f "${CACHE_ROOT_DIR}/${RELEASE_TGZ}"
rm $HOME/.cache/$RELEASE_TGZ [ -e "${CACHE_ROOT_DIR}/${SEC_RELEASE_TGZ}" ] && rm -f "${CACHE_ROOT_DIR}/${SEC_RELEASE_TGZ}"
fi
if [ -e "$HOME/.cache/$SEC_RELEASE_TGZ" ]; then
rm $HOME/.cache/$SEC_RELEASE_TGZ
fi
# generate security release package # generate security release package
tar czf $HOME/.cache/$RELEASE_TGZ -C $HOME/.cache apollo_release tar czf "${CACHE_ROOT_DIR}/${RELEASE_TGZ}" -C "${CACHE_ROOT_DIR}" apollo_release
python modules/tools/ota/create_sec_package.py python modules/tools/ota/create_sec_package.py
docker exec apollo_release cp /root/mnt/${SEC_RELEASE_TGZ} /root docker exec apollo_release cp /root/mnt/${SEC_RELEASE_TGZ} /root
fi fi
...@@ -162,6 +157,7 @@ case $1 in ...@@ -162,6 +157,7 @@ case $1 in
gen_docker gen_docker
;; ;;
*) *)
# TODO(storypku): fix user account issue
docker exec -u $USER apollo_dev_$USER bash -c "./apollo.sh $@" docker exec -u $USER apollo_dev_$USER bash -c "./apollo.sh $@"
;; ;;
esac esac
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
############################################################################### ###############################################################################
APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd -P)"
CACHE_ROOT_DIR="${APOLLO_ROOT_DIR}/.cache"
INCHINA="no" INCHINA="no"
LOCAL_IMAGE="no" LOCAL_IMAGE="no"
...@@ -86,7 +88,6 @@ do ...@@ -86,7 +88,6 @@ do
done done
} }
APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
if [ ! -e /apollo ]; then if [ ! -e /apollo ]; then
sudo ln -sf ${APOLLO_ROOT_DIR} /apollo sudo ln -sf ${APOLLO_ROOT_DIR} /apollo
...@@ -160,8 +161,7 @@ IMG=${DOCKER_REPO}:$VERSION ...@@ -160,8 +161,7 @@ IMG=${DOCKER_REPO}:$VERSION
function local_volumes() { function local_volumes() {
# Apollo root and bazel cache dirs are required. # Apollo root and bazel cache dirs are required.
volumes="-v $APOLLO_ROOT_DIR:/apollo \ volumes="-v $APOLLO_ROOT_DIR:/apollo"
-v $HOME/.cache:${DOCKER_HOME}/.cache"
case "$(uname -s)" in case "$(uname -s)" in
Linux) Linux)
case "$(lsb_release -r | cut -f2)" in case "$(lsb_release -r | cut -f2)" in
...@@ -179,8 +179,6 @@ function local_volumes() { ...@@ -179,8 +179,6 @@ function local_volumes() {
-v /lib/modules:/lib/modules" -v /lib/modules:/lib/modules"
;; ;;
Darwin) Darwin)
# MacOS has strict limitations on mapping volumes.
chmod -R a+wr ~/.cache/bazel
;; ;;
esac esac
echo "${volumes}" echo "${volumes}"
...@@ -223,8 +221,8 @@ function main(){ ...@@ -223,8 +221,8 @@ function main(){
if [ "$USER" == "root" ];then if [ "$USER" == "root" ];then
DOCKER_HOME="/root" DOCKER_HOME="/root"
fi fi
if [ ! -d "$HOME/.cache" ];then if [ ! -d "${CACHE_ROOT_DIR}" ]; then
mkdir "$HOME/.cache" mkdir "${CACHE_ROOT_DIR}"
fi fi
info "Starting docker container \"${APOLLO_CYBER}\" ..." info "Starting docker container \"${APOLLO_CYBER}\" ..."
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
# limitations under the License. # limitations under the License.
############################################################################### ###############################################################################
APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
CACHE_ROOT_DIR="${APOLLO_ROOT_DIR}/.cache"
LOCAL_IMAGE="no" LOCAL_IMAGE="no"
FAST_BUILD_MODE="no" FAST_BUILD_MODE="no"
FAST_TEST_MODE="no" FAST_TEST_MODE="no"
...@@ -85,6 +88,7 @@ do ...@@ -85,6 +88,7 @@ do
fi fi
done done
} }
function set_registry_mirrors() function set_registry_mirrors()
{ {
sed -i '$aDOCKER_OPTS=\"--registry-mirror=http://hub-mirror.c.163.com\"' /etc/default/docker sed -i '$aDOCKER_OPTS=\"--registry-mirror=http://hub-mirror.c.163.com\"' /etc/default/docker
...@@ -92,7 +96,6 @@ sed -i '$i ,"registry-mirrors": [ "http://hub-mirror.c.163.com"]' /etc/docker/d ...@@ -92,7 +96,6 @@ sed -i '$i ,"registry-mirrors": [ "http://hub-mirror.c.163.com"]' /etc/docker/d
service docker restart service docker restart
} }
APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd -P )"
if [ "$(readlink -f /apollo)" != "${APOLLO_ROOT_DIR}" ]; then if [ "$(readlink -f /apollo)" != "${APOLLO_ROOT_DIR}" ]; then
sudo ln -snf ${APOLLO_ROOT_DIR} /apollo sudo ln -snf ${APOLLO_ROOT_DIR} /apollo
...@@ -207,8 +210,7 @@ LOCAL_THIRD_PARTY_VOLUME_IMAGE=${DOCKER_REPO}:local_third_party_volume-${ARCH}-l ...@@ -207,8 +210,7 @@ LOCAL_THIRD_PARTY_VOLUME_IMAGE=${DOCKER_REPO}:local_third_party_volume-${ARCH}-l
function local_volumes() { function local_volumes() {
set +x set +x
# Apollo root and bazel cache dirs are required. # Apollo root and bazel cache dirs are required.
volumes="-v $APOLLO_ROOT_DIR:/apollo \ volumes="-v $APOLLO_ROOT_DIR:/apollo"
-v $HOME/.cache:${DOCKER_HOME}/.cache"
APOLLO_TELEOP="${APOLLO_ROOT_DIR}/../apollo-teleop" APOLLO_TELEOP="${APOLLO_ROOT_DIR}/../apollo-teleop"
if [ -d ${APOLLO_TELEOP} ]; then if [ -d ${APOLLO_TELEOP} ]; then
volumes="-v ${APOLLO_TELEOP}:/apollo/modules/teleop ${volumes}" volumes="-v ${APOLLO_TELEOP}:/apollo/modules/teleop ${volumes}"
...@@ -231,8 +233,6 @@ function local_volumes() { ...@@ -231,8 +233,6 @@ function local_volumes() {
-v /lib/modules:/lib/modules" -v /lib/modules:/lib/modules"
;; ;;
Darwin) Darwin)
# MacOS has strict limitations on mapping volumes.
chmod -R a+wr ~/.cache/bazel
;; ;;
esac esac
echo "${volumes}" echo "${volumes}"
...@@ -280,7 +280,7 @@ function main(){ ...@@ -280,7 +280,7 @@ function main(){
if [ $? == 0 ]; then if [ $? == 0 ]; then
if [[ "$(docker inspect --format='{{.Config.Image}}' $APOLLO_DEV 2> /dev/null)" != "$APOLLO_DEV_IMAGE" ]]; then if [[ "$(docker inspect --format='{{.Config.Image}}' $APOLLO_DEV 2> /dev/null)" != "$APOLLO_DEV_IMAGE" ]]; then
rm -rf $APOLLO_ROOT_DIR/bazel-* rm -rf $APOLLO_ROOT_DIR/bazel-*
rm -rf $HOME/.cache/bazel/* rm -rf ${CACHE_ROOT_DIR}/bazel/*
fi fi
docker stop $APOLLO_DEV 1>/dev/null docker stop $APOLLO_DEV 1>/dev/null
docker rm -v -f $APOLLO_DEV 1>/dev/null docker rm -v -f $APOLLO_DEV 1>/dev/null
...@@ -350,8 +350,8 @@ function main(){ ...@@ -350,8 +350,8 @@ function main(){
if [ "$USER" == "root" ];then if [ "$USER" == "root" ];then
DOCKER_HOME="/root" DOCKER_HOME="/root"
fi fi
if [ ! -d "$HOME/.cache" ];then if [ ! -d "${CACHE_ROOT_DIR}" ]; then
mkdir "$HOME/.cache" mkdir "${CACHE_ROOT_DIR}"
fi fi
info "Starting docker container \"${APOLLO_DEV}\" ..." info "Starting docker container \"${APOLLO_DEV}\" ..."
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")/../.." && pwd )" APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")/../.." && pwd )"
CACHE_ROOT_DIR="${APOLLO_ROOT_DIR}/.cache"
# the machine type, currently support x86_64, aarch64 # the machine type, currently support x86_64, aarch64
MACHINE_ARCH=$(uname -m) MACHINE_ARCH=$(uname -m)
...@@ -80,8 +82,8 @@ function main() { ...@@ -80,8 +82,8 @@ function main() {
if [ "$USER" == "root" ];then if [ "$USER" == "root" ];then
DOCKER_HOME="/root" DOCKER_HOME="/root"
fi fi
if [ ! -d "$HOME/.cache" ];then if [ ! -d "${CACHE_ROOT_DIR}" ]; then
mkdir "$HOME/.cache" mkdir "${CACHE_ROOT_DIR}"
fi fi
DOCKER_CMD="nvidia-docker" DOCKER_CMD="nvidia-docker"
...@@ -96,7 +98,6 @@ function main() { ...@@ -96,7 +98,6 @@ function main() {
-v ${HOME}/data:/apollo/data \ -v ${HOME}/data:/apollo/data \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \ -v /tmp/.X11-unix:/tmp/.X11-unix:rw \
-v /etc/localtime:/etc/localtime:ro \ -v /etc/localtime:/etc/localtime:ro \
-v $HOME/.cache:${DOCKER_HOME}/.cache \
-w /apollo \ -w /apollo \
-e DISPLAY=${display} \ -e DISPLAY=${display} \
-e RELEASE_DOCKER=1 \ -e RELEASE_DOCKER=1 \
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
############################################################################### ###############################################################################
APOLLO_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" APOLLO_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
CACHE_DIR="${APOLLO_ROOT}/.cache"
function update() { function update() {
UPDATE_TAG=$(python ${APOLLO_ROOT}/modules/tools/ota/query_client.py) UPDATE_TAG=$(python ${APOLLO_ROOT}/modules/tools/ota/query_client.py)
...@@ -31,28 +32,26 @@ function update() { ...@@ -31,28 +32,26 @@ function update() {
if [ "$user_agreed" != "y" ] && [ "$user_agreed" != "Y" ]; then if [ "$user_agreed" != "y" ] && [ "$user_agreed" != "Y" ]; then
exit 1 exit 1
fi fi
cp ${APOLLO_ROOT}/scripts/ota.sh /home/$DOCKER_USER/.cache/ cp ${APOLLO_ROOT}/scripts/ota.sh "${CACHE_DIR}"
ssh $DOCKER_USER@localhost bash /home/$DOCKER_USER/.cache/ota.sh download $UPDATE_TAG ssh $DOCKER_USER@localhost bash ${CACHE_DIR}/ota.sh download $UPDATE_TAG
python ${APOLLO_ROOT}/modules/tools/ota/verify_client.py python ${APOLLO_ROOT}/modules/tools/ota/verify_client.py
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
exit 1 exit 1
fi fi
if [ -e "$HOME/.cache/apollo_release" ]; then [ -e "${CACHE_DIR}/apollo_release" ] && rm -rf "${CACHE_DIR}/apollo_release"
rm -rf "$HOME/.cache/apollo_release" tar xzf ${CACHE_DIR}/apollo_release.tar.gz -C ${CACHE_DIR}
fi
tar xzf /home/$DOCKER_USER/.cache/apollo_release.tar.gz -C /home/$DOCKER_USER/.cache
NEW_TAG="${UPDATE_TAG}-local" NEW_TAG="${UPDATE_TAG}-local"
ssh $DOCKER_USER@localhost bash /home/$DOCKER_USER/.cache/ota.sh setup $NEW_TAG ssh $DOCKER_USER@localhost bash ${CACHE_DIR}/ota.sh setup $NEW_TAG
python ${APOLLO_ROOT}/modules/tools/ota/update_client.py ${UPDATE_TAG} python ${APOLLO_ROOT}/modules/tools/ota/update_client.py ${UPDATE_TAG}
} }
function clean() { function clean() {
rm -rf $HOME/.cache/apollo_update rm -rf ${CACHE_DIR}/apollo_update
rm -rf $HOME/.cache/apollo_release.tar.gz rm -rf ${CACHE_DIR}/apollo_release.tar.gz
rm -rf $HOME/.cache/sec_apollo_release.tar.gz rm -rf ${CACHE_DIR}/sec_apollo_release.tar.gz
rm -rf $HOME/.cache/ota.sh rm -rf ${CACHE_DIR}/ota.sh
docker stop test_container 1>/dev/null docker stop test_container 1>/dev/null
docker rm test_container 1>/dev/null docker rm test_container 1>/dev/null
} }
...@@ -78,7 +77,7 @@ function download() { ...@@ -78,7 +77,7 @@ function download() {
docker stop test_container 1>/dev/null docker stop test_container 1>/dev/null
docker rm -f test_container 1>/dev/null docker rm -f test_container 1>/dev/null
fi fi
docker run -d -it --name test_container -v $HOME/.cache:/root/mnt $UPDATE_TAG docker run -d -it --name test_container -v ${CACHE_DIR}:/root/mnt $UPDATE_TAG
docker exec test_container cp /root/sec_apollo_release.tar.gz /root/mnt docker exec test_container cp /root/sec_apollo_release.tar.gz /root/mnt
} }
......
...@@ -12,6 +12,7 @@ startup --batch_cpu_scheduling ...@@ -12,6 +12,7 @@ startup --batch_cpu_scheduling
startup --host_jvm_args=-XX:-UseParallelGC startup --host_jvm_args=-XX:-UseParallelGC
startup --output_user_root=/apollo/.cache/bazel
# +------------------------------------------------------------+ # +------------------------------------------------------------+
# | Test Configurations | # | Test Configurations |
# +------------------------------------------------------------+ # +------------------------------------------------------------+
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册