diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2022-04-06 13:51:08 +0200 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2022-04-07 13:19:52 +0200 |
| commit | 824651ded0bcf8603e9b508860b8fe5a68fc53ff (patch) | |
| tree | ea9b042a2d16cfc6723851faf87c119d03d9b78f /apt-pkg/algorithms.cc | |
| parent | 023c270e27e09cad9f35908caeb933fb23f8bd79 (diff) | |
Only protect two kernels, not last installed one
The kernel autoremoval algorithm was written to accomodate
for Ubuntu's boot partition sizing, which was written to
accomodate 3 kernels - 2 installed ones + a new one being
unpacked.
It seems that when the algorithm was designed, it was overlooked
that it actually kept 3 kernels.
LP: #1968154
Diffstat (limited to 'apt-pkg/algorithms.cc')
| -rw-r--r-- | apt-pkg/algorithms.cc | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index fb0b7dca7..09fd78329 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1514,9 +1514,6 @@ std::string GetProtectedKernelsRegex(pkgCache *cache, bool ReturnRemove) // needs to be initialized to 0s, might not be set up. utsname uts{}; std::string bootedVersion; - std::string lastInstalledVersion; - - std::string lastInstalledUname = _config->Find("APT::LastInstalledKernel"); // Get currently booted version, but only when not on reproducible build. if (getenv("SOURCE_DATE_EPOCH") == 0) @@ -1548,8 +1545,6 @@ std::string GetProtectedKernelsRegex(pkgCache *cache, bool ReturnRemove) if (pkgUname == uts.release) bootedVersion = pkgVersion; - if (pkgUname == lastInstalledUname) - lastInstalledVersion = pkgVersion; } if (version2unames.size() == 0) @@ -1567,19 +1562,13 @@ std::string GetProtectedKernelsRegex(pkgCache *cache, bool ReturnRemove) std::clog << "Keeping booted kernel " << bootedVersion << std::endl; keep.insert(bootedVersion); } - if (not lastInstalledVersion.empty()) - { - if (Debug) - std::clog << "Keeping installed kernel " << lastInstalledVersion << std::endl; - keep.insert(lastInstalledVersion); - } if (latest != version2unames.rend()) { if (Debug) std::clog << "Keeping latest kernel " << latest->first << std::endl; keep.insert(latest->first); } - if (keep.size() < 3 && previous != version2unames.rend()) + if (keep.size() < 2 && previous != version2unames.rend()) { if (Debug) std::clog << "Keeping previous kernel " << previous->first << std::endl; @@ -1596,8 +1585,6 @@ std::string GetProtectedKernelsRegex(pkgCache *cache, bool ReturnRemove) for (auto &pattern : _config->FindVector("APT::VersionedKernelPackages")) { // Legacy compatibility: Always protected the booted uname and last installed uname - if (not lastInstalledUname.empty()) - ss << "|^" << pattern << "-" << escapeSpecial(lastInstalledUname) << "$"; if (*uts.release) ss << "|^" << pattern << "-" << escapeSpecial(uts.release) << "$"; for (auto const &kernel : version2unames) |
