From 58377ceb4b62e8f50ddae8f17ce1511e4bf79a18 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 30 May 2014 13:42:36 +0200 Subject: if Resolver fails, do not continue even if not broken This can happen if the request is already a well-formed request all by itself (e.g. the package has no dependencies), but the resolver found a reason to not accept it as solution. Our edsp 'dump' solver e.g. shouldn't be able to trigger install, which it does otherwise. --- apt-private/private-install.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-private/private-install.cc') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 107ed398e..f15ccc398 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -617,7 +617,8 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, if (Fix != NULL) { // Call the scored problem resolver - Fix->Resolve(true); + if (Fix->Resolve(true) == false && Cache->BrokenCount() == 0) + return false; } // Now we check the state of the packages, -- cgit v1.2.3 From 4d695011895d332685ebfaf21a79e8e4337e003e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 9 Jun 2014 15:50:20 +0200 Subject: separate implementation from declaration of TryTo{Install,Remove} Git-Dch: Ignore --- apt-private/private-install.cc | 141 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) (limited to 'apt-private/private-install.cc') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index f15ccc398..a365d4294 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -802,3 +802,144 @@ bool DoInstall(CommandLine &CmdL) return InstallPackages(Cache,false); } /*}}}*/ + +// TryToInstall - Mark a package for installation /*{{{*/ +void TryToInstall::operator() (pkgCache::VerIterator const &Ver) { + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + + Cache->GetDepCache()->SetCandidateVersion(Ver); + pkgDepCache::StateCache &State = (*Cache)[Pkg]; + + // Handle the no-upgrade case + if (_config->FindB("APT::Get::upgrade",true) == false && Pkg->CurrentVer != 0) + ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"), + Pkg.FullName(true).c_str()); + // Ignore request for install if package would be new + else if (_config->FindB("APT::Get::Only-Upgrade", false) == true && Pkg->CurrentVer == 0) + ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"), + Pkg.FullName(true).c_str()); + else { + if (Fix != NULL) { + Fix->Clear(Pkg); + Fix->Protect(Pkg); + } + Cache->GetDepCache()->MarkInstall(Pkg,false); + + if (State.Install() == false) { + if (_config->FindB("APT::Get::ReInstall",false) == true) { + if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false) + ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"), + Pkg.FullName(true).c_str()); + else + Cache->GetDepCache()->SetReInstall(Pkg, true); + } else + ioprintf(c1out,_("%s is already the newest version.\n"), + Pkg.FullName(true).c_str()); + } + + // Install it with autoinstalling enabled (if we not respect the minial + // required deps or the policy) + if (FixBroken == false) + doAutoInstallLater.insert(Pkg); + } + + // 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++; + } +} + /*}}}*/ +bool TryToInstall::propergateReleaseCandiateSwitching(std::list > const &start, std::ostream &out)/*{{{*/ +{ + for (std::list >::const_iterator s = start.begin(); + s != start.end(); ++s) + Cache->GetDepCache()->SetCandidateVersion(s->first); + + bool Success = true; + // the Changed list contains: + // first: "new version" + // second: "what-caused the change" + std::list > Changed; + for (std::list >::const_iterator s = start.begin(); + s != start.end(); ++s) + { + Changed.push_back(std::make_pair(s->first, pkgCache::VerIterator(*Cache))); + // We continue here even if it failed to enhance the ShowBroken output + Success &= Cache->GetDepCache()->SetCandidateRelease(s->first, s->second, Changed); + } + for (std::list >::const_iterator c = Changed.begin(); + c != Changed.end(); ++c) + { + if (c->second.end() == true) + ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"), + c->first.VerStr(), c->first.RelStr().c_str(), c->first.ParentPkg().FullName(true).c_str()); + else if (c->first.ParentPkg()->Group != c->second.ParentPkg()->Group) + { + pkgCache::VerIterator V = (*Cache)[c->first.ParentPkg()].CandidateVerIter(*Cache); + ioprintf(out, _("Selected version '%s' (%s) for '%s' because of '%s'\n"), V.VerStr(), + V.RelStr().c_str(), V.ParentPkg().FullName(true).c_str(), c->second.ParentPkg().FullName(true).c_str()); + } + } + return Success; +} + /*}}}*/ +void TryToInstall::doAutoInstall() { /*{{{*/ + for (APT::PackageSet::const_iterator P = doAutoInstallLater.begin(); + P != doAutoInstallLater.end(); ++P) { + pkgDepCache::StateCache &State = (*Cache)[P]; + if (State.InstBroken() == false && State.InstPolicyBroken() == false) + continue; + Cache->GetDepCache()->MarkInstall(P, true); + } + doAutoInstallLater.clear(); +} + /*}}}*/ +// TryToRemove - Mark a package for removal /*{{{*/ +void TryToRemove::operator() (pkgCache::VerIterator const &Ver) +{ + pkgCache::PkgIterator Pkg = Ver.ParentPkg(); + + if (Fix != NULL) + { + Fix->Clear(Pkg); + Fix->Protect(Pkg); + Fix->Remove(Pkg); + } + + if ((Pkg->CurrentVer == 0 && PurgePkgs == false) || + (PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled)) + { + pkgCache::GrpIterator Grp = Pkg.Group(); + pkgCache::PkgIterator P = Grp.PackageList(); + for (; P.end() != true; P = Grp.NextPkg(P)) + { + if (P == Pkg) + continue; + if (P->CurrentVer != 0 || (PurgePkgs == true && P->CurrentState != pkgCache::State::NotInstalled)) + { + // TRANSLATORS: Note, this is not an interactive question + ioprintf(c1out,_("Package '%s' is not installed, so not removed. Did you mean '%s'?\n"), + Pkg.FullName(true).c_str(), P.FullName(true).c_str()); + break; + } + } + if (P.end() == true) + ioprintf(c1out,_("Package '%s' is not installed, so not removed\n"),Pkg.FullName(true).c_str()); + + // MarkInstall refuses to install packages on hold + Pkg->SelectedState = pkgCache::State::Hold; + } + else + Cache->GetDepCache()->MarkDelete(Pkg, PurgePkgs); +} + /*}}}*/ -- cgit v1.2.3 From 172947cd7dc5c88c94c6ad269dc6c6be002ee958 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 17 Jun 2014 19:05:53 +0200 Subject: do not call resolver twice on (dist-)upgrade --- apt-private/private-install.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'apt-private/private-install.cc') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index a365d4294..e08cd8057 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -524,15 +525,14 @@ static bool DoAutomaticRemove(CacheFile &Cache) static const unsigned short MOD_REMOVE = 1; static const unsigned short MOD_INSTALL = 2; -bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache) +bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, int UpgradeMode) { std::map verset; - return DoCacheManipulationFromCommandLine(CmdL, Cache, verset); + return DoCacheManipulationFromCommandLine(CmdL, Cache, verset, UpgradeMode); } bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, - std::map &verset) + std::map &verset, int UpgradeMode) { - // Enter the special broken fixing mode if the user specified arguments bool BrokenFix = false; if (Cache->BrokenCount() != 0) @@ -617,7 +617,17 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, if (Fix != NULL) { // Call the scored problem resolver - if (Fix->Resolve(true) == false && Cache->BrokenCount() == 0) + bool resolver_fail = false; + if (UpgradeMode == 0) + { + if (strcmp(CmdL.FileList[0], "dist-upgrade") == 0 || strcmp(CmdL.FileList[0], "full-upgrade") == 0) + resolver_fail = APT::Upgrade::Upgrade(Cache, 0); + else + resolver_fail = Fix->Resolve(true); + } else + resolver_fail = APT::Upgrade::Upgrade(Cache, UpgradeMode); + + if (resolver_fail == false && Cache->BrokenCount() == 0) return false; } @@ -676,7 +686,7 @@ bool DoInstall(CommandLine &CmdL) std::map verset; - if(!DoCacheManipulationFromCommandLine(CmdL, Cache, verset)) + if(!DoCacheManipulationFromCommandLine(CmdL, Cache, verset, 0)) return false; /* Print out a list of packages that are going to be installed extra -- cgit v1.2.3 From 2a884c612b10b27f4be2cc6dd689bfe448d9361a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 17 Aug 2014 12:30:21 +0200 Subject: fix progress output for (dist-)upgrade calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, we had a start and a done of the calculation printed by higher-level code, but this got intermixed by progress reporting from an external solver or the output of autoremove codeā€¦ The higherlevel code is now only responsible for instantiating a progress object of its choosing (if it wants progress after all) and the rest will be handled by the upgrade code. Either it is used to show the progress of the external solver or the internal solver will give some hints about its overall progress. The later isn't really a proper progress as it will jump forward after each substep, but that is at least a bit better than before without any progress indication. Fixes also the 'strange' non-display of this progress line in -q=1, while all others are shown, which is reflected by all testcase changes. --- apt-private/private-install.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'apt-private/private-install.cc') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 55893bda0..656b97233 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -620,14 +620,17 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, { // Call the scored problem resolver bool resolver_fail = false; + OpTextProgress Progress(*_config); + bool const distUpgradeMode = strcmp(CmdL.FileList[0], "dist-upgrade") == 0 || strcmp(CmdL.FileList[0], "full-upgrade") == 0; + if (UpgradeMode == 0) { - if (strcmp(CmdL.FileList[0], "dist-upgrade") == 0 || strcmp(CmdL.FileList[0], "full-upgrade") == 0) - resolver_fail = APT::Upgrade::Upgrade(Cache, 0); + if (distUpgradeMode == true) + resolver_fail = APT::Upgrade::Upgrade(Cache, 0, &Progress); else - resolver_fail = Fix->Resolve(true); + resolver_fail = Fix->Resolve(true, &Progress); } else - resolver_fail = APT::Upgrade::Upgrade(Cache, UpgradeMode); + resolver_fail = APT::Upgrade::Upgrade(Cache, UpgradeMode, &Progress); if (resolver_fail == false && Cache->BrokenCount() == 0) return false; -- cgit v1.2.3 From 67caa2e6538f13ff7a0d77e98ad6c58af998376d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 17 Aug 2014 13:27:59 +0200 Subject: mark pkg(All|Dist)Upgrade as deprecated The comment above their definition marks them already as such, so this is only a formalisation of the deprecation and fixes the occurances we have in our own code together with removing a magic number. Git-Dch: Ignore --- apt-private/private-install.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'apt-private/private-install.cc') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 656b97233..c172f5ee7 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -619,18 +619,14 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, if (Fix != NULL) { // Call the scored problem resolver - bool resolver_fail = false; OpTextProgress Progress(*_config); bool const distUpgradeMode = strcmp(CmdL.FileList[0], "dist-upgrade") == 0 || strcmp(CmdL.FileList[0], "full-upgrade") == 0; - if (UpgradeMode == 0) - { - if (distUpgradeMode == true) - resolver_fail = APT::Upgrade::Upgrade(Cache, 0, &Progress); - else - resolver_fail = Fix->Resolve(true, &Progress); - } else + bool resolver_fail = false; + if (distUpgradeMode == true || UpgradeMode != APT::Upgrade::ALLOW_EVERYTHING) resolver_fail = APT::Upgrade::Upgrade(Cache, UpgradeMode, &Progress); + else + resolver_fail = Fix->Resolve(true, &Progress); if (resolver_fail == false && Cache->BrokenCount() == 0) return false; -- cgit v1.2.3 From e6f0c9bca4b052d20a2e48ce9715b89e187b671a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 3 Sep 2014 19:02:05 +0200 Subject: adapt to the new CacheSetHelper API Git-Dch: Ignore --- apt-private/private-install.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-private/private-install.cc') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index c172f5ee7..86ba52857 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -560,9 +560,9 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, std::list mods; mods.push_back(APT::VersionSet::Modifier(MOD_INSTALL, "+", - APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::CANDIDATE)); + APT::VersionSet::Modifier::POSTFIX, APT::CacheSetHelper::CANDIDATE)); mods.push_back(APT::VersionSet::Modifier(MOD_REMOVE, "-", - APT::VersionSet::Modifier::POSTFIX, APT::VersionSet::NEWEST)); + APT::VersionSet::Modifier::POSTFIX, APT::CacheSetHelper::NEWEST)); CacheSetHelperAPTGet helper(c0out); verset = APT::VersionSet::GroupedFromCommandLine(Cache, CmdL.FileList + 1, mods, fallback, helper); -- cgit v1.2.3