1#!/bin/bash 2# Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14set -e 15while [ $# -gt 0 ]; do 16 case "$1" in 17 -skip-ssl|--skip-ssl) # wget skip ssl check, which will allow 18 # hacker to get and modify data stream between server and client! 19 SKIP_SSL=YES 20 ;; 21 -h|--help) 22 HELP=YES 23 ;; 24 --tool-repo) 25 TOOL_REPO="$2" 26 shift 27 ;; 28 --tool-repo=*) 29 TOOL_REPO="${1#--tool-repo=}" 30 ;; 31 --trusted-host) 32 TRUSTED_HOST="$2" 33 shift 34 ;; 35 --trusted-host=*) 36 TRUSTED_HOST="${1#--trusted-host=}" 37 ;; 38 --pypi-url) # python package index url 39 PYPI_URL="$2" 40 shift 41 ;; 42 --pypi-url=*) 43 PYPI_URL="${1#--pypi-url=}" 44 ;; 45 *) 46 echo "$0: Warning: unsupported parameter: $1" >&2 47 ;; 48 esac 49 shift 50done 51 52case $(uname -s) in 53 Linux) 54 55 host_platform=linux 56 ;; 57 Darwin) 58 host_platform=darwin 59 ;; 60 *) 61 echo "Unsupported host platform: $(uname -s)" 62 exit 1 63esac 64 65case $(uname -m) in 66 arm64) 67 68 host_cpu=arm64 69 ;; 70 *) 71 host_cpu=x86_64 72esac 73 74if [ "X${SKIP_SSL}" == "XYES" ];then 75 wget_ssl_check="--skip-ssl" 76else 77 wget_ssl_check='' 78fi 79 80if [ "X${HELP}" == "XYES" ];then 81 help="-h" 82else 83 help='' 84fi 85 86if [ ! -z "$TOOL_REPO" ];then 87 tool_repo="--tool-repo $TOOL_REPO" 88else 89 tool_repo='' 90fi 91 92if [ ! -z "$TRUSTED_HOST" ];then 93 trusted_host=$TRUSTED_HOST 94elif [ ! -z "$PYPI_URL" ];then 95 trusted_host=${PYPI_URL/#*:\/\//} # remove prefix part such as http:// https:// etc. 96 trusted_host=${trusted_host/%[:\/]*/} # remove suffix part including the port number 97else 98 trusted_host='repo.huaweicloud.com' 99fi 100 101if [ ! -z "$PYPI_URL" ];then 102 pypi_url=$PYPI_URL 103else 104 pypi_url='http://repo.huaweicloud.com/repository/pypi/simple' 105fi 106 107cpu="--host-cpu $host_cpu" 108platform="--host-platform $host_platform" 109 110script_path=$(cd $(dirname $0);pwd) 111code_dir=$(dirname ${script_path}) 112pip3 install --trusted-host $trusted_host -i $pypi_url rich 113echo "prebuilts_download start" 114python3 "arkcompiler/toolchain/build/prebuilts_download/prebuilts_download.py" $wget_ssl_check $tool_repo $help $cpu $platform 115echo "prebuilts_download end" 116 117echo -e "\n" 118