代码拉取完成,页面将自动刷新
同步操作将从 Phytium嵌入式软件/Phytium-OpenHarmony-Device 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
function print_help(){
echo -e "\033[31m Help Info\033[0m"
echo -e "\033[31m USAGE: phytium_env.sh OHOS_PATH_ROOT DEVICE_ID\033[0m"
echo -e "\033[31m OHOS_PATH_ROOT: absolute path of openharmony root path\033[0m"
echo -e "\033[31m DEVICE_ID : 0 for d2000 | 1 for e2000 | 2 for phytiumpi-firefly \033[0m"
echo -e "\033[31m example: ./phytium_env.sh /home/phytium/OpenHarmony 1 \033[0m"
}
#check input parameters
if [ $# -lt 2 ];then
print_help
exit 1;
fi
OHOS_PATH_ROOT=$1
if [ ! -d $OHOS_PATH_ROOT ];then
echo -e "\033[31mMake sure the OHOS_PATH_ROOT($OHOS_PATH_ROOT) exist! \033[0m"
print_help
exit 1;
fi
DEVICE_ID=$2
case $DEVICE_ID in
0)
DEVICE=d2000
;;
1)
DEVICE=e2000
;;
2)
DEVICE=phytiumpi-firefly
;;
*)
echo -e "\033[31mMake sure the DEVICE_ID is correct! \033[0m"
print_help
exit 1;
esac
CLEAN=0
if [ $# -eq 3 ];then
CLEAN=$3
fi
echo -e "\033[32mTHE OHOS_PATH_ROOT: $OHOS_PATH_ROOT \033[0m"
echo -e "\033[32mTHE DEVICE: $DEVICE($DEVICE_ID) \033[0m"
echo -e "\033[32m #### sync phytium env start! #### \033[0m"
CURRENTPWD=$(pwd)
#sync device code
function rm_path(){
if [ -d $1 ];then
rm $1 -r
echo -e "\033[32m #### remove path $1 #### \033[0m"
fi
}
rm_path $OHOS_PATH_ROOT/device/soc/phytium
rm_path $OHOS_PATH_ROOT/device/board/phytium
rm_path $OHOS_PATH_ROOT/vendor/phytium
if [ $CLEAN -eq 0 ];then
{
#sync device_soc_phytium
echo -e "\033[32m #### sync device_soc_phytium #### \033[0m"
mkdir -p $OHOS_PATH_ROOT/device/soc/phytium/
cp device_soc_phytium/* $OHOS_PATH_ROOT/device/soc/phytium -R
echo -e "\033[32m #### sync device_soc_phytium end #### \033[0m"
#sync device_board_phytium
echo -e "\033[32m #### sync device_board_phytium #### \033[0m"
mkdir -p $OHOS_PATH_ROOT/device/board/phytium
cp device_board_phytium/* $OHOS_PATH_ROOT/device/board/phytium/ -R
chmod 777 $OHOS_PATH_ROOT/device/board/phytium/$DEVICE/kernel/*
echo -e "\033[32m #### sync device_board_phytium end #### \033[0m"
#sync vendor_phytium
echo -e "\033[32m #### sync vendor_phytium #### \033[0m"
mkdir -p $OHOS_PATH_ROOT/vendor/phytium
cp vendor_phytium/* $OHOS_PATH_ROOT/vendor/phytium/ -R
echo -e "\033[32m #### sync vendor_phytium end #### \033[0m"
}
fi
#applay patch for openharmony
####get_git_path(patch_name) get git path from patch name to git apply
function get_git_path(){
local path=$1
path=${path#*=}
path=${path%=*}
path=${path//-/\/}
echo $path
}
####apply_git_patch(patch_path) apply git patch in patch_path
function apply_git_patch(){
for file in `ls $1`
do
if [[ ! $file =~ ".patch" ]] && [[ ! $file =~ ".diff" ]]; then
continue
fi
git_path=$(get_git_path $file)/
if [ ! -d $OHOS_PATH_ROOT/$git_path ];then
echo -e "\033[31m$git_path not exit \033[0m"
continue
fi
cd $OHOS_PATH_ROOT/$git_path
if [ $CLEAN -eq 0 ];then
echo -e "\n\033[32m#### git apply $file #### \033[0m"
git apply $1/$file
echo -e "\033[32m#### git apply $file end#### \033[0m"
else
echo -e "\n\033[32m#### git reset $git_path #### \033[0m"
git clean -df
git checkout ./*
git lfs checkout
echo -e "\033[32m#### git reset $git_path end #### \033[0m"
fi
#git status
done
}
PATCH_PATH=$CURRENTPWD/device_board_phytium/common/patch
if [ $DEVICE == d2000 ]; then
PATCH_PATH=$CURRENTPWD/device_board_phytium/d2000/patch
fi
#PATCH_PATH=$OHOS_PATH_ROOT/device/board/phytium/common/patch
#if [ ! -d $PATCH_PATH ];then
# echo -e "\033[31mMake sure you have copied phytium device code to OHOS_PATH_ROOT! \033[0m"
# exit 1;
#fi
echo -e ""
echo -e "######################################################################"
echo -e "#### \033[32m Auto apply phytium_oh patchs start !\033[0m"
echo -e "#### \033[32m OHOS_PATH_ROOT: $OHOS_PATH_ROOT \033[0m"
echo -e "#### \033[32m PATCH_PATH : $PATCH_PATH \033[0m"
echo -e "#### \033[32m DEVICE : $DEVICE \033[0m"
echo -e "######################################################################"
CURRENTPWD=$(pwd)
apply_git_patch $PATCH_PATH
device_patch_path=$PATCH_PATH/$DEVICE
if [ -d $device_patch_path ];then
apply_git_patch $device_patch_path
fi
cd $CURRENTPWD
echo -e "\033[32m #### applay patch end ####\n \033[0m"
echo -e "\033[32m #### sync phytium end! #### \033[0m"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。