[Yum-devel] [PATCH] Fix for /proc isn't mounted, continues as though cpuinfo was empty

Tim Lauridsen tim.lauridsen at gmail.com
Thu Jul 15 07:37:04 UTC 2010


On Wed, Jul 14, 2010 at 7:09 PM, James Antill <james at and.org> wrote:

> ---
>  rpmUtils/arch.py |   34 +++++++++++++---------------------
>  1 files changed, 13 insertions(+), 21 deletions(-)
>
> 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
> --
> 1.7.0.1
>
> _______________________________________________
> Yum-devel mailing list
> Yum-devel at lists.baseurl.org
> http://lists.baseurl.org/mailman/listinfo/yum-devel
>

ACK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20100715/31985abf/attachment.html>


More information about the Yum-devel mailing list