提交 f3550636 编写于 作者: F frf12

v1.4.0

上级 af46c220
# coding: utf-8 # coding: utf-8
# OceanBase Deploy.
# Copyright (C) 2021 OceanBase
#
# This file is part of OceanBase Deploy.
#
# OceanBase Deploy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OceanBase Deploy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OceanBase Deploy. If not, see <https://www.gnu.org/licenses/>.
import os import os
import ctypes import ctypes
import struct import struct
...@@ -23,12 +6,13 @@ import struct ...@@ -23,12 +6,13 @@ import struct
_ppc64_native_is_best = True _ppc64_native_is_best = True
# dict mapping arch -> ( multicompat, best personality, biarch personality ) # dict mapping arch -> ( multicompat, best personality, biarch personality )
multilibArches = { "x86_64": ( "athlon", "x86_64", "athlon" ), multilibArches = {
"sparc64v": ( "sparcv9v", "sparcv9v", "sparc64v" ), "x86_64": ( "athlon", "x86_64", "athlon" ),
"sparc64": ( "sparcv9", "sparcv9", "sparc64" ), "sparc64v": ( "sparcv9v", "sparcv9v", "sparc64v" ),
"ppc64": ( "ppc", "ppc", "ppc64" ), "sparc64": ( "sparcv9", "sparcv9", "sparc64" ),
"s390x": ( "s390", "s390x", "s390" ), "ppc64": ( "ppc", "ppc", "ppc64" ),
} "s390x": ( "s390", "s390x", "s390" ),
}
if _ppc64_native_is_best: if _ppc64_native_is_best:
multilibArches["ppc64"] = ( "ppc", "ppc64", "ppc64" ) multilibArches["ppc64"] = ( "ppc", "ppc64", "ppc64" )
...@@ -103,14 +87,15 @@ arches = { ...@@ -103,14 +87,15 @@ arches = {
#itanium #itanium
"ia64": "noarch", "ia64": "noarch",
} }
# Will contain information parsed from /proc/self/auxv via _parse_auxv(). # Will contain information parsed from /proc/self/auxv via _parse_auxv().
# Should move into rpm really. # Should move into rpm really.
_aux_vector = { _aux_vector = {
"platform": "", "platform": "",
"hwcap": 0, "hwcap": 0,
} }
def _try_read_cpuinfo(): def _try_read_cpuinfo():
""" Try to read /proc/cpuinfo ... if we can't ignore errors (ie. proc not """ Try to read /proc/cpuinfo ... if we can't ignore errors (ie. proc not
...@@ -120,6 +105,7 @@ def _try_read_cpuinfo(): ...@@ -120,6 +105,7 @@ def _try_read_cpuinfo():
except: except:
return [] return []
def _parse_auxv(): def _parse_auxv():
""" Read /proc/self/auxv and parse it into global dict for easier access """ Read /proc/self/auxv and parse it into global dict for easier access
later on, very similar to what rpm does. """ later on, very similar to what rpm does. """
...@@ -146,6 +132,7 @@ def _parse_auxv(): ...@@ -146,6 +132,7 @@ def _parse_auxv():
_aux_vector["hwcap"] = at_val _aux_vector["hwcap"] = at_val
offset = offset + fmtlen offset = offset + fmtlen
def getCanonX86Arch(arch): def getCanonX86Arch(arch):
# #
if arch == "i586": if arch == "i586":
...@@ -171,6 +158,7 @@ def getCanonX86Arch(arch): ...@@ -171,6 +158,7 @@ def getCanonX86Arch(arch):
return arch return arch
def getCanonARMArch(arch): def getCanonARMArch(arch):
# the %{_target_arch} macro in rpm will let us know the abi we are using # the %{_target_arch} macro in rpm will let us know the abi we are using
try: try:
...@@ -182,6 +170,7 @@ def getCanonARMArch(arch): ...@@ -182,6 +170,7 @@ def getCanonARMArch(arch):
pass pass
return arch return arch
def getCanonPPCArch(arch): def getCanonPPCArch(arch):
# FIXME: should I do better handling for mac, etc? # FIXME: should I do better handling for mac, etc?
if arch != "ppc64": if arch != "ppc64":
...@@ -212,6 +201,7 @@ def getCanonPPCArch(arch): ...@@ -212,6 +201,7 @@ def getCanonPPCArch(arch):
return "ppc64iseries" return "ppc64iseries"
return arch return arch
def getCanonSPARCArch(arch): def getCanonSPARCArch(arch):
# Deal with sun4v, sun4u, sun4m cases # Deal with sun4v, sun4u, sun4m cases
SPARCtype = None SPARCtype = None
...@@ -253,7 +243,8 @@ def getCanonX86_64Arch(arch): ...@@ -253,7 +243,8 @@ def getCanonX86_64Arch(arch):
if vendor.find("GenuineIntel") != -1: if vendor.find("GenuineIntel") != -1:
return "ia32e" return "ia32e"
return arch return arch
def getCanonArch(skipRpmPlatform = 0): def getCanonArch(skipRpmPlatform = 0):
if not skipRpmPlatform and os.access("/etc/rpm/platform", os.R_OK): if not skipRpmPlatform and os.access("/etc/rpm/platform", os.R_OK):
try: try:
...@@ -282,8 +273,10 @@ def getCanonArch(skipRpmPlatform = 0): ...@@ -282,8 +273,10 @@ def getCanonArch(skipRpmPlatform = 0):
return getCanonX86_64Arch(arch) return getCanonX86_64Arch(arch)
return arch return arch
canonArch = getCanonArch() canonArch = getCanonArch()
def isMultiLibArch(arch=None): def isMultiLibArch(arch=None):
"""returns true if arch is a multilib arch, false if not""" """returns true if arch is a multilib arch, false if not"""
if arch is None: if arch is None:
...@@ -300,6 +293,7 @@ def isMultiLibArch(arch=None): ...@@ -300,6 +293,7 @@ def isMultiLibArch(arch=None):
return 0 return 0
def getBaseArch(myarch=None): def getBaseArch(myarch=None):
"""returns 'base' arch for myarch, if specified, or canonArch if not. """returns 'base' arch for myarch, if specified, or canonArch if not.
base arch is the arch before noarch in the arches dict if myarch is not base arch is the arch before noarch in the arches dict if myarch is not
...@@ -338,7 +332,8 @@ def getBaseArch(myarch=None): ...@@ -338,7 +332,8 @@ def getBaseArch(myarch=None):
value = arches[basearch] value = arches[basearch]
return basearch return basearch
def getArchList(thisarch=None): def getArchList(thisarch=None):
# this returns a list of archs that are compatible with arch given # this returns a list of archs that are compatible with arch given
if not thisarch: if not thisarch:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册