From 5fe473a5bb287cc5b7a7fb725c37c9a3e96b0391 Mon Sep 17 00:00:00 2001 From: cc <18856836718@163.com> Date: Mon, 1 Apr 2024 17:39:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0a-fot=20=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=20=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/download/download_config.py | 4 ++ .../src/download/download_utils.py | 49 +++---------------- tools/install_dependency/src/download_main.py | 4 +- .../install_dependency/src/machine/machine.py | 22 ++++----- 4 files changed, 25 insertions(+), 54 deletions(-) diff --git a/tools/install_dependency/src/download/download_config.py b/tools/install_dependency/src/download/download_config.py index 262519e..df28f5a 100644 --- a/tools/install_dependency/src/download/download_config.py +++ b/tools/install_dependency/src/download/download_config.py @@ -28,6 +28,10 @@ LkpTests = { "DevkitDistribute": "https://gitee.com/openeuler/devkit-pipeline/releases/download/v0.2/devkit_distribute.tar.gz", } +A_FOT = { + "component_name": "A-FOT", + "file": "https://gitee.com/openeuler/devkit-pipeline/releases/download/v0.2/a-fot.tar.gz", +} DevKitWeb = { "component_name": "DevKitWeb", diff --git a/tools/install_dependency/src/download/download_utils.py b/tools/install_dependency/src/download/download_utils.py index 2416e42..fd224b5 100644 --- a/tools/install_dependency/src/download/download_utils.py +++ b/tools/install_dependency/src/download/download_utils.py @@ -1,8 +1,6 @@ import os import platform import subprocess -import shutil -import tarfile import urllib.error import warnings @@ -14,16 +12,6 @@ from constant import URL, FILE, SAVE_PATH, SHA256, DEFAULT_PATH warnings.filterwarnings("ignore", message='Unverified HTTPS request') -# A-FOT files -BASE_URL = "https://gitee.com/openeuler/A-FOT/raw/master/{}" -A_FOT = "a-fot" -A_FOT_INI = "a-fot.ini" -AUTO_FDO_SH = "auto_fdo.sh" -AUTO_BOLT_SH = "auto_bolt.sh" -AUTO_PREFETCH = "auto_prefetch.sh" -SPLIT_JSON_PY = "split_json.py" -FILE_LIST = (A_FOT, A_FOT_INI, AUTO_FDO_SH, AUTO_BOLT_SH, AUTO_PREFETCH, SPLIT_JSON_PY) - component_collection_map = { "BiShengCompiler": { @@ -86,41 +74,22 @@ component_collection_map = { } }, + "A-FOT": { + "download file": { + URL: f"{download_config.A_FOT.get(FILE)}", + SAVE_PATH: f"{os.path.join(DEFAULT_PATH, download_config.A_FOT.get(FILE).split('/')[-1])}", + } + }, + "DevKitWeb": { "download file": { URL: f"{download_config.DevKitWeb.get(FILE)}", SAVE_PATH: f"{os.path.join(DEFAULT_PATH, download_config.DevKitWeb.get(FILE).split('/')[-1])}", }, - } + }, } -def download_a_fot(): - tar_file = os.path.join(DEFAULT_PATH, "a-fot.tar.gz") - if os.path.exists(tar_file) and os.path.isfile(tar_file): - return True - - saved_path = os.path.join(DEFAULT_PATH, A_FOT) - try: - os.mkdir(saved_path) - except FileExistsError as e: - pass - - try: - for f in FILE_LIST: - print(f"Downloading from {BASE_URL.format(f)}") - wget.download(BASE_URL.format(f), os.path.join(saved_path, f)) - print() - with tarfile.open(tar_file, "w:gz") as t: - t.add(saved_path, arcname="a-fot") - return True - except Exception as e: - print(e) - return False - finally: - shutil.rmtree(saved_path) - - def download_dependence(component_list): if not os.path.exists(DEFAULT_PATH): os.mkdir(DEFAULT_PATH) @@ -134,8 +103,6 @@ def download_dependence(component_list): continue shell_dict = component_collection_map.get(component_name) ret = ret and download_dependence_handler(shell_dict) - if "A-FOT" in component_list: - ret &= download_a_fot() return ret diff --git a/tools/install_dependency/src/download_main.py b/tools/install_dependency/src/download_main.py index 2c0d0aa..8100758 100644 --- a/tools/install_dependency/src/download_main.py +++ b/tools/install_dependency/src/download_main.py @@ -23,12 +23,12 @@ iso_collection_map = { "download file": { URL: f"{component.get(FILE)}", - SAVE_PATH: f"{os.path.join('/', component.get(FILE).split('/')[-1])}" + SAVE_PATH: f"{os.path.join('./', component.get(FILE).split('/')[-1])}" }, "download sha256": { URL: f"{component.get(SHA256)}", - SAVE_PATH: f"{os.path.join('/', component.get(SHA256).split('/')[-1])}" + SAVE_PATH: f"{os.path.join('./', component.get(SHA256).split('/')[-1])}" } } for component in ( download_config.OpenEuler_2003_LTS, diff --git a/tools/install_dependency/src/machine/machine.py b/tools/install_dependency/src/machine/machine.py index 590b038..3c8323b 100644 --- a/tools/install_dependency/src/machine/machine.py +++ b/tools/install_dependency/src/machine/machine.py @@ -105,6 +105,17 @@ class Machine: transport.connect(username=user, pkey=pkey) return transport + def install_components(self): + if self.mirrors: + self.install_component("OpenEulerMirrorISO") + for component in self.component_list: + self.install_component(component) + if self.mirrors: + self.install_component("UnOpenEulerMirrorISO") + + self.clear_tmp_file_at_remote_machine( + self.ssh_client(), [os.path.join("/tmp/", constant.DEPENDENCY_DIR)]) + def install_component(self, component_name): ssh_client = self.ssh_client() sftp_client = self.sftp_client() @@ -118,17 +129,6 @@ class Machine: ssh_client.close() sftp_client.close() - def install_components(self): - if self.mirrors: - self.install_component("OpenEulerMirrorISO") - for component in self.component_list: - self.install_component(component) - if self.mirrors: - self.install_component("UnOpenEulerMirrorISO") - - self.clear_tmp_file_at_remote_machine( - self.ssh_client(), [os.path.join("/tmp/", constant.DEPENDENCY_DIR)]) - def install_component_handler(self, component_name, sftp_client, ssh_client): component_name_to_func_dict: typing.Dict[ str, typing.Callable[[str, paramiko.SFTPClient, paramiko.SSHClient], typing.Any]] = { -- Gitee