diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2014-03-30 11:57:59 -0400 |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2014-03-30 11:57:59 -0400 |
commit | 39896dee457418dda22ccf5f0ac5016c8ba0545e (patch) | |
tree | c57709bc9243966f2482b664eafe91159416e88a | |
parent | 90124735f5cef03585ac15112858b0cd02e917ba (diff) | |
download | scons-39896dee457418dda22ccf5f0ac5016c8ba0545e.tar.gz |
rpm tool: get default rpm arch more robustly, from rpm itself.
-rw-r--r-- | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | src/engine/SCons/Tool/rpmutils.py | 30 |
2 files changed, 23 insertions, 10 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 372b9e26..5cea35f3 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -6,6 +6,9 @@ RELEASE 2.3.2.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE + From Gary Oberbrunner: + - get default RPM architecture more robustly when building RPMs + From Shane Gannon: - Support for Visual Studio 2013 (12.0) diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py index 90e3d744..e20d53bc 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) |