更新包名

This commit is contained in:
zhang_xubo 2024-08-05 10:00:13 +08:00
parent 6d91e1172f
commit 45d19623c5
12 changed files with 66 additions and 104 deletions

View File

@ -2,7 +2,7 @@
declare binarylib_dir='None'
declare gcc_version='10.3'
declare module_name="openGauss"
declare module_name="openGauss-OM"
declare version_number='6.0.0'
declare version_Kernel='92.298'
ROOT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
@ -85,8 +85,10 @@ else
echo "Kernel is $kernel"
exit 1
fi
os_version=$(cat /etc/os-release | grep -w VERSION_ID | awk -F '"' '{print $2}')
declare package_pre_name="${version_string}-${dist_version}-${PLATFORM}bit-om"
PLATFORM_ARCH=$(uname -p)
declare package_pre_name="${version_string}-${dist_version}${os_version}-${PLATFORM_ARCH}"
declare package_name="${package_pre_name}.tar.gz"
declare sha256_name="${package_pre_name}.sha256"

View File

@ -22,6 +22,11 @@ class CommConstants:
PACKAGE_TYPE = "bz2File"
VERSION_PATTERN = r'[0-9]+\.[0-9]+\.[0-9]+'
VERSION_EXAMPLE = "openGauss-1.0"
PKG_SERVER = "Server"
PKG_OM = "OM"
PKG_CM = "CM"
PKG_SHA256 = "sha256"
# upgrade sql sha file and sql file
UPGRADE_SQL_SHA = "upgrade_sql.sha256"

View File

