On 2026-11-16 13:58:11 -0600, David Wright wrote:
> It would be more realistic to try out Vincent's suggestion by
> testing with APT::NeverAutoRemove::KernelCount "N"; where N=0…6
> in turn.

Yes. And the current code (3.3.7) in apt-pkg/algorithms.cc is

   auto keepKernels = (unsigned 
long)_config->FindI("APT::NeverAutoRemove::KernelCount", 2);
   if (keepKernels < 2)
      keepKernels = 2;

   if (Debug)
      std::clog << "Amount of kernels to keep " << keepKernels << std::endl;

   if (not bootedVersion.empty())
   {
      if (Debug)
         std::clog << "Keeping booted kernel " << bootedVersion << std::endl;
      keep.insert(bootedVersion);
   }

   while (keep.size() < keepKernels && versions != version2unames.rend())
   {
      auto v = versions->first;
      if (v == bootedVersion)
      {
         versions++;
         continue;
      }
      if (Debug)
         std::clog << "Keeping previous kernel " << v << std::endl;
      keep.insert(v);
      versions++;
   }

So it can output debug information. It would be interesting to get it.
If this loop outputs unexpected "Keeping previous kernel" lines, then
the bug is there. If not...

Later in the code:

   if (Debug)
      std::clog << "Kernel protection regex: " << re << "\n";

See whether the constructed regex is correct.

-- 
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

Reply via email to