Package: piuparts
Version: 0.40
Severity: normal
Tags: patch

The "crude hack" for installing and removing logrotate breaks with an
Ubuntu chroot, where adduser will already be installed.

Here's a replacement for the hack.

It changes the order that logrotate is removed in. I assume that isn't a
problem?

Another possible option is to use apt-get's --auto-remove, but I don't
know how good an idea that would be in the cleanup function.

SR

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing-proposed-updates
  APT policy: (500, 'testing-proposed-updates'), (500, 'unstable'), (500, 
'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.0.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_ZA.UTF-8, LC_CTYPE=en_ZA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages piuparts depends on:
ii  apt                        0.8.15.5      Advanced front-end for dpkg
ii  debootstrap                1.0.35        Bootstrap a basic Debian system
ii  lsb-release                3.2-27        Linux Standard Base version report
ii  lsof                       4.81.dfsg.1-1 List open files
ii  python                     2.6.7-3       interactive high-level object-orie
ii  python-debian              0.1.21        Python modules to work with Debian
ii  python-support             1.0.14        automated rebuilding support for P

piuparts recommends no packages.

Versions of packages piuparts suggests:
ii  ghostscript                  9.02~dfsg-3 interpreter for the PostScript lan
pn  python-rpy                   <none>      (no description available)

-- no debconf information
diff --git a/piuparts.py b/piuparts.py
index cae35ee..000e6a4 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -925,7 +926,10 @@ class Chroot:
             logrotatefiles, logrotatefiles_list = self.check_if_logrotatefiles(packages)
 	
         if not settings.skip_logrotatefiles_test and logrotatefiles:
+            installed = self.install_logrotate()
             self.check_output_logrotatefiles(logrotatefiles_list)
+            for pkg in installed:
+                self.remove_or_purge("purge", installed)
 
         # Then purge all packages being depended on.
         self.remove_or_purge("purge", deps_to_purge)
@@ -933,15 +937,6 @@ class Chroot:
         # Finally, purge actual packages.
         self.remove_or_purge("purge", nondeps_to_purge)
 
-        # remove logrotate and it's depends 
-        #    (this is a fix for #602409 introduced by #566597 
-        #    - search for the latter bug number in this file)
-        # XXX: another crude hack: ^^^
-        if not settings.skip_logrotatefiles_test:
-          self.remove_or_purge("remove", ["adduser", "cron", "libpopt0", "logrotate"])
-          self.remove_or_purge("purge", ["adduser", "cron", "libpopt0", "logrotate"])
-          self.run(["apt-get", "clean"])
-
         # Run custom scripts after purge all packages.
         if settings.scriptsdir is not None: 
             self.run_scripts("post_purge")
@@ -1147,13 +1142,19 @@ class Chroot:
 
         return has_logrotatefiles, vlist
 
+    def install_logrotate(self):
+        """Install logrotate for check_output_logrotatefiles, and return the
+        list of packages that were installed"""
+        old_selections = self.get_selections()
+        self.run(['apt-get', 'install', '-y', 'logrotate'])
+        self.run(['apt-get', 'clean'])
+        diff = diff_selections(self, old_selections)
+        return diff.keys()
+
     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 (to fix #602409). Can't we define a set of needed packages differently?
-        #     It also introduces the need for hack to fix #602409 in piuparts.py
-        (a,b) = self.run(['apt-get','install', '-y', 'logrotate'])
         for vfile in list:
 
             if not os.path.exists(self.relative(vfile.strip("/"))):

Reply via email to