[Piuparts-commits] rev 61 - trunk

Ana Beatriz Guerrero López ana at alioth.debian.org
Wed Aug 15 23:48:00 UTC 2007


Author: ana
Date: 2007-08-15 23:48:00 +0000 (Wed, 15 Aug 2007)
New Revision: 61

Modified:
   trunk/piuparts.py
Log:
add piuparts test to check cronfiles. It is not finished yet.


Modified: trunk/piuparts.py
===================================================================
--- trunk/piuparts.py	2007-08-06 13:52:41 UTC (rev 60)
+++ trunk/piuparts.py	2007-08-15 23:48:00 UTC (rev 61)
@@ -752,8 +752,32 @@
 	    panic()
         else:
             logging.debug("No broken symlinks as far as we can find.")
+	    
+    def check_if_cronfiles(self, packages):
+        """Check if a package has cron files under /etc/cron.d and in case positive, 
+        it returns the list of files. """
 
+        dir = self.relative("var/lib/dpkg/info")
+        list = []
+        has_cronfiles  = False
+        for p in packages:
+            basename = p + ".list"
+            f = file(os.path.join(dir,basename), "r")
+            for line in f:
+                pathname = line.strip()
+		if pathname.startswith("/etc/cron.") and os.path.isfile(pathname):
+		    if not has_cronfiles:
+		        has_cronfiles = True
+                    list.append(pathname)
+		    logging.debug("Cronfile found: " + pathname)
+            f.close()
+        return has_cronfiles, list
 
+    def check_output_cronfiles (self, list):
+        """Check if a given list of cronfiles has any output."""
+        for file in list:
+            logging.info("Checking cronfile: " + file)
+
 def objects_are_different(pair1, pair2):
     """Are filesystem objects different based on their meta data?"""
     (m1, target1) = pair1
@@ -902,6 +926,8 @@
         chroot.install_packages_by_name(packages)
         chroot.run(["apt-get", "clean"])
 
+    cronfiles, cronfiles_list = chroot.check_if_cronfiles(packages)
+
     chroot.check_for_no_processes()
     chroot.check_for_broken_symlinks()
 
@@ -912,6 +938,10 @@
     chroot.restore_selections(changes, packages)
     
     chroot.check_for_broken_symlinks()
+    if cronfiles:
+        chroot.check_output_cronfiles(cronfiles_list)
+    else:
+        logging.info("The packages does not have cronfiles")
     chroot.unmount_proc()
 
     return check_results(chroot, root_info, file_owners, packages=packages)




More information about the Piuparts-commits mailing list