@ -36,7 +36,7 @@ class PackageInfo(object):
This file is for Gauss package things.
"""
@staticmethod
def getPackageFile(fileType="tarFile"):
def getPackageFile(fileType):
"""
function : Get the path of binary file version.
input : NA
@ -53,7 +53,7 @@ class PackageInfo(object):
input : NA
output : str
"""
return PackageInfo.getPackageFile("sha256File")
return PackageInfo.getPackageFile(CommConstants.PKG_SHA256)
@staticmethod
def get_package_file_path():
@ -62,7 +62,7 @@ class PackageInfo(object):
input : NA
output : str
"""
return PackageInfo.getPackageFile(CommConstants.PACKAGE_TYPE)
return PackageInfo.getPackageFile(CommConstants.PKG_SERVER)
@staticmethod
def getFileSHA256Info():
@ -153,12 +153,10 @@ class PackageInfo(object):
"""
# init bin file name, integrity file name and tar list names
package_path = os.path.normpath(package_path)
bz2_file_name = PackageInfo.getPackageFile("bz2File")
server_file_name = PackageInfo.getPackageFile(CommConstants.PKG_SERVER)
integrity_file_name = PackageInfo.getSHA256FilePath()
cm_package = "%s-cm.tar.gz" % PackageInfo.getPackageFile(
"bz2File").replace(".tar.bz2", "")
om_package = "%s-om.tar.gz" % PackageInfo.getPackageFile(
"bz2File").replace(".tar.bz2", "")
cm_package = server_file_name.replace("Server", "CM")
om_package = server_file_name.replace("Server", "OM")
tar_lists = SingleInstDiff.get_package_tar_lists(is_single_inst,
os.path.normpath(package_path))
@ -173,7 +171,7 @@ class PackageInfo(object):
# do not tar *.log files
cmd += CompressUtil.getCompressFilesCmd(PackageInfo.get_package_back_name(),
tar_lists)
cmd += " %s %s %s " % (os.path.basename(bz2_file_name),
cmd += " %s %s %s " % (os.path.basename(server_file_name),
os.path.basename(integrity_file_name), os.path.basename(om_package))
# add CM package to bak package
if os.path.isfile(os.path.realpath(os.path.join(package_path, cm_package))):

View File

@ -435,7 +435,7 @@ General options:
except Exception as e:
GaussLog.exitWithError(str(e))
# decompress version.cfg from bz2, and read it
# decompress version.cfg from Server, and read it
def readVersioncfg(self):
def _parse_version_cfg(_cfg):
_cmd = f'cat {_cfg}'
@ -446,7 +446,7 @@ General options:
"The output is %s." % _output)
_lines = _output.splitlines()
_res = {
'pkg_prefix': _lines[0],
'pkg_prefix': _lines[0].replace("OM", "Server"),
'pgversion': _lines[1],
'commit': _lines[2],
'mode': 'release' if len(_lines) < 4 else _lines[3]
@ -461,10 +461,10 @@ General options:
# upack and read version.cfg of openGauss-server package
# the existing om version.cfg will be overwritten
cmd = 'cd {} && tar -xpf {}*.tar.bz2 ./version.cfg'.format(root, self.om_version_cfg['pkg_prefix'])
cmd = 'cd {} && tar -xpf {}*.tar.gz ./version.cfg'.format(root, self.om_version_cfg['pkg_prefix'])
status, output = subprocess.getstatusoutput(cmd)
if status != 0:
cmd = 'cd {} && tar -xpf `ls openGauss*.tar.bz2 | tail -1` ./version.cfg'.format(root)
cmd = 'cd {} && tar -xpf `ls openGauss-Server*.tar.gz | tail -1` ./version.cfg'.format(root)
status, output = subprocess.getstatusoutput(cmd)
if status != 0:
GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50217"] % "version.cfg" +
@ -498,7 +498,7 @@ General options:
# unpack and move tools into target path
cmd = 'cd {} && '.format(root)
cmd += 'tar -xpf {}*.tar.bz2 {} && '.format(pkg_prefix, ' '.join(bin_files + dss_files + memcheck_files))
cmd += 'tar -xpf {}*.tar.gz {} && '.format(pkg_prefix, ' '.join(bin_files + dss_files + memcheck_files))
if cm_files:
cmd += 'tar -xpf {}*cm.tar.gz {} && '.format(pkg_prefix, ' '.join(cm_files))
cmd += 'mkdir -p {0} -m u=rwx && '.format(clib_dss)
@ -507,7 +507,7 @@ General options:
cmd += 'cp ./lib/libasan.so.6 {} &&'.format(memcheck_root_lib)
cmd += '\mv {} {} && '.format(' '.join(bin_files + memcheck_files), clib)
cmd += 'cd {} && rm -rf bin'.format(root)
status, _ = subprocess.getstatusoutput(cmd)
status, output = subprocess.getstatusoutput(cmd)
if status != 0:
GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50217"] %
"version.cfg" + "The cmd is %s. " % cmd +

View File

@ -1289,7 +1289,7 @@ General options:
root = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
clib = os.path.join(root, "script/gspylib/clib")
bin_files = ['./bin/encrypt']
bin_cmd = 'tar -xpf `ls openGauss*.tar.bz2`'
bin_cmd = 'tar -xpf `ls openGauss-Server*.tar.gz`'
cmd = 'cd {} && '.format(root)
cmd += '{} {} && '.format(bin_cmd, ''.join(' '.join(bin_files)))
cmd += '\mv {} {} && '.format(' '.join(bin_files), clib)

View File

@ -483,14 +483,6 @@ class PlatformCommand():
"""
return self.getPackageFile("bz2File")
def getBinFilePath(self):
"""
function : Get the path of binary file version..
input : NA
output : str
"""
return self.getPackageFile("binFile")
def getSHA256FilePath(self):
"""
function : Get the path of sha256 file version..
@ -499,26 +491,6 @@ class PlatformCommand():
"""
return self.getPackageFile("sha256File")
def getFileSHA256Info(self):
"""
function: get file sha256 info
input: NA
output: str, str
"""
try:
bz2Path = self.getBz2FilePath()
sha256Path = self.getSHA256FilePath()
fileSHA256 = g_file.getFileSHA256(bz2Path)
valueList = g_file.readFile(sha256Path)
if len(valueList) != 1:
raise Exception(ErrorCode.GAUSS_502["GAUSS_50204"] %
sha256Path)
sha256Value = valueList[0].strip()
return fileSHA256, sha256Value
except Exception as e:
raise Exception(str(e))
def checkLink(self, filePath):
"""
function:check if file is a link

View File

@ -1625,7 +1625,7 @@ class LinuxPlatform(GenericPlatform):
raise Exception(str(e))
def getPackageFile(self, distName, version, packageVersion,
productVersion, fileType="tarFile"):
productVersion, fileType):
"""
function : Get the path of binary file version.
input : distName, version, packageVersion,

View File

