Bug#611729: apt: apt-get does not always mark a package as manually installed
Package: apt
Version: 0.8.10
Severity: normal
Tags: patch
[ This bug has been found in Maemo's version of apt, absed on 0.7.25.3,
and has only confirmed to be present in Debian's version of apt by
reading the code. Thus, I don't include any information about my
Debian installation.
]
Apt-get does not always mark a package as manually installed when it
should. I only have a Gedanken Test Case for reproduction, sorry, but
it should be simple.
Consider this scenario:
Package: a
Depends: b
Package: b
Neither a nor b are installed. Then
$ apt-get install a b
will not mark b as manually installed.
The culprit is this code in cmd-line/apt-get.cc, function TryToInstall:
// see if we need to fix the auto-mark flag
// e.g. apt-get install foo
// where foo is marked automatic
if (State.Install() == false &&
(State.Flags & pkgCache::Flag::Auto) &&
_config->FindB("APT::Get::ReInstall",false) == false &&
_config->FindB("APT::Get::Only-Upgrade",false) == false &&
_config->FindB("APT::Get::Download-Only",false) == false)
{
ioprintf(c1out,_("%s set to manually installed.\n"),
Pkg.FullName(true).c_str());
Cache->GetDepCache()->MarkAuto(Pkg,false);
AutoMarkChanged++;
}
This code will not "fix the auto-mark flag" when State.Install() is
false. However, planning to install a will produce the state where
State.Install() is true for b, and State.Flags for b will include Auto.
The following variant of the code should make this work:
// see if we need to fix the auto-mark flag
// e.g. apt-get install foo
// where foo is marked automatic
if((State.Flags & pkgCache::Flag::Auto) &&
_config->FindB("APT::Get::ReInstall",false) == false &&
_config->FindB("APT::Get::Only-Upgrade",false) == false &&
_config->FindB("APT::Get::Download-Only",false) == false)
{
Cache->GetDepCache()->MarkAuto(Pkg,false);
AutoMarkChanged++;
// If we are not actually installing the package right
// now because it is already installed, at least
// mention that we are changing its auto flag.
if (State.Install() == false)
ioprintf(c1out,_("%s set to manually installed.\n"),
Pkg.FullName(true).c_str());
}
[ No patch since I didn't even compile this. ]
The logic behind this change is that it shouldn't matter whether or not
State.Install() is true when deciding whether to fix the auto-mark. All
we really want is to supress the message in the normal case where a
package is about to be installed.
Reply to: