Browse Source

Ignore AutomaticRemove conffile option in upgrade

We are in a dilemma here: The regression of sorts was introduced in 2013
with commit d8a8f9d7f0 allowing pkg modifiers for the upgrade commands.
That calls the autoremover as a sideeffect through and with it comes the
option to remove the garbage packages in these commands (similar to aptitude).

Having the option on the commandline is no problem – people aren't going
to request what they don't want (or so I hope), but the documentation
explicitly states that this option only effects install/remove and
mentions a config knob users might use and expect to not suddenly apply
(especially without documentation) to more commands.

Just reverting the commit is out of question, completely ignoring the
option breaks the workflow of every user who happened to use
--autoremove on the commandline for upgrade and expects that to work
given that it was accepted and worked in a stable release. Changing the
documentation to reflect reality while perhaps the simplest and cleanest
option contradicts freeze and is a surprising change we tend to avoid
like the plague while just leaving it be confuses all users who end up
believing the documentation even if was different in the last 3 years.

So what we do is a tricky compromise: The configuration option if read
from a file does apply only for install/remove as documented, while if
the option is encountered on the commandline it is accepted and applies
to the upgrade which should make 99% of the users happy. The rest has to
wait for us to figure out for buster how to get that documented and
implemented in a saner way.

Closes: #855891
tags/debian/1.4
David Kalnischkies 4 years ago
parent
commit
c89b22c285
2 changed files with 51 additions and 0 deletions
  1. +10
    -0
      apt-private/private-cmndline.cc
  2. +41
    -0
      test/integration/test-apt-get-autoremove

+ 10
- 0
apt-private/private-cmndline.cc View File

@@ -474,6 +474,16 @@ static void BinaryCommandSpecificConfiguration(char const * const Binary, char c
std::string const binary = flNotDir(Binary);
if (binary == "apt-get" && CmdMatches("update"))
_config->CndSet("Binary::apt-get::Acquire::AllowInsecureRepositories", true);
if ((binary == "apt" || binary == "apt-get") && CmdMatches("upgrade", "dist-upgrade", "full-upgrade"))
{
//FIXME: the option is documented to apply only for install/remove, so
// we force it false for configuration files where users can be confused if
// we support it anyhow, but allow it on the commandline to take effect
// even through it isn't documented as a user who doesn't want it wouldn't
// ask for it
_config->Set("Binary::apt-get::APT::Get::AutomaticRemove", false);
_config->Set("Binary::apt::APT::Get::AutomaticRemove", false);
}
}
#undef CmdMatches
/*}}}*/


+ 41
- 0
test/integration/test-apt-get-autoremove View File

@@ -46,6 +46,47 @@ Reading state information...
1 package was automatically installed and is no longer required.
Use '$AUTOREMOVE' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
testequal "Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following package was automatically installed and is no longer required:
po-debconf
Use '$AUTOREMOVE' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget upgrade -s
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 --autoremove
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 --autoremove
echo 'APT::Get::AutomaticRemove "true";' > rootdir/etc/apt/apt.conf.d/autoremoval
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
testequal "Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following package was automatically installed and is no longer required:
po-debconf
Use '$AUTOREMOVE' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget upgrade -s
rm -f rootdir/etc/apt/apt.conf.d/autoremoval

testdpkginstalled 'po-debconf'

echo 'APT::NeverAutoRemove { "^po-debconf$"; };' > rootdir/etc/apt/apt.conf.d/00autoremove


Loading…
Cancel
Save