@ -39,16 +39,19 @@ from gspylib.threads.SshTool import SshTool
from gspylib.common.ErrorCode import ErrorCode
from gspylib.common.Common import DefaultValue
from gspylib.common.GaussLog import GaussLog
from gspylib.os.gsOSlib import g_OSlib
# from gspylib.os.gsOSlib import g_OSlib
import impl.upgrade.UpgradeConst as Const
from gspylib.common.OMCommand import OMCommand
from gspylib.os.gsfile import g_file
from domain_utils.cluster_file.cluster_dir import ClusterDir
from base_utils.os.env_util import EnvUtil
from base_utils.os.cmd_util import CmdUtil
from domain_utils.cluster_file.version_info import VersionInfo
from domain_utils.cluster_file.package_info import PackageInfo
from base_utils.os.net_util import NetUtil
from base_diff.comm_constants import CommConstants
#boot/build mode
MODE_PRIMARY = "primary"
@ -197,18 +200,18 @@ class ExpansionImpl():
self.logger.log("End to send soft to each standby nodes.")
def generatePackages(self, pkgdir):
bz2_file = g_OSlib.getBz2FilePath()
bz2_sha_file = g_OSlib.getSHA256FilePath()
server_file = PackageInfo.getPackageFile(CommConstants.PKG_SERVER)
sha_file = PackageInfo.getPackageFile(CommConstants.PKG_SHA256)
upgrade_sql_file = os.path.join(pkgdir,
Const.UPGRADE_SQL_FILE)
upgrade_sha_file = os.path.join(pkgdir,
Const.UPGRADE_SQL_SHA)
om_file = bz2_sha_file.replace(".sha256", "-om.tar.gz")
om_file = server_file.replace("Server", "OM")
cm_file = []
if self.context.check_cm_component():
cm_file = [bz2_sha_file.replace(".sha256", "-cm.tar.gz")]
cm_file = [server_file.replace("Server", "CM")]
return [om_file, bz2_file, bz2_sha_file, upgrade_sql_file,
return [om_file, server_file, sha_file, upgrade_sql_file,
upgrade_sha_file] + cm_file
def generateAndSendXmlFile(self):

View File

@ -41,6 +41,7 @@ from domain_utils.cluster_file.profile_file import ProfileFile
from domain_utils.cluster_file.version_info import VersionInfo
from base_utils.os.net_util import NetUtil
from domain_utils.domain_common.cluster_constants import ClusterConstants
from base_diff.comm_constants import CommConstants
#################################################################
ACTION_INSTALL_CLUSTER = "install_cluster"
@ -398,8 +399,8 @@ class Install(LocalBaseOM):
Decompress CM package
"""
cm_package = os.path.join(EnvUtil.getEnvironmentParameterValue(
"GPHOME", self.user), "%s-cm.tar.gz" % PackageInfo.getPackageFile(
"bz2File").replace(".tar.bz2", ""))
"GPHOME", self.user), PackageInfo.getPackageFile(
"CM"))
if DefaultValue.get_cm_server_num_from_static(self.clusterInfo) == 0 and \
not os.path.isfile(cm_package):
self.logger.log("No need to decompress cm package.")
@ -440,7 +441,7 @@ class Install(LocalBaseOM):
output: NA
"""
self.logger.log("Decompressing bin file.")
tar_file = PackageInfo.getPackageFile("bz2File")
tar_file = PackageInfo.getPackageFile(CommConstants.PKG_SERVER)
# let bin executable
FileUtil.changeMode(DefaultValue.KEY_DIRECTORY_MODE, tar_file)

View File

@ -2799,8 +2799,6 @@ Common options:
"%s/script/gs_*" % toolPath)
FileUtil.changeMode(DefaultValue.BIN_FILE_MODE, "%s/*.sha256" % toolPath)
FileUtil.changeMode(DefaultValue.BIN_FILE_MODE, "%s/*.tar.gz" % toolPath)
FileUtil.changeMode(DefaultValue.BIN_FILE_MODE, "%s/*.tar.bz2" %
toolPath)
FileUtil.changeMode(DefaultValue.BIN_FILE_MODE, "%s/version.cfg" %
toolPath)
@ -2822,8 +2820,6 @@ Common options:
package_path)
FileUtil.changeMode(DefaultValue.BIN_FILE_MODE, "%s/*.tar.gz" %
package_path)
FileUtil.changeMode(DefaultValue.BIN_FILE_MODE, "%s/*.tar.bz2" %
package_path)
FileUtil.changeMode(DefaultValue.BIN_FILE_MODE, "%s/version.cfg" %
package_path)

View File

