From 2e9959da5a724f652b855207b8a0de53599fbe8b Mon Sep 17 00:00:00 2001 From: liuheng Date: Wed, 13 Sep 2023 09:47:57 +0800 Subject: [PATCH] =?UTF-8?q?fix=20gs=5Fsshexkey=E5=88=9B=E5=BB=BA=E4=BA=92?= =?UTF-8?q?=E4=BF=A1=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/gs_preinstall | 39 ++-------------------- script/gs_sshexkey | 2 ++ script/gspylib/common/copy_python_lib.py | 42 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 script/gspylib/common/copy_python_lib.py diff --git a/script/gs_preinstall b/script/gs_preinstall index 98512b2..8c6b56e 100644 --- a/script/gs_preinstall +++ b/script/gs_preinstall @@ -51,43 +51,8 @@ else: check_os_and_package_arch() check_python_version() check_python_compiler_option() - source = os.path.join(sys.path[0], '../lib/bcrypt/lib3.' + \ - str(sys.version_info[1]), '_bcrypt.abi3.so') - dest = os.path.join(sys.path[0], '../lib/bcrypt/') - cmd = f"cp {source} {dest}" - (status, output) = subprocess.getstatusoutput(cmd) - if status != 0: - GaussLog.exitWithError("cp file failed.\nError:%s\nThe cmd is: %s\n" % - (output, cmd)) - - source = os.path.join(sys.path[0], '../lib/_cffi_backend_3.' + \ - str(sys.version_info[1]), '_cffi_backend.so') - dest = os.path.join(sys.path[0], '../lib/') - cmd = f"cp {source} {dest}" - (status, output) = subprocess.getstatusoutput(cmd) - if status != 0: - GaussLog.exitWithError("cp file failed.\nError:%s\nThe cmd is: %s\n" % - (output, cmd)) - - - source = os.path.join(sys.path[0], '../lib/cryptography/hazmat/bindings/lib3.' + \ - str(sys.version_info[1]), '*.so') - dest = os.path.join(sys.path[0], '../lib/cryptography/hazmat/bindings/') - cmd = f"cp {source} {dest}" - (status, output) = subprocess.getstatusoutput(cmd) - if status != 0: - GaussLog.exitWithError("cp file failed.\nError:%s\nThe cmd is: %s\n" % - (output, cmd)) - - - source = os.path.join(sys.path[0], '../lib/nacl/lib3.' + \ - str(sys.version_info[1]), '_sodium.abi3.so') - dest = os.path.join(sys.path[0], '../lib/nacl/') - cmd = f"cp {source} {dest}" - (status, output) = subprocess.getstatusoutput(cmd) - if status != 0: - GaussLog.exitWithError("cp file failed.\nError:%s\nThe cmd is: %s\n" % - (output, cmd)) + from gspylib.common.copy_python_lib import copy_lib + copy_lib() from gspylib.common.Common import DefaultValue from gspylib.common.ErrorCode import ErrorCode diff --git a/script/gs_sshexkey b/script/gs_sshexkey index 8596891..9fc0162 100644 --- a/script/gs_sshexkey +++ b/script/gs_sshexkey @@ -49,8 +49,10 @@ from base_utils.os.password_util import PasswordUtil from base_utils.os.net_util import NetUtil from subprocess import PIPE from base_utils.common.fast_popen import FastPopen +from gspylib.common.copy_python_lib import copy_lib DefaultValue.doConfigForParamiko() +copy_lib() try: import paramiko diff --git a/script/gspylib/common/copy_python_lib.py b/script/gspylib/common/copy_python_lib.py new file mode 100644 index 0000000..95efe9f --- /dev/null +++ b/script/gspylib/common/copy_python_lib.py @@ -0,0 +1,42 @@ +import os +import sys +import subprocess + + +def copy_lib(): + current_path = os.path.dirname(os.path.abspath(__file__)) + source = os.path.join(current_path, '../../../lib/bcrypt/lib3.' + \ + str(sys.version_info[1]), '_bcrypt.abi3.so') + dest = os.path.join(current_path, '../../../lib/bcrypt/') + cmd = f"cp {source} {dest}" + (status, output) = subprocess.getstatusoutput(cmd) + if status != 0: + raise Exception("cp file failed.\nError:%s\nThe cmd is: %s\n" % + (output, cmd)) + + source = os.path.join(current_path, '../../../lib/_cffi_backend_3.' + \ + str(sys.version_info[1]), '_cffi_backend.so') + dest = os.path.join(current_path, '../../../lib/') + cmd = f"cp {source} {dest}" + (status, output) = subprocess.getstatusoutput(cmd) + if status != 0: + raise Exception("cp file failed.\nError:%s\nThe cmd is: %s\n" % + (output, cmd)) + + source = os.path.join(current_path, '../../../lib/cryptography/hazmat/bindings/lib3.' + \ + str(sys.version_info[1]), '*.so') + dest = os.path.join(current_path, '../../../lib/cryptography/hazmat/bindings/') + cmd = f"cp {source} {dest}" + (status, output) = subprocess.getstatusoutput(cmd) + if status != 0: + raise Exception("cp file failed.\nError:%s\nThe cmd is: %s\n" % + (output, cmd)) + + source = os.path.join(current_path, '../../../lib/nacl/lib3.' + \ + str(sys.version_info[1]), '_sodium.abi3.so') + dest = os.path.join(current_path, '../../../lib/nacl/') + cmd = f"cp {source} {dest}" + (status, output) = subprocess.getstatusoutput(cmd) + if status != 0: + raise Exception("cp file failed.\nError:%s\nThe cmd is: %s\n" % + (output, cmd))