diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2014-03-30 15:57:59 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2014-03-30 15:57:59 (GMT) |
commit | d4f8c6e320484c106446918c37affdddacd5c7a3 (patch) | |
tree | c57709bc9243966f2482b664eafe91159416e88a /src/engine/SCons/Tool/rpmutils.py | |
parent | 29b5018f78b8fe161b76b19125eec2a164c58098 (diff) | |
download | SCons-d4f8c6e320484c106446918c37affdddacd5c7a3.zip SCons-d4f8c6e320484c106446918c37affdddacd5c7a3.tar.gz SCons-d4f8c6e320484c106446918c37affdddacd5c7a3.tar.bz2 |
rpm tool: get default rpm arch more robustly, from rpm itself.
Diffstat (limited to 'src/engine/SCons/Tool/rpmutils.py')
-rw-r--r-- | src/engine/SCons/Tool/rpmutils.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index 90e3d74..e20d53b 100644 --- a/src/engine/SCons/Tool/rpmutils.py +++ b/src/engine/SCons/Tool/rpmutils.py @@ -10,7 +10,7 @@ mimic the exact naming rules of the RPM source code. They were directly derived from the file "rpmrc.in" of the version rpm-4.9.1.3. For updating to a more recent version of RPM, this Python script can be used standalone. The usage() function below shows the -exact syntax. +exact syntax. """ @@ -39,6 +39,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import platform +import subprocess # Start of rpmrc dictionaries (Marker, don't change or remove!) os_canon = { @@ -435,20 +436,29 @@ arch_canon = { # End of rpmrc dictionaries (Marker, don't change or remove!) -def defaultMachine(): +def defaultMachine(use_rpm_default=True): """ Return the canonicalized machine name. """ - rmachine = platform.machine() - - # Try to lookup the string in the canon table - if rmachine in arch_canon: - rmachine = arch_canon[rmachine][0] - + + if use_rpm_default: + try: + # This should be the most reliable way to get the default arch + rmachine = subprocess.check_output(['rpm', '--eval=%_target_cpu'], shell=False).rstrip() + except Exception as e: + # Something went wrong, try again by looking up platform.machine() + return defaultMachine(False) + else: + rmachine = platform.machine() + + # Try to lookup the string in the canon table + if rmachine in arch_canon: + rmachine = arch_canon[rmachine][0] + return rmachine def defaultSystem(): """ Return the canonicalized system name. """ rsystem = platform.system() - + # Try to lookup the string in the canon tables if rsystem in os_canon: rsystem = os_canon[rsystem][0] @@ -523,7 +533,7 @@ def usage(): def main(): import sys - + if len(sys.argv) < 3: usage() sys.exit(0) |