-
Notifications
You must be signed in to change notification settings - Fork 0
/
BZ-614496-traceback-no-proc-mounted.patch
83 lines (76 loc) · 2.48 KB
/
BZ-614496-traceback-no-proc-mounted.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
commit ff24179876401b3c6526b90df89c767e8091afb3
Author: James Antill <[email protected]>
Date: Wed Jul 14 13:09:18 2010 -0400
Fix for /proc isn't mounted, continues as though cpuinfo was empty
diff --git a/rpmUtils/arch.py b/rpmUtils/arch.py
index af0d782..5512ea6 100644
--- a/rpmUtils/arch.py
+++ b/rpmUtils/arch.py
@@ -202,15 +202,19 @@ def getArchList(thisarch=None):
archlist.append('noarch')
return archlist
-
+def _try_read_cpuinfo():
+ """ Try to read /proc/cpuinfo ... if we can't ignore errors (ie. proc not
+ mounted). """
+ try:
+ lines = open("/proc/cpuinfo", "r").readlines()
+ return lines
+ except:
+ return []
def getCanonX86Arch(arch):
#
if arch == "i586":
- f = open("/proc/cpuinfo", "r")
- lines = f.readlines()
- f.close()
- for line in lines:
+ for line in _try_read_cpuinfo():
if line.startswith("model name") and line.find("Geode(TM)") != -1:
return "geode"
return arch
@@ -219,10 +223,7 @@ def getCanonX86Arch(arch):
return arch
# if we're i686 and AuthenticAMD, then we should be an athlon
- f = open("/proc/cpuinfo", "r")
- lines = f.readlines()
- f.close()
- for line in lines:
+ for line in _try_read_cpuinfo():
if line.startswith("vendor") and line.find("AuthenticAMD") != -1:
return "athlon"
# i686 doesn't guarantee cmov, but we depend on it
@@ -237,10 +238,7 @@ def getCanonPPCArch(arch):
return arch
machine = None
- f = open("/proc/cpuinfo", "r")
- lines = f.readlines()
- f.close()
- for line in lines:
+ for line in _try_read_cpuinfo():
if line.find("machine") != -1:
machine = line.split(':')[1]
break
@@ -256,10 +254,7 @@ def getCanonPPCArch(arch):
def getCanonSPARCArch(arch):
# Deal with sun4v, sun4u, sun4m cases
SPARCtype = None
- f = open("/proc/cpuinfo", "r")
- lines = f.readlines()
- f.close()
- for line in lines:
+ for line in _try_read_cpuinfo():
if line.startswith("type"):
SPARCtype = line.split(':')[1]
break
@@ -285,10 +280,7 @@ def getCanonX86_64Arch(arch):
return arch
vendor = None
- f = open("/proc/cpuinfo", "r")
- lines = f.readlines()
- f.close()
- for line in lines:
+ for line in _try_read_cpuinfo():
if line.startswith("vendor_id"):
vendor = line.split(':')[1]
break