@ -20,6 +20,8 @@
#############################################################################
import os
import platform
import re
from gspylib.common.ErrorCode import ErrorCode
from os_platform.common import REDHAT, PAK_REDHAT, BIT_VERSION, \
@ -128,12 +130,20 @@ class LinuxPlatform(object):
def package_file_path(self, prefix_str, packageVersion, distro, postfix_str):
dir_name = os.path.dirname(os.path.realpath(__file__))
return os.path.join(dir_name, "./../../", "%s-%s-%s-%s.%s" % (
arch = platform.machine()
fuzzynamestr = os.path.join(dir_name, "./../../", "%s-%s-%s.*-%s.%s" % (
prefix_str, packageVersion, distro,
BIT_VERSION, postfix_str))
arch, postfix_str))
dirname = os.path.dirname(fuzzynamestr)
fuzzname = os.path.basename(fuzzynamestr)
partten = re.compile(fuzzname)
filenames = [file for file in os.listdir(dirname) if partten.match(file)]
if len(filenames) > 0:
return os.path.join(dirname, filenames[0])
return fuzzynamestr
def getPackageFile(self, packageVersion, productVersion, fileType="tarFile"):
def getPackageFile(self, packageVersion, productVersion, fileType="Server"):
"""
function : Get the path of binary file version.
input : packageVersion, productVersion, fileType
@ -143,14 +153,18 @@ class LinuxPlatform(object):
distname = distname.lower()
dir_name = os.path.dirname(os.path.realpath(__file__))
prefix_str = productVersion
if fileType == "tarFile":
if fileType == "Server":
prefix_str = f"{productVersion}-Server"
postfix_str = "tar.gz"
elif fileType == "binFile":
postfix_str = "bin"
elif fileType == "sha256File":
elif fileType == "OM":
prefix_str = f"{productVersion}-OM"
postfix_str = "tar.gz"
elif fileType == "CM":
prefix_str = f"{productVersion}-CM"
postfix_str = "tar.gz"
elif fileType == "sha256":
prefix_str = f"{productVersion}-Server"
postfix_str = "sha256"
elif fileType == "bz2File":
postfix_str = "tar.bz2"
else:
raise Exception(ErrorCode.GAUSS_500["GAUSS_50024"] % "fileType")
@ -244,36 +258,7 @@ class LinuxPlatform(object):
if os.path.exists(file_name) and os.path.isfile(file_name):
return file_name
for file_name in file_name_list:
try:
directory_to_search = os.path.join(dir_name, "./../../../")
matched_files = self.compare_files_in_directory(directory_to_search, file_name)
if len(matched_files) == 1:
return matched_files[0]
elif len(matched_files) > 1:
print("Multiple matching files found,"
"please select one:")
for i, file in enumerate(matched_files, 1):
print(f"{i}. {file}")
while True:
try:
choice = int(input("Please enter the serial number"
"of the option:"))
if 1 <= choice <= len(matched_files):
return matched_files[choice - 1]
else:
print("Invalid input: Please re-enter")
except ValueError:
print("Invalid input: Please re-enter")
else:
raise Exception("No matching files found in the directory.")
except Exception as e:
raise Exception(ErrorCode.GAUSS_502["GAUSS_50201"] % file_name)
raise Exception(ErrorCode.GAUSS_502["GAUSS_50201"] % package_name_list)
return file_name_list[0]
def compare_files_in_directory(directory, file_to_compare):
"""

View File

@ -35,13 +35,13 @@ class OGController(object):
@staticmethod
def is_support_package(pkg):
# openGauss bz2:openGauss-5.0.0-openEuler-64bit.tar.gz
# openGauss server:openGauss-Server-6.0.0-openEuler20.03-64bit.tar.gz
parts = os.path.basename(pkg).split('-')
if len(parts) < 4 or parts[0] != 'openGauss' or parts[3] != '64bit.tar.bz2':
return False, '非openGauss bz2压缩安装包:' + pkg
if len(parts) < 5 or parts[0] != 'openGauss' or parts[1] != 'Server':
return False, '非openGauss server压缩安装包:' + pkg
if not is_support_version(parts[1]):
if not is_support_version(parts[2]):
return False, '工具不支持的OG版本:' + parts[1]
return True, ''
@ -120,7 +120,7 @@ class OGController(object):
Shell.run(cmd, print_desc='卸载数据库', check=True)
if __name__ == "__main__":
og = OGController('/data/pkg/openGauss-5.0.0-openEuler-64bit.tar.gz')
og = OGController('/data/pkg/openGauss-Server-6.0.0-openEuler20.03-64bit.tar.gz')
og.install()
og.initdb()
og.start(16666)