[Piuparts-commits] rev 647 - in trunk: . debian
Holger Levsen
holger at alioth.debian.org
Tue Feb 23 09:12:40 UTC 2010
Author: holger
Date: 2010-02-23 09:12:36 +0000 (Tue, 23 Feb 2010)
New Revision: 647
Modified:
trunk/debian/changelog
trunk/piuparts.1.txt
trunk/piuparts.py
Log:
* piuparts.py:
- Check for remaining logrotate files which produce output after the
package was removed. (Closes: #566597)
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2010-02-23 01:48:18 UTC (rev 646)
+++ trunk/debian/changelog 2010-02-23 09:12:36 UTC (rev 647)
@@ -1,5 +1,6 @@
piuparts (0.39) UNRELEASED; urgency=low
+ [ Holger Levsen ]
* piuparts-report.py:
- report packages which failed due to broken maintainer scripts,
due to output from cron after removal and due to not enough force being
@@ -26,8 +27,13 @@
* Makefile: support python 2.5 and 2.6 instead of 2.4 and 2.5, adjust
debian/control accordingly.
- -- Holger Levsen <holger at debian.org> Fri, 18 Dec 2009 13:32:16 +0100
+ [ Evgeni Golov ]
+ * piuparts.py:
+ - Check for remaining logrotate files which produce output after the
+ package was removed. (Closes: #566597)
+ -- Holger Levsen <holger at debian.org> Sun, 24 Jan 2010 15:27:50 +0100
+
piuparts (0.38) unstable; urgency=low
* piuparts.py:
Modified: trunk/piuparts.1.txt
===================================================================
--- trunk/piuparts.1.txt 2010-02-23 01:48:18 UTC (rev 646)
+++ trunk/piuparts.1.txt 2010-02-23 09:12:36 UTC (rev 647)
@@ -132,6 +132,9 @@
*--skip-cronfiles-test*::
Skip testing the output from the cron files left in the system after remove a package.
+*--skip-logrotatefiles-test*::
+ Skip testing the output from the logrotate files left in the system after remove a package.
+
*-t directory, --tmpdir*='directory'::
Use directory as the place where temporary files and directories are created. The default is the environment variable *TMPDIR*, or _/tmp_ if not set.
Modified: trunk/piuparts.py
===================================================================
--- trunk/piuparts.py 2010-02-23 01:48:18 UTC (rev 646)
+++ trunk/piuparts.py 2010-02-23 09:12:36 UTC (rev 647)
@@ -148,6 +148,7 @@
self.list_installed_files = False
self.no_upgrade_test = False
self.skip_cronfiles_test = False
+ self.skip_logrotatefiles_test = False
self.check_broken_symlinks = True
self.warn_broken_symlinks = False
self.debfoster_options = None
@@ -850,6 +851,12 @@
if not settings.skip_cronfiles_test and cronfiles:
self.check_output_cronfiles(cronfiles_list)
+ if not settings.skip_logrotatefiles_test:
+ logrotatefiles, logrotatefiles_list = self.check_if_logrotatefiles(packages)
+
+ if not settings.skip_logrotatefiles_test and logrotatefiles:
+ self.check_output_logrotatefiles(logrotatefiles_list)
+
# Then purge all packages being depended on.
self.remove_or_purge("purge", deps_to_purge)
@@ -1033,6 +1040,51 @@
if failed:
panic()
+ def check_if_logrotatefiles(self, packages):
+ """Check if the packages have logrotate files under /etc/logrotate.d and in case positive,
+ it returns the list of files. """
+
+ dir = self.relative("var/lib/dpkg/info")
+ list = []
+ has_logrotatefiles = False
+ for p in packages:
+ basename = p + ".list"
+
+ if not os.path.exists(os.path.join(dir,basename)):
+ continue
+
+ f = file(os.path.join(dir,basename), "r")
+ for line in f:
+ pathname = line.strip()
+ if pathname.startswith("/etc/logrotate.d/"):
+ if os.path.isfile(self.relative(pathname.strip("/"))):
+ if not has_logrotatefiles:
+ has_logrotatefiles = True
+ list.append(pathname)
+ logging.info("Package " + p + " contains logrotate file: " + pathname)
+ f.close()
+
+ return has_logrotatefiles, list
+
+ def check_output_logrotatefiles (self, list):
+ """Check if a given list of logrotatefiles has any output. Executes
+ logrotate file as logrotate would do from cron (except for SHELL)"""
+ failed = False
+ # XXX That's a crude hack. Can't we define a set of needed packages differently?
+ (a,b) = self.run(['apt-get','install', '-y', 'logrotate'])
+ for file in list:
+
+ if not os.path.exists(self.relative(file.strip("/"))):
+ continue
+
+ (retval, output) = self.run(['/usr/sbin/logrotate', file])
+ if output:
+ failed = True
+ logging.error("FAIL: Logrotate file %s has output with package removed" % file)
+
+ if failed:
+ panic()
+
def run_scripts (self, step):
""" Run custom scripts to given step post-install|remove|purge"""
@@ -1881,6 +1933,10 @@
action="store_true", default=False,
help="Skip testing the output from the cron files.")
+ parser.add_option("--skip-logrotatefiles-test",
+ action="store_true", default=False,
+ help="Skip testing the output from the logrotate files.")
+
parser.add_option("--skip-minimize",
action="store_true", default=True,
help="Skip minimize chroot step. This is the default now.")
@@ -1935,6 +1991,7 @@
settings.list_installed_files = opts.list_installed_files
settings.no_upgrade_test = opts.no_upgrade_test
settings.skip_cronfiles_test = opts.skip_cronfiles_test
+ settings.skip_logrotatefiles_test = opts.skip_logrotatefiles_test
settings.keyring = opts.keyring
settings.do_not_verify_signatures = opts.do_not_verify_signatures
if settings.do_not_verify_signatures:
More information about the Piuparts-commits
mailing list