diff --git a/build.sh b/build.sh index fe0a533dc1324da4deb5ff665c7242b17af2881a..8bbb6cdf4c4c648b1786888759ce50f7425b6f06 100644 --- a/build.sh +++ b/build.sh @@ -10,6 +10,9 @@ tag="v0.1" mkdir -p "${current_dir}"/build bash "${current_dir}"/component/build_component.sh +if [[ "$?" -ne "0" ]]; then + exit 1 +fi bash "${current_dir}"/tools/distribute/build_devkit_distribute.sh diff --git a/component/LkpTests/build_lkp_tests_all.sh b/component/LkpTests/build_lkp_tests_all.sh index 303dc220689c33d2377f7ca8e3d81314bce9edff..dcae1fc6c85dba012f191b716e966c8f6d204156 100644 --- a/component/LkpTests/build_lkp_tests_all.sh +++ b/component/LkpTests/build_lkp_tests_all.sh @@ -8,12 +8,24 @@ function main() { upload_path=$1 echo "build LkpTests upload_path: " "${upload_path}" sh ${current_dir}/lkp_help/lkp_help.sh ${upload_path} + if [[ "$?" -ne "0" ]]; then + exit 1 + fi cd ${current_dir}/compatibility_help/ wget -c https://mirrors.huaweicloud.com/kunpeng/archive/compatibility_testing/compatibility_testing.tar.gz + if [[ "$?" -ne "0" ]]; then + exit 1 + fi sh ${current_dir}/compatibility_help/compatibility_help.sh ${current_dir}/compatibility_help ${upload_path} + if [[ "$?" -ne "0" ]]; then + exit 1 + fi /bin/cp -rf ${current_dir}/gem_dependencies.zip ${upload_path} + if [[ "$?" -ne "0" ]]; then + exit 1 + fi } main "$@" diff --git a/component/LkpTests/lkp_help/lkp_help.sh b/component/LkpTests/lkp_help/lkp_help.sh index 8c530ba6637f03c25815eb6c5074262aa6a8d44d..0de5e8f2df104c6b6a93b933a1528717101a91c4 100644 --- a/component/LkpTests/lkp_help/lkp_help.sh +++ b/component/LkpTests/lkp_help/lkp_help.sh @@ -12,14 +12,24 @@ function main() { fi git clone https://gitee.com/wu_fengguang/lkp-tests.git + if [[ "$?" -ne "0" ]]; then + exit 1 + fi + cd lkp-tests git apply ${current_dir}/devkit-pipeline.patch /bin/cp -rf ${current_dir}/compatibility-test ${current_dir}/lkp-tests/programs/compatibility-test dos2unix ${current_dir}/lkp-tests/programs/compatibility-test/run + if [[ "$?" -ne "0" ]]; then + exit 1 + fi cd ${current_dir} echo "tar -zcf lkp-tests.tar.gz ./lkp-tests" tar -zcf lkp-tests.tar.gz ./lkp-tests + if [[ "$?" -ne "0" ]]; then + exit 1 + fi echo "/bin/cp -rf lkp-tests.tar.gz ${upload_path}" /bin/cp -rf lkp-tests.tar.gz ${upload_path} diff --git a/component/OpenEulerMirrorISO/install.sh b/component/OpenEulerMirrorISO/install.sh index a6cd2bfb161a41f2f652f57909d97d8762ea6cea..3240bf7d5755b5a2a78aaa885b731efbdb7db073 100644 --- a/component/OpenEulerMirrorISO/install.sh +++ b/component/OpenEulerMirrorISO/install.sh @@ -14,7 +14,7 @@ function configure_local_mirror() { cat > /etc/yum.repos.d/local.repo <<'EOF' [local] name=local.repo -baseurl=file:///mnt +baseurl=file:///devkitmirror enabled=1 gpgcheck=0 EOF diff --git a/component/build_component.sh b/component/build_component.sh index 6cc48c66f3a534d321e9fecf6ea92fcc6ddd0fd7..5d83c27d4fe2e3c29eb5c6bac845db1ab807d4b2 100644 --- a/component/build_component.sh +++ b/component/build_component.sh @@ -15,6 +15,10 @@ function build_lkp_tests() { mkdir -p ${final_component_dir}/LkpTests bash ${current_dir}/LkpTests/build_lkp_tests_all.sh ${final_component_dir}/LkpTests + if [[ "$?" -ne "0" ]]; then + exit 1 + fi + cp -rf ${current_dir}/LkpTests/install.sh ${final_component_dir}/LkpTests cp -rf ${current_dir}/LkpTests/check_install_result.sh ${final_component_dir}/LkpTests } diff --git a/tools/distribute/build_devkit_distribute.sh b/tools/distribute/build_devkit_distribute.sh index 697704547c0b987663a9e0f1781a92561f21233a..7b99a89cfde3a8244c17fcd030c342a86a3740a7 100644 --- a/tools/distribute/build_devkit_distribute.sh +++ b/tools/distribute/build_devkit_distribute.sh @@ -40,4 +40,4 @@ cp devkit_pipeline_agent.tar.gz devkit_distribute/config tar -czf devkit_distribute.tar.gz devkit_distribute -cp devkit_distribute.tar.gz "${project_dir}"/build/component +/bin/cp -rf devkit_distribute.tar.gz "${project_dir}"/build/component/DevkitDistribute diff --git a/tools/install_dependency/src/lkp_collect_map.py b/tools/install_dependency/src/lkp_collect_map.py index a3a1b77a2ca5d56cab213fb7ad8aaa8fc840723e..040265eac12d248e2034b2771a305818017970c6 100644 --- a/tools/install_dependency/src/lkp_collect_map.py +++ b/tools/install_dependency/src/lkp_collect_map.py @@ -18,7 +18,7 @@ lkp_collection_map = { }, "DevkitDistribute": { "download file": { - "save_path": f"{os.path.join(base_path('component'), 'devkit_distribute.tar.gz')}", + "save_path": f"{os.path.join(base_path('component'), 'DevkitDistribute', 'devkit_distribute.tar.gz')}", } } } diff --git a/tools/install_dependency/src/machine/machine.py b/tools/install_dependency/src/machine/machine.py index fe3d10093a4b29d7fd9b84b8d860c30c6b0f2fd0..0a3cb64c89fd4e2f92fffb637e0b1828f3147136 100644 --- a/tools/install_dependency/src/machine/machine.py +++ b/tools/install_dependency/src/machine/machine.py @@ -12,7 +12,8 @@ from exception.connect_exception import CreatePkeyFailedException, ConnectRemote NotMatchedMachineTypeException from download import component_collection_map from lkp_collect_map import lkp_collection_map -from utils import base_path +from utils import (base_path, MKDIR_TMP_DEVKITDEPENDENCIES_CMD, YUM_INSTALL_LKP_DEPENDENCIES_CMD, + CHECK_HOME_SPACE_SUFFICIENT_FOR_MIRROR, CHECK_TMP_SPACE_SUFFICIENT_FOR_PACKAGE, PROMPT_MAP) LOGGER = logging.getLogger("install_dependency") SHELL_FILE_LIST = ["install.sh", "check_install_result.sh"] @@ -113,8 +114,8 @@ class Machine: return component_name_to_func_dict.get(component_name)(component_name, sftp_client, ssh_client) def lkptest_install_component_handle(self, component_name, sftp_client, ssh_client): - self._remote_exec_command(f"mkdir -p /tmp/{constant.DEPENDENCY_DIR}", ssh_client) - self._remote_exec_command("yum install -y git wget rubygems", ssh_client) + self._remote_exec_command(MKDIR_TMP_DEVKITDEPENDENCIES_CMD, ssh_client) + self._remote_exec_command(YUM_INSTALL_LKP_DEPENDENCIES_CMD, ssh_client) # 上传 lkp-tests.tar.gz文件 LOGGER.info(f"Install component in remote machine {self.ip}: {component_name}") @@ -193,6 +194,8 @@ class Machine: self.clear_tmp_file_at_remote_machine(ssh_client, remote_file_list) def deploy_iso_handle(self, component_name, sftp_client, ssh_client): + self._remote_exec_command(CHECK_HOME_SPACE_SUFFICIENT_FOR_MIRROR, ssh_client) + # 上传 镜像文件 LOGGER.info(f"Deploy component in remote machine {self.ip}: {component_name}") local_path = os.path.abspath(CommandLine.iso_path) @@ -227,7 +230,8 @@ class Machine: self.clear_tmp_file_at_remote_machine(ssh_client, remote_file_list) def default_install_component_handle(self, component_name, sftp_client, ssh_client): - self._remote_exec_command(f"mkdir -p /tmp/{constant.DEPENDENCY_DIR}", ssh_client) + self._remote_exec_command(MKDIR_TMP_DEVKITDEPENDENCIES_CMD, ssh_client) + self._remote_exec_command(CHECK_TMP_SPACE_SUFFICIENT_FOR_PACKAGE, ssh_client) # 上传 组件压缩包和校验文件 LOGGER.info(f"Install component in remote machine {self.ip}: {component_name}") @@ -272,13 +276,13 @@ class Machine: stdin, stdout, stderr = ssh_client.exec_command(cmd, timeout=90) except (paramiko.ssh_exception.SSHException, socket.timeout) as e: LOGGER.error(f"Remote machine {self.ip} exec '{cmd}' failed Please run this command in remote machine.") - raise OSError(f"Remote machine {self.ip} exec '{cmd}' failed Please run this command in remote machine.") + raise OSError(PROMPT_MAP.get(cmd, f"Remote machine {self.ip} exec '{cmd}' failed.")) exit_status = stdout.channel.recv_exit_status() LOGGER.debug(f"Remote machine {self.ip} exec '{cmd}' result: " f"{'success' if not exit_status else 'failed'}") if exit_status: LOGGER.error(f"Remote machine {self.ip} exec '{cmd}' failed Please run this command in remote machine.") - raise OSError(f"Remote machine {self.ip} exec '{cmd}' failed Please run this command in remote machine.") + raise OSError(PROMPT_MAP.get(cmd, f"Remote machine {self.ip} exec '{cmd}' failed.")) def transport_shell_file_and_execute(self, ssh_client, sftp_client, sh_file_local_path, sh_file_remote_path, sh_cmd): diff --git a/tools/install_dependency/src/utils.py b/tools/install_dependency/src/utils.py index 336dcc8f979a9d198aa8940a280846e09dbbde5a..5e631fa9a444c4c609bb68c42926c55dc8d9fd88 100644 --- a/tools/install_dependency/src/utils.py +++ b/tools/install_dependency/src/utils.py @@ -1,6 +1,18 @@ import os import sys +MKDIR_TMP_DEVKITDEPENDENCIES_CMD = "mkdir -p /tmp/devkitdependencies" +YUM_INSTALL_LKP_DEPENDENCIES_CMD = "yum install -y git wget rubygems" +CHECK_HOME_SPACE_SUFFICIENT_FOR_MIRROR = "[[ $(df -m /home | awk 'NR==2' | awk '{print $4}') -gt 17*1024 ]]" +CHECK_TMP_SPACE_SUFFICIENT_FOR_PACKAGE = "[[ $(df -m /tmp | awk 'NR==2' | awk '{print $4}') -gt 1024 ]]" + +PROMPT_MAP = { + MKDIR_TMP_DEVKITDEPENDENCIES_CMD: "Directory /tmp/devkitdependencies not exists.", + YUM_INSTALL_LKP_DEPENDENCIES_CMD: "Yum install dependencies failed.", + CHECK_HOME_SPACE_SUFFICIENT_FOR_MIRROR: "Machine /home space not sufficient for mirror.", + CHECK_TMP_SPACE_SUFFICIENT_FOR_PACKAGE: "Machine /tmp space not sufficient for package.", +} + def base_path(path): if getattr(sys, 'frozen', False):