[Piuparts-devel] Bug#588041: [PATCH] use apt-get remove; remove/purge all packages at once
Andreas Beckmann
debian at abeckmann.de
Sun Nov 6 00:49:32 UTC 2011
Removing packages with dpkg one-by-one does not respect dependencies
therefore use apt-get remove to reorder the packages properly.
apt-get purge can't be used because it fails on unknown packages (i.e. not
in the archive and not in config-files-remaining state). See #637853.
But we can purge all packages in one dpkg call.
Also apt-get in lenny is not able to properly purge previously removed
packages.
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
---
piuparts.py | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/piuparts.py b/piuparts.py
index b3d4667..7464f9b 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -864,12 +864,27 @@ class Chroot:
vdict[name] = status
return vdict
+ def remove_packages(self, packages):
+ """Remove packages in a chroot."""
+ if not False: # ToDo: settings.remove_one_by_one
+ if packages:
+ self.run(["apt-get", "remove"] + packages, ignore_errors=True)
+ else:
+ self.remove_or_purge("remove", packages)
+
+ def purge_packages(self, packages):
+ """Purge packages in a chroot."""
+ if not False: # ToDo: settings.purge_one_by_one
+ if packages:
+ self.run(["dpkg", "--purge"] + packages, ignore_errors=True)
+ else:
+ self.remove_or_purge("purge", packages)
+
def remove_or_purge(self, operation, packages):
- """Remove or purge packages in a chroot."""
+ """Remove or purge packages in a chroot. No dependency ordering."""
for name in packages:
self.run(["dpkg", "--" + operation, name], ignore_errors=True)
self.run(["dpkg", "--remove", "--pending"], ignore_errors=True)
-
def restore_selections(self, changes, packages):
"""Restore package selections in a chroot by applying 'changes'.
@@ -897,8 +912,8 @@ class Chroot:
self.run_scripts("pre_remove")
# First remove all packages.
- self.remove_or_purge("remove", deps_to_remove + deps_to_purge +
- nondeps_to_remove + nondeps_to_purge)
+ self.remove_packages(deps_to_remove + deps_to_purge +
+ nondeps_to_remove + nondeps_to_purge)
# Run custom scripts after removing all packages.
if settings.scriptsdir is not None:
self.run_scripts("post_remove")
@@ -915,13 +930,13 @@ class Chroot:
if not settings.skip_logrotatefiles_test and logrotatefiles:
installed = self.install_logrotate()
self.check_output_logrotatefiles(logrotatefiles_list)
- self.remove_or_purge("purge", installed)
+ self.purge_packages(installed)
# Then purge all packages being depended on.
- self.remove_or_purge("purge", deps_to_purge)
+ self.purge_packages(deps_to_purge)
# Finally, purge actual packages.
- self.remove_or_purge("purge", nondeps_to_purge)
+ self.purge_packages(nondeps_to_purge)
# Run custom scripts after purge all packages.
if settings.scriptsdir is not None:
--
tg: (b51c8c4..) t/feat/apt-get-remove (depends on: t/fix/purge-logrotate)
More information about the Piuparts-devel
mailing list