代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony-SIG/ohos_cordova 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
# Copyright (c) 2023 Huawei Device Co., Ltd.
# 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.
ROOT_DIR=$(pwd)
NODE_HOME=$ROOT_DIR/node-v16.15.0-linux-x64
NODE_URL=https://nodejs.org/download/release/v16.15.0/node-v16.15.0-linux-x64.tar.gz
SDK_API9_URL=https://mirrors.huaweicloud.com/openharmony/os/3.2.2/ohos-sdk-windows_linux-public.tar.gz
SDK_API9_SHASUM="edb094e4ce2739a5722ecd6ccddbfea9c8688d46de1144221584e867a8ab11ca9943a3b3d6ad189c553289e091395c719920b96264022a4d47240108f295dee9"
SDK_API10_URL=http://download.ci.openharmony.cn/version/Release_Version/OpenHarmony_4.0.10.15_sp1/20231106_190927/version-Release_Version-OpenHarmony_4.0.10.15_sp1-20231106_190927-ohos-sdk-full_4.0-release.tar.gz
SDK_API10_SHASUM="abcb530f96189e01bc40ef50e6cd256aba1cd8b2811598f7dea24ff0582708e3aa12ca28324d628c86c538384e1268396a171e30c06021a4544e089151c038f9"
SDK_API11_URL="https://cidownload.openharmony.cn/version/Master_Version/ohos-sdk-full/20240126_034018/version-Master_Version-ohos-sdk-full-20240126_034018-ohos-sdk-full.tar.gz"
SDK_API11_SHASUM="7ade43b88bd2aa86904b1f71766a7ba3252142f926a305e795daaa3a4225c82ec5704d277d5dfe8f17ff9e20db72e24f8ac3f15234ad96361f0dfee6376ed2c9"
# SDK_API11_URL=https://cidownload.openharmony.cn/version/Master_Version/OpenHarmony_5.0.0.17_dev/20240322_020126/version-Master_Version-OpenHarmony_5.0.0.17_dev-20240322_020126-ohos-sdk-full.tar.gz
# SDK_API11_SHASUM="55e2fa2ed02409a7fa2ffbcacd5c509a12391c388329d80cd4c0f1099985d4821208652673d989b13d1a18bbf659a6e595f98e1b9a823adaef7947e0183b5cb8"
SHASUM_FILE=SHA512SUM
API_VERSION=
SDK_API9_DIR=$ROOT_DIR/ohos-sdk-9
SDK9_PKG_NAME=ohos-sdk-9.tar.gz
SDK_API10_DIR=$ROOT_DIR/ohos-sdk-10
SDK10_PKG_NAME=ohos-sdk-10.tar.gz
SDK_API11_DIR=$ROOT_DIR/ohos-sdk-11
SDK11_PKG_NAME=ohos-sdk-11.tar.gz
SDK_DIR=
SDK_URL=
SDK_PKG_NAME=
SDK_SHASUM=
OHOS_SDK_HOME=
COMPONT_NAME=
echo "ROOT_DIR=$ROOT_DIR"
function prepare_nodejs() {
echo "prepare nodejs ############"
if [ ! -d "$NODE_HOME" ]
then
wget --no-check-certificate $NODE_URL
if [ $? -ne 0 ]
then
echo "download nodejs failed!"
return 1
fi
local node_name=${NODE_URL##*/}
tar -zxf $node_name
chmod 777 $NODE_HOME/bin/*
fi
export PATH=$NODE_HOME:$PATH
export NODE_HOME=${NODE_HOME}
export PATH=$NODE_HOME/bin:$PATH
$NODE_HOME/bin/npm config set @ohos:registry=https://repo.harmonyos.com/npm/
$NODE_HOME/bin/npm config set lockfile=false
}
function get_samples_modules() {
local olddir=`pwd`
local name=$1
local retval=0
local modulesflag=false
local path=
local url=
local branch=
cd $ROOT_DIR/openharmony_tpc_samples
while read line
do
local tmp=`echo $line | grep submodule`
if [ ! -z "$tmp" ]
then
if [ $modulesflag == true ]
then
break
fi
tmp=`echo $line | grep $name`
if [ ! -z "$tmp" ]
then
modulesflag=true
continue
fi
fi
if [ $modulesflag == true ]
then
tmp=`echo $line | grep "path"`
if [ ! -z "$tmp" ]
then
path=${line##*"= "}
path=${path%/*}
continue
fi
tmp=`echo $line | grep "url"`
if [ ! -z "$tmp" ]
then
url=${line##*"= "}
continue
fi
tmp=`echo $line | grep "branch"`
if [ ! -z "$tmp" ]
then
branch=${line##*"= "}
continue
fi
fi
done < .gitmodules
if [ $modulesflag == true ]
then
cd $path
if [ $? -ne 0 ]
then
retval=1
else
git config http.sslverify false # 关闭SSL校验
if [ -z $branch ]
then
git lfs clone $url --recursive
else
git lfs clone $url -b $branch --recursive
fi
retval=$?
fi
fi
cd $olddir
return $retval
}
function get_openharmony_tpc_samples() {
local diff_url=$1.diff
local diff_name=${diff_url##*/}
local retval=1
local compont_name=
if [ ! -f $diff_name ]
then
wget --no-check-certificate $diff_url
if [ $? -ne 0 ]
then
echo "download $diff_name failed!"
reutrn $retval
fi
fi
local diff_str=`cat $diff_name | grep "diff --git"`
for diff in $diff_str
do
local tmp=`echo $diff | grep "/"`
if [ ! -z "$tmp" ]
then
retval=0
tmp=${tmp#*/}
local tmp_name=${tmp%%/*}
if [ -d $COMPONT_NAME/$tmp_name ]
then
if [ -z $compont_name ]
then
compont_name=$tmp_name
else
if [ "$compont_name" != "$tmp_name" ] # 判断是否一次PR提交多个demo的修改
then
echo "One submission only supports modification of one third-party library!"
retval=1
break
fi
fi
fi
fi
done
if [ $retval -eq 0 ]
then
if [ -e $COMPONT_NAME/.gitmodules ]
then
get_samples_modules $compont_name
fi
COMPONT_NAME=$COMPONT_NAME/$compont_name
fi
echo "COMPONT_NAME:$COMPONT_NAME"
return $retval
}
function init_sdk_whith_apiversion() {
local tmpVersion=`cat build-profile.json5 | grep compileSdkVersion`
echo "......init_sdk_whith_apiversion....."
echo "$tmpVersion"
tmpVersion=${tmpVersion##*: }
if [ "$tmpVersion" == "9," ]
then
echo "API9"
API_VERSION=9
SDK_DIR=$SDK_API9_DIR
SDK_URL=$SDK_API9_URL
SDK_PKG_NAME=$SDK9_PKG_NAME
SDK_SHASUM=$SDK_API9_SHASUM
elif [ "$tmpVersion" == "10," ]
then
echo "API10"
API_VERSION=10
SDK_DIR=$SDK_API10_DIR
SDK_URL=$SDK_API10_URL
SDK_PKG_NAME=$SDK10_PKG_NAME
SDK_SHASUM=$SDK_API10_SHASUM
elif [ "$tmpVersion" == "11," ]
then
echo "API11"
API_VERSION=11
SDK_DIR=$SDK_API11_DIR
SDK_URL=$SDK_API11_URL
SDK_PKG_NAME=$SDK11_PKG_NAME
SDK_SHASUM=$SDK_API11_SHASUM
else
echo "Get SDK Version Failed!"
cd $OLDPWD
return 0
fi
export OHOS_SDK_HOME=$SDK_DIR/linux
return 0
}
function get_aki_apiversion() {
local res = 0
cd aki/platform/ohos/publish
init_sdk_whith_apiversion
res=$?
cd $OLDPWD
export COMPONT_NAME=$COMPONT_NAME
return $res
}
function get_apiversion(){
local res=0
local pr_name=$1
if [[ $pr_name == *openharmony-tpc* ]]
then
pr_name=${pr_name#*openharmony-tpc/}
else
pr_name=${pr_name#*openharmony-sig/}
fi
COMPONT_NAME=${pr_name%/pulls*}
echo "COMPONT_NAME=$COMPONT_NAME"
if [ $COMPONT_NAME == "manifest" ]
then
echo "*************manifest***************";
return 0;
fi
if [ $COMPONT_NAME == aki ]
then
get_aki_apiversion
return $?
fi
if [ $COMPONT_NAME == "openharmony_tpc_samples" ]
then
get_openharmony_tpc_samples $1
if [ $? -ne 0 ]
then
echo "get_openharmony_tpc_samples failed!!!"
return 1
fi
fi
cd $COMPONT_NAME
init_sdk_whith_apiversion
res=$?
cd $OLDPWD
export COMPONT_NAME=$COMPONT_NAME
return $res
}
function prepare_ohpm() {
if [ ! -d ohpm ]
then
git clone https://gitee.com/zhong-luping/ohpm_tools.git
if [ $? -ne 0 ]
then
echo "failed to download ohpm tools!!!"
return 1
fi
cp ohpm_tools/ohpm.tar ./
tar -xf ohpm.tar
rm -rf ohpm.tar ohpm_tools
fi
return 0
}
function check_sdk_sum() {
if [ -z $SDK_DIR ]
then
echo "please get sdk version first!"
return 1
fi
if [ -d $SDK_DIR ]
then
if [ -f "$SDK_DIR/$SHASUM_FILE" ]
then
local shasum=`cat $SDK_DIR/$SHASUM_FILE`
shasum=${shasum:0:128}
if [ "$shasum" == "$SDK_SHASUM" ]
then
echo "no need change the sdk!!"
return 0
fi
echo "$shasum != $SDK_SHASUM"
echo "need change sdk!!"
fi
rm -rf $SDK_DIR*
echo "rm -rf $SDK_DIR"
fi
return 0
}
function prepare_sdk(){
old_dir=`pwd`
echo "prepare sdk ############################### API_VERSION=$API_VERSION"
echo "$old_dir"
check_sdk_sum
if [ $? -ne 0 ]
then
return 1
fi
if [ ! -d "$SDK_DIR" ]
then
if [ ! -f $SDK_PKG_NAME ]
then
curl -L $SDK_URL --output $SDK_PKG_NAME
if [ $? -ne 0 ]
then
echo "download sdk api $API_VERSION failed! sdk url:$SDK_URL"
rm -f $SDK_PKG_NAME
return 1
fi
fi
tar -zxf $SDK_PKG_NAME
mv ohos-sdk ohos-sdk-$API_VERSION
sha512sum $SDK_PKG_NAME > $SDK_DIR/$SHASUM_FILE
cd $SDK_DIR/linux
if [ $? -ne 0 ]
then
echo "prepare SDK $API_VERSION failed!"
return 1
fi
mkdir $API_VERSION
for file in $(ls ./)
do
if [ $file != "$API_VERSION" ]
then
mv $file $API_VERSION/
cd $API_VERSION/
unzip $file >> /dev/null
cd $OLDPWD
fi
echo "$file"
done
fi
if [ $API_VERSION -lt 11 ]
then
cd $SDK_DIR/linux/$API_VERSION/ets/build-tools/ets-loader
$NODE_HOME/bin/npm install
if [ $? -ne 0 ]
then
echo "ets-loader npm install failed!"
cd $old_dir
return 1
fi
cd $SDK_DIR/linux/$API_VERSION/js/build-tools/ace-loader
$NODE_HOME/bin/npm install
if [ $? -ne 0 ]
then
echo "ace-loader npm install failed!"
cd $old_dir
return 1
fi
fi
cd $old_dir
return 0
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。