[yum] Add code for arm detection.

James Antill james at fedoraproject.org
Fri Apr 27 18:33:11 UTC 2012


commit 3c5de65e07fcf3c275b0fae7a3190ea77ae4625b
Author: James Antill <james at and.org>
Date:   Fri Apr 27 14:32:04 2012 -0400

    Add code for arm detection.

 arm-arch-detection.patch |  104 ++++++++++++++++++++++++++++++++++++++++++++++
 yum.spec                 |    7 +++-
 2 files changed, 110 insertions(+), 1 deletions(-)
---
diff --git a/arm-arch-detection.patch b/arm-arch-detection.patch
new file mode 100644
index 0000000..0d7dbb3
--- /dev/null
+++ b/arm-arch-detection.patch
@@ -0,0 +1,104 @@
+commit 24dde23643f98ed355fcf50fb09807e2b08ea620
+Author: Phil Knirsch <pknirsch at redhat.com>
+Date:   Fri Apr 27 09:09:15 2012 -0400
+
+     Do arm arch detection in the same way rpm does it. Once we have the rpm API
+    in place we can switch over to that easily.
+    
+     Minor cleanups by James Antill.
+
+diff --git a/rpmUtils/arch.py b/rpmUtils/arch.py
+index 7d67907..2226dc5 100644
+--- a/rpmUtils/arch.py
++++ b/rpmUtils/arch.py
+@@ -3,6 +3,8 @@
+ 
+ import os
+ import rpm
++import ctypes
++import struct
+ 
+ _ppc64_native_is_best = True
+ 
+@@ -31,6 +33,7 @@ arches = {
+     "ia32e": "x86_64",
+     
+     # ppc
++    "ppc64p7": "ppc64",
+     "ppc64pseries": "ppc64",
+     "ppc64iseries": "ppc64",    
+     "ppc64": "ppc",
+@@ -82,6 +85,13 @@ arches = {
+     "ia64": "noarch",
+     }
+ 
++#  Will contain information parsed from /proc/self/auxv via _parse_auxv().
++# Should move into rpm really.
++_aux_vector = {
++    "platform": "",
++    "hwcap": 0,
++    }
++
+ def legitMultiArchesInSameLib(arch=None):
+     # this is completely crackrock - if anyone has a better way I
+     # am all ears
+@@ -222,6 +232,32 @@ def _try_read_cpuinfo():
+     except:
+         return []
+ 
++def _parse_auxv():
++    """ Read /proc/self/auxv and parse it into global dict for easier access
++        later on, very similar to what rpm does. """
++    # In case we can't open and read /proc/self/auxv, just return
++    try:
++        data = open("/proc/self/auxv", "rb").read()
++    except:
++        return
++
++    # Define values from /usr/include/elf.h
++    AT_PLATFORM = 15
++    AT_HWCAP = 16
++    fmtlen = struct.calcsize("LL")
++    offset = 0
++    platform = ctypes.c_char_p()
++
++    # Parse the data and fill in _aux_vector dict
++    while offset <= len(data) - fmtlen:
++        at_type, at_val = struct.unpack_from("LL", data, offset)
++        if at_type == AT_PLATFORM:
++            platform.value = at_val
++            _aux_vector["platform"] = platform.value
++        if at_type == AT_HWCAP:
++            _aux_vector["hwcap"] = at_val
++        offset = offset + fmtlen
++
+ def getCanonX86Arch(arch):
+     # 
+     if arch == "i586":
+@@ -260,6 +296,17 @@ def getCanonPPCArch(arch):
+         if line.find("machine") != -1:
+             machine = line.split(':')[1]
+             break
++
++    platform = _aux_vector["platform"]
++    if machine is None and not platform:
++        return arch
++
++    try:
++        if platform.startswith("power") and int(platform[5:]) >= 7:
++            return "ppc64p7"
++    except:
++        pass
++
+     if machine is None:
+         return arch
+ 
+@@ -324,6 +371,8 @@ def getCanonArch(skipRpmPlatform = 0):
+         
+     arch = os.uname()[4]
+ 
++    _parse_auxv()
++
+     if (len(arch) == 4 and arch[0] == "i" and arch[2:4] == "86"):
+         return getCanonX86Arch(arch)
+ 
diff --git a/yum.spec b/yum.spec
index 5b2bb2b..639ca18 100644
--- a/yum.spec
+++ b/yum.spec
@@ -18,7 +18,7 @@
 Summary: RPM package installer/updater/manager
 Name: yum
 Version: 3.4.3
-Release: 23%{?dist}
+Release: 24%{?dist}
 License: GPLv2+
 Group: System Environment/Base
 Source0: http://yum.baseurl.org/download/3.4/%{name}-%{version}.tar.gz
@@ -30,6 +30,7 @@ Patch5: geode-arch.patch
 Patch6: yum-HEAD.patch
 Patch7: yum-ppc64-preferred.patch
 Patch8: BZ-803346-no-only-update.patch
+Patch9: arm-arch-detection.patch
 Patch20: yum-manpage-files.patch
 
 URL: http://yum.baseurl.org/
@@ -138,6 +139,7 @@ Install this package if you want auto yum updates nightly via cron.
 %patch6 -p1
 %patch7 -p1
 %patch8 -p1
+%patch9 -p1
 %patch20 -p1
 %patch1 -p1
 
@@ -313,6 +315,9 @@ exit 0
 %endif
 
 %changelog
+* Fri Apr 27 2012 James Antill <james at fedoraproject.org> - 3.4.3-24
+- Add code for arm detection.
+
 * Fri Mar 16 2012 James Antill <james at fedoraproject.org> - 3.4.3-23
 - update to latest HEAD.
 - Also fix "yum check" for strong requires. bug 795907.


More information about the scm-commits mailing list