emaint binhost: check SIZE and MTIME
authorZac Medico <zmedico@gentoo.org>
Sat, 18 Jun 2011 19:51:12 +0000 (12:51 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 18 Jun 2011 19:51:12 +0000 (12:51 -0700)
bin/emaint

index 1b1df71c11b5d617d9f9aa4b7d5ba9fb7baa494d..7294d79d7138394d14e452a0a52813bb578b5f90 100755 (executable)
@@ -5,6 +5,7 @@ from __future__ import print_function
 
 import re
 import signal
+import stat
 import sys
 import textwrap
 import time
@@ -19,6 +20,9 @@ except ImportError:
 
 from portage import os
 
+if sys.hexversion >= 0x3000000:
+       long = int
+
 class WorldHandler(object):
 
        short_desc = "Fix problems in the world file"
@@ -185,7 +189,23 @@ class BinhostHandler(object):
                                del missing[:]
                                for i, cpv in enumerate(cpv_all):
                                        d = metadata.get(cpv)
-                                       if not d or "MD5" not in d:
+                                       if not d or \
+                                               "MD5" not in d or \
+                                               "SIZE" not in d or \
+                                               "MTIME" not in d:
+                                               missing.append(cpv)
+                                               continue
+
+                                       pkg_path = bintree.getname(cpv)
+                                       s = os.lstat(pkg_path)
+                                       try:
+                                               if long(d["MTIME"]) != s[stat.ST_MTIME]:
+                                                       missing.append(cpv)
+                                                       continue
+                                               if long(d["SIZE"]) != long(s.st_size):
+                                                       missing.append(cpv)
+                                                       continue
+                                       except ValueError:
                                                missing.append(cpv)
 
                                maxval = len(missing)