Last active
September 11, 2019 03:43
-
-
Save rming/ebefdd1daae00f4eb375af1e782b6217 to your computer and use it in GitHub Desktop.
自动根据分支下载代码的脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# 配置每个 fork 文件存储位置 | |
PATH_FORK=/data/forks/dragonpilot | |
PATH_GERNBY=${PATH_FORK}/gernby | |
PATH_OPENPILOT=${PATH_FORK}/openpilot | |
PATH_DRAGONPILOT=${PATH_FORK}/dragonpilot | |
# 配置每个 fork 的 git 地址 | |
GIT_GERNBY=https://github.com/Gernby/openpilot | |
GIT_OPENPILOT=https://github.com/commaai/openpilot | |
GIT_DRAGONPILOT=https://github.com/dragonpilot-community/dragonpilot | |
# 配置每个 fork 选取的 branch | |
BRANCH_GERNBY=kegman-plusGernby-0.6.2 | |
BRANCH_OPENPILOT=devel | |
BRANCH_DRAGONPILOT=devel-zhs | |
# 构建结果文件 | |
FILE_UI_BUILD=selfdrive/ui/ui.o | |
# OP的入口文件 | |
FILE_OP_LAUNCH=launch_openpilot.sh | |
# 创建 | |
FORK="OPENPILOT" | |
switch=`cat /sys/devices/virtual/switch/tri-state-key/state` | |
case "${switch}" in | |
"1") | |
FORK="GERNBY" | |
;; | |
"2") | |
FORK="OPENPILOT" | |
;; | |
"3") | |
FORK="DRAGONPILOT" | |
;; | |
esac | |
VAR_OP_PATH=`eval echo "$""PATH_${FORK}"` | |
VAR_OP_GIT=`eval echo "$""GIT_${FORK}"` | |
VAR_OP_BRANCH=`eval echo "$""BRANCH_${FORK}"` | |
OP_PATH=${VAR_OP_PATH} | |
OP_GIT=${VAR_OP_GIT} | |
OP_BRANCH=${VAR_OP_BRANCH} | |
# 创建目录 | |
if [ ! -d "${OP_PATH}" ]; then | |
mkdir -p "${OP_PATH}" | |
fi | |
# 克隆 | |
# todo: 使用本地proxy | |
if [ ! -f "${OP_PATH}/${FILE_OP_LAUNCH}" ]; then | |
git clone -b ${OP_BRANCH} ${OP_GIT} ${OP_PATH} | |
fi | |
# 创建软链 | |
ENV_OP_PATH=/data/openpilot | |
if [ -d "${ENV_OP_PATH}" ]; then | |
ms=`date +%s_%N` | |
mv "${ENV_OP_PATH}" "${PATH_FORK}/backup_${ms}" | |
fi | |
rm -f ${ENV_OP_PATH} | |
ln -sf ${OP_PATH} ${ENV_OP_PATH} | |
cd ${ENV_OP_PATH} | |
exec ./launch_openpilot.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment