summaryrefslogtreecommitdiff
path: root/engine/SCons/Tool/rpmutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'engine/SCons/Tool/rpmutils.py')
-rw-r--r--engine/SCons/Tool/rpmutils.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/engine/SCons/Tool/rpmutils.py b/engine/SCons/Tool/rpmutils.py
index f482fbb..5599a8e 100644
--- a/engine/SCons/Tool/rpmutils.py
+++ b/engine/SCons/Tool/rpmutils.py
@@ -10,11 +10,11 @@ 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.
"""
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation
+# Copyright (c) 2001 - 2014 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -35,10 +35,11 @@ exact syntax.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/rpmutils.py 2014/03/02 14:18:15 garyo"
+__revision__ = "src/engine/SCons/Tool/rpmutils.py 2014/07/05 09:42:21 garyo"
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)