1 Star 0 Fork 22

wuao2431/Phytium-OpenHarmony-TengruiD-X100

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
phytium_env.sh 4.38 KB
一键复制 编辑 原始数据 按行查看 历史
xiayan 提交于 2024-07-23 19:44 . update device code
#!/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"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lesliewow/phytium-openharmony-d2000-device.git
git@gitee.com:lesliewow/phytium-openharmony-d2000-device.git
lesliewow
phytium-openharmony-d2000-device
Phytium-OpenHarmony-TengruiD-X100
master

搜索帮助