Friday 9 September 2022

Re: Upgrade Notifications for Kubuntu and Ubuntu Studio

On Friday, September 9, 2022 3:09:32 AM PDT Julian Andres Klode wrote:
> On Thu, Sep 08, 2022 at 08:46:31PM -0700, Erich Eickmeyer wrote:
> > Hi Aleix,
> >
> > On Thursday, September 8, 2022 1:30:02 PM PDT Aleix Pol wrote:
> > > Note that Discover is just using PackageKit, so it's a problem to
> > > address
> > > there.
> > >
> > > If despite having Discover be "very, very flawed" you want to have a
> > > discussion one day about how to make it fit for your purpose, I'll be
> > > happy to join and see what can be done.
> >
> > That was not meant as an insult to your work, and I'm terribly sorry if it
> > arrived that way. Honestly, Discover is a fine piece of software,
> > especially as a software store and I quite enjoy using it as such.
> > However, I think you're right, my observations toward the "very, very
> > flawed" might be better directed at PackageKit since it doesn't have the
> > capability to do autoremove like I'm suggesting for software updates.
>
> It's not hard to implement, it's basically
>
> bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
> bool doAutoRemoveKernels =
> _config->FindB("APT::Get::AutomaticRemove::Kernels", false); bool
> hideAutoRemove = _config->FindB("APT::Get::HideAutoRemove");
>
> std::unique_ptr<APT::CacheFilter::Matcher> kernelAutoremovalMatcher;
> if (doAutoRemoveKernels && !doAutoRemove)
> {
> kernelAutoremovalMatcher =
> APT::KernelAutoRemoveHelper::GetProtectedKernelsFilter(Cache, true); }
>
> Cache->MarkAndSweep();
>
> SortedPackageUniverse Universe(Cache);
> // look over the cache to see what can be removed
> for (auto const &Pkg: Universe)
> {
> if (Cache[Pkg].Garbage)
> {
> if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install())
> if(Debug)
> std::cout << "We could delete " << APT::PrettyPkg(Cache, Pkg)
> << std::endl; if (doAutoRemove || (kernelAutoremovalMatcher != nullptr &&
> (*kernelAutoremovalMatcher)(Pkg))) {
> if(Pkg.CurrentVer() != 0 &&
> Pkg->CurrentState != pkgCache::State::ConfigFiles)
> Cache->MarkDelete(Pkg, purgePkgs, 0, false);
> else
> Cache->MarkKeep(Pkg, false, false);
> }
>
>
> at the right place after calling Upgrade().
>
> Though I don't know maybe it needs the following code bits too where we
> recover packages we now have broken.
>
> // we could have removed a new dependency of a garbage package,
> // so check if a reverse depends is broken and if so install it again.
>
> Probably it makes sense to extract the non-CLI bits of DoAutoremove() in
> apt-private to apt-pkg, so PackageKit and others just have one function to
> call to do any autoremovals that should be done by policy.

Right. We definitely want to be careful here. The strength of update-manager is
that it presents the user with a checkbox list of packages to remove and gives
them the option whether or not to remove those packages. Autoremoving
wholesale is not what I'm looking for here, and I guess I should've
communicated that better.

--
Erich Eickmeyer
Project Leader - Ubuntu Studio
Member - Ubuntu Community Council