From ff3d747bcee3fc7ab58cdc517a394c5265c119fb Mon Sep 17 00:00:00 2001 From: pan <601760354@163.com> Date: Thu, 28 Mar 2024 19:08:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=BB=93=E6=9D=9F=E5=88=A0?= =?UTF-8?q?=E9=99=A4/tmp=E4=B8=8B=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=20cbuidler=E5=AE=89=E8=A3=85=E6=97=A0=E6=84=9F?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/install_dependency/src/constant.py | 2 +- .../src/machine/local_machine.py | 14 +++++++++++--- tools/install_dependency/src/machine/machine.py | 13 +++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/install_dependency/src/constant.py b/tools/install_dependency/src/constant.py index 1e3ad0e..46a2883 100644 --- a/tools/install_dependency/src/constant.py +++ b/tools/install_dependency/src/constant.py @@ -14,7 +14,7 @@ INSTRUCTION = "instruction" ROLE_COMPONENT = { SCANNER: ["BiShengJDK17"], - C_BUIDLER: ["GCCforOpenEuler", "BiShengCompiler", "BiShengJDK17", "A-FOT"], + C_BUIDLER: ["GCCforOpenEuler", "BiShengCompiler", "BiShengJDK17", "A-FOT", "NonInvasiveSwitching"], JAVA_BUILDER: ["BiShengJDK17", "BiShengJDK8"], EXECUTOR: ["BiShengJDK17", "LkpTests"] } diff --git a/tools/install_dependency/src/machine/local_machine.py b/tools/install_dependency/src/machine/local_machine.py index af34286..fece548 100644 --- a/tools/install_dependency/src/machine/local_machine.py +++ b/tools/install_dependency/src/machine/local_machine.py @@ -39,6 +39,8 @@ class LocalMachine: if self.mirrors: self.install_component("UnOpenEulerMirrorISO") + self.clear_tmp_file_at_local_machine([os.path.join("/tmp/", constant.DEPENDENCY_DIR)]) + def check_is_aarch64(self): machine_type = os.uname().machine.lower() LOGGER.info(f"{self.ip} machine type: {machine_type}") @@ -267,9 +269,15 @@ class LocalMachine: def clear_tmp_file_at_local_machine(self, remote_file_list): LOGGER.debug(f"Clear tmp file at local machine {self.ip}") for remote_file in remote_file_list: - LOGGER.debug(f"Delete tmp file at local machine {self.ip}: {remote_file}") - subprocess.run(f"rm -f {remote_file}".split(' '), - capture_output=False, shell=False, stderr=subprocess.STDOUT) + try: + remote_file = os.path.realpath(remote_file) + if not remote_file.startswith(os.path.join("/tmp", constant.DEPENDENCY_DIR)): + continue + LOGGER.debug(f"Delete tmp file at local machine {self.ip}: {remote_file}") + subprocess.run(f"rm -fr {remote_file}".split(' '), + capture_output=False, shell=False, stderr=subprocess.STDOUT) + except Exception as e: + LOGGER.debug(str(e)) def do_nothing(self, component_name, sftp_client, ssh_client): return diff --git a/tools/install_dependency/src/machine/machine.py b/tools/install_dependency/src/machine/machine.py index 3fad35c..9779112 100644 --- a/tools/install_dependency/src/machine/machine.py +++ b/tools/install_dependency/src/machine/machine.py @@ -125,6 +125,9 @@ class Machine: 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]] = { @@ -366,8 +369,14 @@ class Machine: def clear_tmp_file_at_remote_machine(self, ssh_client, remote_file_list): LOGGER.debug(f"Clear tmp file at remote machine {self.ip}") for remote_file in remote_file_list: - LOGGER.debug(f"Delete tmp file at remote machine {self.ip}: {remote_file}") - ssh_client.exec_command(f"rm -f {remote_file}") + try: + remote_file = os.path.realpath(remote_file) + if not remote_file.startswith(os.path.join("/tmp", constant.DEPENDENCY_DIR)): + continue + LOGGER.debug(f"Delete tmp file at remote machine {self.ip}: {remote_file}") + ssh_client.exec_command(f"rm -fr {remote_file}") + except Exception as e: + LOGGER.debug(str(e)) def do_nothing(self, component_name, sftp_client, ssh_client): return -- Gitee