summaryrefslogtreecommitdiff
path: root/engine/SCons/Tool/rpmutils.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <jff@merkur>2014-07-26 11:45:48 +0200
committerJörg Frings-Fürst <jff@merkur>2014-07-26 11:45:48 +0200
commit99469e37d07b9f326c5b2c8157566f2f512cdc56 (patch)
tree475c0ae1b3b3b8be085b54420894896688ea363c /engine/SCons/Tool/rpmutils.py
parent2176ae74d2f856582dd1e498a63a31949a7e19e2 (diff)
parent7c6b954c00c2a2eed2e975ec797216c515cd249d (diff)
Merge tag 'upstream/2.3.2'
Upstream version 2.3.2
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)