[yum-git] 2 commits - yum/packages.py

James Antill james at linux.duke.edu
Tue Feb 26 18:19:24 UTC 2008


 yum/packages.py |   49 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 11 deletions(-)

New commits:
commit 2b97e892ba37fd7d1eac79472d3cfa45abdf4c6c
Author: James Antill <james at and.org>
Date:   Tue Feb 26 12:58:22 2008 -0500

     Fix mode value.
     Check mode and size.
     Skip checks that don't make sense for dirs and links.

diff --git a/yum/packages.py b/yum/packages.py
index 059533a..d133229 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -875,7 +875,14 @@ class YumInstalledPackage(YumHeaderPackage):
                 my_user = pwd.getpwuid(my_st[stat.ST_UID])[0]
                 my_group = grp.getgrgid(my_st[stat.ST_GID])[0]
 
-                if my_st.st_mtime != mtime:
+                if mode < 0:
+                    # Stupid rpm, should be unsigned value but is signed ...
+                    # so we "fix" it via. this hack
+                    mode = (mode & 0xFFFF)
+
+                isdir = stat.S_ISDIR(my_st.st_mode)
+                islnk = stat.S_ISLNK(my_st.st_mode)
+                if my_st.st_mtime != mtime and not isdir and not islnk:
                     thisproblem = misc.GenericHolder()
                     thisproblem.type = 'mtime' # maybe replace with a constants type
                     thisproblem.message = 'mtime does not match'
@@ -883,23 +890,39 @@ class YumInstalledPackage(YumHeaderPackage):
                     thisproblem.disk_value = my_st[stat.ST_MTIME]
                     problems.append(thisproblem)
 
-                if my_group != group:
+                if my_group != group and not islnk:
                     thisproblem = misc.GenericHolder()
                     thisproblem.type = 'group' # maybe replace with a constants type
                     thisproblem.message = 'group does not match'
                     thisproblem.database_value = group
                     thisproblem.disk_value = my_group
                     problems.append(thisproblem)
-                if my_user != user:
+                if my_user != user and not islnk:
                     thisproblem = misc.GenericHolder()
                     thisproblem.type = 'user' # maybe replace with a constants type
                     thisproblem.message = 'user does not match'
                     thisproblem.database_value = user
                     thisproblem.disk_value = my_user
                     problems.append(thisproblem)
+
+                if my_st.st_size != size and not isdir and not islnk:
+                    thisproblem = misc.GenericHolder()
+                    thisproblem.type = 'size'
+                    thisproblem.message = 'size does not match'
+                    thisproblem.database_value = size
+                    thisproblem.disk_value = my_st.st_size
+                    problems.append(thisproblem)
                     
-                # checksum
-                if csum: # don't checksum files that don't have a csum in the rpmdb :)
+                if my_st.st_mode != mode and not islnk:
+                    thisproblem = misc.GenericHolder()
+                    thisproblem.type = 'mode'
+                    thisproblem.message = 'mode does not match'
+                    thisproblem.database_value = mode
+                    thisproblem.disk_value = my_st.st_mode
+                    problems.append(thisproblem)
+
+                # don't checksum files that don't have a csum in the rpmdb :)
+                if csum and not isdir:
                     my_csum = misc.checksum('md5', fn)
                     if my_csum != csum and have_prelink:
                         #  This is how rpm -V works, try and if that fails try
commit 7d5c830a2a2009aa25d35cf3017f7a9b39a937bb
Author: James Antill <james at and.org>
Date:   Tue Feb 26 12:28:42 2008 -0500

    Minor cleanup, drop prelink stderr

diff --git a/yum/packages.py b/yum/packages.py
index 86fed98..059533a 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -35,6 +35,9 @@ import Errors
 import urlparse
 urlparse.uses_fragment.append("media")
 
+# For verify
+import pwd
+import grp
 
 def comparePoEVR(po1, po2):
     """
@@ -846,8 +849,11 @@ class YumInstalledPackage(YumHeaderPackage):
            returns a tuple """
         fi = self.hdr.fiFromHeader()
         results = {} # fn = problem_obj?
-        import pwd
-        import grp
+
+        # Use prelink_undo_cmd macro?
+        prelink_cmd = "/usr/sbin/prelink"
+        have_prelink = os.path.exists(prelink_cmd)
+
         for filetuple in fi:
             #tuple is: (filename, fsize, mode, mtime, flags, frdev?, inode, link,
             #           state, vflags?, user, group, md5sum(or none for dirs) 
@@ -865,11 +871,11 @@ class YumInstalledPackage(YumHeaderPackage):
             problems = []
             if os.path.exists(fn):
                 # stat
-                my_st = os.stat(fn)
+                my_st = os.lstat(fn)
                 my_user = pwd.getpwuid(my_st[stat.ST_UID])[0]
                 my_group = grp.getgrgid(my_st[stat.ST_GID])[0]
 
-                if my_st[stat.ST_MTIME] != mtime:
+                if my_st.st_mtime != mtime:
                     thisproblem = misc.GenericHolder()
                     thisproblem.type = 'mtime' # maybe replace with a constants type
                     thisproblem.message = 'mtime does not match'
@@ -894,14 +900,12 @@ class YumInstalledPackage(YumHeaderPackage):
                     
                 # checksum
                 if csum: # don't checksum files that don't have a csum in the rpmdb :)
-                    # Use prelink_undo_cmd macro?
-                    have_prelink = os.path.exists("/usr/sbin/prelink")
-
                     my_csum = misc.checksum('md5', fn)
                     if my_csum != csum and have_prelink:
                         #  This is how rpm -V works, try and if that fails try
                         # again with prelink.
-                        (ig, fp) = os.popen2(["/usr/sbin/prelink", "-y", fn])
+                        (ig, fp,er) = os.popen3([prelink_cmd, "-y", fn])
+                        er.read(1024 * 1024) # Try and get most of the stderr
                         my_csum = misc.checksum('md5', fp)
 
                     if my_csum != csum:



More information about the Yum-cvs-commits mailing list