On 04/18/2012 04:29 PM, James Antill wrote:
On Wed, 2012-04-18 at 15:37 +0200, Phil Knirsch wrote:
Yea, it's kinda butt ugly, but the problem is that rpm doesn't have an
API for it, even less so for the python part that would be required.
Yeh, just seems that one of the bester cases here would be having an
"rpm API" that says "give me the current AT_PLATFORM and/or AT_*".
Even if we don't move/merge "all" of the arch detection code into rpm,
at least having those would be good.
The latest patch i've attached for now basically do the same as rpm
does. Once we have the rpm API in place we can switch over to that
easily. Basically replaced the evil /bin/true ENV parsing hack with a
proper general purpose /proc/self/auxv parser in python directly, so
basically the cleanest way we can do this for now. And i've done it just
like in rpm, so any other arch can access and use the
aux_vector["platform"] and aux_vector["hwcap"] information.
The latest patch version for rpm at least does it in a decently sane way
where a struct is being populated with AT_PLATFORM and AT_HWCAPS
information to be used for defaultMachine() stuff.
The other 2 options are to either look at /proc/cpuinfo or to use ENV
where at the end the AT stuff is being "injected", but the IBM folks
strongly recommended not to use the former
Do they say why they don't want us looking in cpuinfo? We do that on
most arches anyway ... I just know anaconda/mock/pungi/something is
going to barf when we have to start running other programs.
Yep, see my earlier comment, i completely nuked that and reading cpuinfo
would have been incorrect, so i just went the extra mile to do a proper
general purpose auxv parser.
That also makes the second part a lot cleaner and easier to read and
i've fixed it to check if it's power7 or higher properly as well.
So we should be pretty much en par with the changes in rpm now as they
are very similar solved in both now.
Could we get a f-17 version with that change out soon too please? rpm
already contains the necessary changes, and we'd really love to get this
test for F-17 beta on PPC which we're aiming for next Wednesday.
Thanks & regards, Phil
--
Philipp Knirsch | Tel.: +49-711-96437-470
Supervisor Core Services | Fax.: +49-711-96437-111
Red Hat GmbH | Email: Phil Knirsch <[email protected]>
Hauptstaetterstr. 58 | Web: http://www.redhat.com/
D-70178 Stuttgart, Germany
diff -up yum-3.4.3/rpmUtils/arch.py.ppc64p7 yum-3.4.3/rpmUtils/arch.py
--- yum-3.4.3/rpmUtils/arch.py.ppc64p7 2012-04-26 15:34:05.845002514 +0200
+++ yum-3.4.3/rpmUtils/arch.py 2012-04-26 16:21:34.415004799 +0200
@@ -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,12 @@ arches = {
"ia64": "noarch",
}
+# Will contain information parsed from /proc/self/auxv via parse_auxv()
+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 +231,32 @@ def _try_read_cpuinfo():
except:
return []
+def parse_auxv():
+ """ Read /proc/self/auxv and parse it into a 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,13 +295,22 @@ def getCanonPPCArch(arch):
if line.find("machine") != -1:
machine = line.split(':')[1]
break
- if machine is None:
+
+ platform = aux_vector["platform"]
+ if machine is None and platform == "":
return arch
- if machine.find("CHRP IBM") != -1:
- return "ppc64pseries"
- if machine.find("iSeries") != -1:
- return "ppc64iseries"
+ try:
+ if platform.startswith("power") and int(platform[5:]) >= 7:
+ return "ppc64p7"
+ except:
+ pass
+
+ if machine != None:
+ if machine.find("CHRP IBM") != -1:
+ return "ppc64pseries"
+ if machine.find("iSeries") != -1:
+ return "ppc64iseries"
return arch
def getCanonSPARCArch(arch):
@@ -324,6 +368,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)
_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel