diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2023-11-20 10:02:21 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2023-11-20 10:04:05 +0100 |
commit | b6f362e8013b03efce54e7381e0e22fac1fa1539 (patch) | |
tree | a93619c3df86e5a5b1bb7194d9072251828e5b57 | |
parent | 1f5ecf5d211a073892e05047becd4e55f3e055c9 (diff) |
Restore ?garbage by calling MarkAndSweep before parsing
This ensures that things work correctly.
LP: #1995790
-rw-r--r-- | apt-private/private-install.cc | 3 | ||||
-rwxr-xr-x | test/integration/test-apt-get-autoremove | 22 |
2 files changed, 25 insertions, 0 deletions
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index e366634ad..2f254ca27 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -669,6 +669,9 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector<PseudoPkg fallback = MOD_REMOVE; } + // We need to MarkAndSweep before parsing commandline so that ?garbage pattern works correctly. + Cache->MarkAndSweep(); + std::list<APT::VersionSet::Modifier> mods; mods.push_back(APT::VersionSet::Modifier(MOD_INSTALL, "+", APT::VersionSet::Modifier::POSTFIX, APT::CacheSetHelper::CANDIDATE)); diff --git a/test/integration/test-apt-get-autoremove b/test/integration/test-apt-get-autoremove index 5546958a0..66257f442 100755 --- a/test/integration/test-apt-get-autoremove +++ b/test/integration/test-apt-get-autoremove @@ -75,6 +75,28 @@ The following packages will be REMOVED: po-debconf 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. Remv po-debconf [1.0.16]' aptget upgrade -s --autoremove +testsuccessequal 'Reading package lists... +Building dependency tree... +Reading state information... +The following packages will be REMOVED: + po-debconf +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv po-debconf [1.0.16]' aptget install -s '?garbage-' +testsuccessequal 'Reading package lists... +Building dependency tree... +Reading state information... +The following packages will be REMOVED: + po-debconf +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv po-debconf [1.0.16]' aptget remove -s '?garbage' +testsuccessequal 'Reading package lists... +Building dependency tree... +Reading state information... +Calculating upgrade... +The following packages will be REMOVED: + po-debconf +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv po-debconf [1.0.16]' aptget upgrade -s '?garbage-' echo 'APT::Get::AutomaticRemove "true";' > rootdir/etc/apt/apt.conf.d/autoremoval testsuccessequal 'Reading package lists... Building dependency tree... |