From 698c33a5ddc8bf8192631c06d21299c1f37a1be1 Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Mon, 4 Mar 2024 18:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86sh=E8=84=9A=E6=9C=AC=E6=96=87=E4=BB=B6?= =?UTF-8?q?,=20=E6=89=93=E5=8C=85=E8=87=B3=E4=BA=8C=E8=BF=9B=E5=88=B6?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 22 +++---- tools/download_dependency/src/download.py | 59 ++++--------------- .../src/download_config.py | 4 ++ .../install_dependency/src/machine/machine.py | 3 +- tools/install_dependency/src/utils.py | 10 ++++ 5 files changed, 38 insertions(+), 60 deletions(-) create mode 100644 tools/install_dependency/src/utils.py diff --git a/build.sh b/build.sh index e1ab6a2..634ef2b 100644 --- a/build.sh +++ b/build.sh @@ -5,20 +5,20 @@ set -e current_dir=$(cd $(dirname $0); pwd) -cd $current_dir -cp $current_dir/tools/download_dependency/src/* $current_dir/tools/install_dependency/src/ +cd ${current_dir} +cp ${current_dir}/tools/download_dependency/src/* ${current_dir}/tools/install_dependency/src/ -cd $current_dir/tools/download_dependency +cd ${current_dir}/tools/download_dependency pyinstaller -F ./src/download.py -p ./ -cd $current_dir/tools/install_dependency -pyinstaller -F ./src/devkitpipeline.py -p ./ +cd ${current_dir}/tools/install_dependency +pyinstaller -F ./src/devkitpipeline.py -p ./ --add-data "${current_dir}/component:component" -cp $current_dir/tools/install_dependency/config/machine.yaml $current_dir/tools/install_dependency/dist/machine.yaml -cp -rf $current_dir/component $current_dir/tools/install_dependency/dist/ -cp $current_dir/tools/download_dependency/dist/download $current_dir/tools/install_dependency/dist/ +cp ${current_dir}/tools/install_dependency/config/machine.yaml ${current_dir}/tools/install_dependency/dist/machine.yaml +cp -rf ${current_dir}/component ${current_dir}/tools/install_dependency/dist/ +cp ${current_dir}/tools/download_dependency/dist/download ${current_dir}/tools/install_dependency/dist/ -mkdir -p $current_dir/tools/install_dependency/v1.0/tools/ -cp -rf $current_dir/tools/install_dependency/dist/ $current_dir/tools/install_dependency/v1.0/tools/linux -cd $current_dir/tools/install_dependency/v1.0/ +mkdir -p ${current_dir}/tools/install_dependency/v1.0/tools/ +cp -rf ${current_dir}/tools/install_dependency/dist/ ${current_dir}/tools/install_dependency/v1.0/tools/linux +cd ${current_dir}/tools/install_dependency/v1.0/ tar -zcvf v1.0.tar.gz tools diff --git a/tools/download_dependency/src/download.py b/tools/download_dependency/src/download.py index b675de3..de344a1 100644 --- a/tools/download_dependency/src/download.py +++ b/tools/download_dependency/src/download.py @@ -15,57 +15,20 @@ DEFAULT_PATH = "./devkitdependencies" DEPENDENCY_FILE = "devkitdependencies.tar.gz" component_collection_map = { - "BiShengCompiler": { - f"wget -c {BiShengCompiler.get(FILE)} -O {os.path.join(DEFAULT_PATH, BiShengCompiler.get(FILE).split('/')[-1])}": + component.get("component_name"): { + "download file": { - URL: f"{BiShengCompiler.get(FILE)}", - SAVE_PATH: f"{os.path.join(DEFAULT_PATH, BiShengCompiler.get(FILE).split('/')[-1])}" + URL: f"{component.get(FILE)}", + SAVE_PATH: f"{os.path.join(DEFAULT_PATH, component.get(FILE).split('/')[-1])}" }, - f"wget -c {BiShengCompiler.get(SHA256)} -O {os.path.join(DEFAULT_PATH, BiShengCompiler.get(SHA256).split('/')[-1])}": + "download sha256": { - URL: f"{BiShengCompiler.get(SHA256)}", - SAVE_PATH: f"{os.path.join(DEFAULT_PATH, BiShengCompiler.get(SHA256).split('/')[-1])}" - }, - }, - - "GCCforOpenEuler": { - f"wget -c {GCCforOpenEuler.get(FILE)} -O {os.path.join(DEFAULT_PATH, GCCforOpenEuler.get(FILE).split('/')[-1])}": - { - URL: f"{GCCforOpenEuler.get(FILE)}", - SAVE_PATH: f"{os.path.join(DEFAULT_PATH, GCCforOpenEuler.get(FILE).split('/')[-1])}" - }, - f"wget -c {GCCforOpenEuler.get(SHA256)} -O {os.path.join(DEFAULT_PATH, GCCforOpenEuler.get(SHA256).split('/')[-1])}": - { - URL: f"{GCCforOpenEuler.get(SHA256)}", - SAVE_PATH: f"{os.path.join(DEFAULT_PATH, GCCforOpenEuler.get(SHA256).split('/')[-1])}" - } - }, - - "BiShengJDK8": { - f"wget -c {BiShengJDK8.get(FILE)} -O {os.path.join(DEFAULT_PATH, BiShengJDK8.get(FILE).split('/')[-1])}": - { - URL: f"{BiShengJDK8.get(FILE)}", - SAVE_PATH: f"{os.path.join(DEFAULT_PATH, BiShengJDK8.get(FILE).split('/')[-1])}" - }, - f"wget -c {BiShengJDK8.get(SHA256)} -O {os.path.join(DEFAULT_PATH, BiShengJDK8.get(SHA256).split('/')[-1])}": - { - URL: f"{BiShengJDK8.get(SHA256)}", - SAVE_PATH: f"{os.path.join(DEFAULT_PATH, BiShengJDK8.get(SHA256).split('/')[-1])}" - } - }, - - "BiShengJDK17": { - f"wget -c {BiShengJDK17.get(FILE)} -O {os.path.join(DEFAULT_PATH, BiShengJDK17.get(FILE).split('/')[-1])}": - { - URL: f"{BiShengJDK17.get(FILE)}", - SAVE_PATH: f"{os.path.join(DEFAULT_PATH, BiShengJDK17.get(FILE).split('/')[-1])}" - }, - f"wget -c {BiShengJDK17.get(SHA256)} -O {os.path.join(DEFAULT_PATH, BiShengJDK17.get(SHA256).split('/')[-1])}": - { - URL: f"{BiShengJDK17.get(SHA256)}", - SAVE_PATH: f"{os.path.join(DEFAULT_PATH, BiShengJDK17.get(SHA256).split('/')[-1])}" + URL: f"{component.get(SHA256)}", + SAVE_PATH: f"{os.path.join(DEFAULT_PATH, component.get(SHA256).split('/')[-1])}" } - }, + } for component in ( + BiShengCompiler, GCCforOpenEuler, BiShengJDK8, BiShengJDK17 + ) } @@ -115,6 +78,6 @@ if __name__ == '__main__': print("-- Delete dependencies directory. --") else: print("-- Download dependencies failed. Please try execute download tool again. --") - except Exception as e: + except (KeyboardInterrupt, Exception) as e: print(f"Download dependencies failed. {str(e)} Please try execute download tool again.") sys.exit(1) diff --git a/tools/download_dependency/src/download_config.py b/tools/download_dependency/src/download_config.py index b170a53..e7e1b15 100644 --- a/tools/download_dependency/src/download_config.py +++ b/tools/download_dependency/src/download_config.py @@ -1,16 +1,20 @@ BiShengCompiler = { + "component_name": "BiShengCompiler", "file": "https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_compiler/BiShengCompiler-3.2.0-aarch64-linux.tar.gz", "sha256": "https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_compiler/BiShengCompiler-3.2.0-aarch64-linux.tar.gz.sha256", } GCCforOpenEuler = { + "component_name": "GCCforOpenEuler", "file": "https://mirrors.huaweicloud.com/kunpeng/archive/compiler/kunpeng_gcc/gcc-10.3.1-2023.12-aarch64-linux.tar.gz", "sha256": "https://mirrors.huaweicloud.com/kunpeng/archive/compiler/kunpeng_gcc/gcc-10.3.1-2023.12-aarch64-linux.tar.gz.sha256", } BiShengJDK8 = { + "component_name": "BiShengJDK8", "file": "https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_jdk/bisheng-jdk-8u402-linux-aarch64.tar.gz", "sha256": "https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_jdk/bisheng-jdk-8u402-linux-aarch64.tar.gz.sha256", } BiShengJDK17 = { + "component_name": "BiShengJDK17", "file": "https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_jdk/bisheng-jdk-17.0.10-linux-aarch64.tar.gz", "sha256": "https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_jdk/bisheng-jdk-17.0.10-linux-aarch64.tar.gz.sha256", } diff --git a/tools/install_dependency/src/machine/machine.py b/tools/install_dependency/src/machine/machine.py index 0660369..e75f485 100644 --- a/tools/install_dependency/src/machine/machine.py +++ b/tools/install_dependency/src/machine/machine.py @@ -8,6 +8,7 @@ import constant from exception.connect_exception import CreatePkeyFailedException, ConnectRemoteException, \ NotMatchedMachineTypeException from download import component_collection_map +from utils import base_path LOGGER = logging.getLogger("install_dependency") @@ -135,7 +136,7 @@ class Machine: self.clear_tmp_file_at_remote_machine(ssh_client, remote_file_list) def transport_shell_file_and_execute(self, ssh_client, sftp_client, component_name, shell_file): - sh_file_local_path = os.path.join("./component", component_name, shell_file) + sh_file_local_path = os.path.join(base_path("component"), component_name, shell_file) if not os.path.exists(sh_file_local_path): LOGGER.error(f"{sh_file_local_path} not exists.") raise FileNotFoundError(f"local file {sh_file_local_path} not exists.") diff --git a/tools/install_dependency/src/utils.py b/tools/install_dependency/src/utils.py new file mode 100644 index 0000000..336dcc8 --- /dev/null +++ b/tools/install_dependency/src/utils.py @@ -0,0 +1,10 @@ +import os +import sys + + +def base_path(path): + if getattr(sys, 'frozen', False): + base_dir = sys._MEIPASS + else: + base_dir = os.path.dirname(__file__) + return os.path.join(base_dir, path) -- Gitee