代码拉取完成,页面将自动刷新
#!/bin/bash
# Copyright (c) 2024 Phytium Technology Co., Ltd. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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 tengrui_d | 1 for tenglong_e | 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=tengrui_d
;;
1)
DEVICE=tenglong_e
;;
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
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
#apply 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
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 #### apply patch end ####\n \033[0m"
echo -e "\033[32m #### sync phytium end! #### \033[0m"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。