From 7db98f31498a85da22cc00e446bce8ac8c319554 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 14 Mar 2007 13:10:42 +0100 Subject: * cmdline/apt-get.cc: - "apt-get install foo" on a already installed package foo will clean the automatic installed flag --- cmdline/apt-get.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 4ffb9414b..430b1bccb 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1556,6 +1556,7 @@ bool DoInstall(CommandLine &CmdL) if (Cache->BrokenCount() != 0) BrokenFix = true; + unsigned int AutoMarkChanged = 0; unsigned int ExpectedInst = 0; unsigned int Packages = 0; pkgProblemResolver Fix(Cache); @@ -1692,6 +1693,18 @@ bool DoInstall(CommandLine &CmdL) return false; if (TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,ExpectedInst) == false) return false; + + // see if we need to fix the auto-mark flag + // e.g. apt-get install foo + // where foo is marked automatic + if(Cache[Pkg].Install() == false && + (Cache[Pkg].Flags & pkgCache::Flag::Auto)) + { + ioprintf(c1out,_("%s set to manual installed.\n"), + Pkg.Name()); + Cache->MarkAuto(Pkg,false); + AutoMarkChanged++; + } } } @@ -1854,6 +1867,14 @@ bool DoInstall(CommandLine &CmdL) } + // if nothing changed in the cache, but only the automark information + // we write the StateFile here, otherwise it will be written in + // cache.commit() + if (AutoMarkChanged > 0 && + Cache->DelCount() == 0 && Cache->InstCount() == 0 && + Cache->BadCount() == 0) + Cache->writeStateFile(NULL); + // See if we need to prompt if (Cache->InstCount() == ExpectedInst && Cache->DelCount() == 0) return InstallPackages(Cache,false,false); -- cgit v1.2.3