[Piuparts-devel] Bug#588041: [PATCH] use apt-get remove; remove/purge all packages at once

Andreas Beckmann debian at abeckmann.de
Sun Nov 6 14:44:26 UTC 2011


On 2011-11-06 01:49, Andreas Beckmann wrote:
> 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.

For proceeding with this patch I'd like to know if the current behaviour
of removing/purging package by package without looking at dependencies
should be available via an command line option (currently marked as
TODO) or if I can drop just the old remove_or_purge as not needed any
longer.


Andreas

> 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  (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)






More information about the Piuparts-devel mailing list