0
# (C) 2007 Red Hat Inc.
0
# David Lutterkort <dlutter @redhat.com>
0
+# this maintains compatibility with really old platforms with python 1.x
0
+from os import popen, WEXITSTATUS
0
+# Try to use the yum libraries by default, but shell out to the yum executable
0
+# if they are not present (i.e. yum <= 2.0). This is only required for RHEL3
0
+# and earlier that do not support later versions of Yum. Once RHEL3 is EOL,
0
+# shell_out() and related code can be removed.
0
@@ -26,14 +41,80 @@ def pkg_lists(my):
0
return my.doPackageLists('updates')
0
+ p = popen("/usr/bin/env yum check-update 2>&1")
0
+ output = p.readlines()
0
+ # None represents exit code of 0, otherwise the exit code is in the
0
+ # format returned by wait(). Exit code of 100 from yum represents
0
+ if WEXITSTATUS(rc) != 100:
0
+ return WEXITSTATUS(rc)
0
+ # Exit code is None (0), no updates waiting so don't both parsing output
0
+ # Yum prints a line of hyphens (old versions) or a blank line between
0
+ # headers and package data, so skip everything before them
0
+ if re.compile("^((-){80}|)$").search(line):
0
+ # Skip any blank lines
0
+ if re.compile("^[ \t]*$").search(line):
0
+ # Yum 1.x: name arch (epoch:)?version
0
+ # Yum 2.0: name arch (epoch:)?version repo
0
+ # epoch is optional if 0
0
+ p = string.split(line)
0
+ # Separate out epoch:version-release
0
+ evr_re = re.compile("^(\d:)?(\S+)-(\S+)$")
0
+ evr = evr_re.match(pevr)
0
+ if evr.group(1) is None:
0
+ pepoch = evr.group(1).replace(":", "")
0
+ pversion = evr.group(2)
0
+ prelease = evr.group(3)
0
+ print "_pkg", pname, pepoch, pversion, prelease, parch
0
+ print sys.exc_info()[0]
0
- for pkg in ypl.updates:
0
- print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)
0
- print "_err IOError %d %s" % (e.errno, e)
0
+ for pkg in ypl.updates:
0
+ print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)
0
+ print "_err IOError %d %s" % (e.errno, e)
0
+ except AttributeError, e:
0
+ # catch yumlib errors in buggy 2.x versions of yum
0
+ print "_err AttributeError %s" % e
Comments
No one has commented yet.