X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/9777639ef84917f37b0c225a99676e3f0f85421a..e7e10e47476606e3b2274cf66b1e8ea74b236757:/apt-private/private-install.cc diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 28b8d9a7b..dda5b50be 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -485,7 +484,11 @@ static bool DoAutomaticRemove(CacheFile &Cache) else ioprintf(c1out, P_("%lu package was automatically installed and is no longer required.\n", "%lu packages were automatically installed and are no longer required.\n", autoRemoveCount), autoRemoveCount); - c1out << P_("Use 'apt-get autoremove' to remove it.", "Use 'apt-get autoremove' to remove them.", autoRemoveCount) << std::endl; + std::string autocmd = "apt autoremove"; + if (getenv("SUDO_USER") != NULL) + autocmd = "sudo " + autocmd; + ioprintf(c1out, P_("Use '%s' to remove it.", "Use '%s' to remove them.", autoRemoveCount), autocmd.c_str()); + c1out << std::endl; } return true; } @@ -495,11 +498,16 @@ static const unsigned short MOD_REMOVE = 1; static const unsigned short MOD_INSTALL = 2; bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, int UpgradeMode) +{ + std::vector VolatileCmdL; + return DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, UpgradeMode); +} +bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, int UpgradeMode) { std::map verset; - return DoCacheManipulationFromCommandLine(CmdL, Cache, verset, UpgradeMode); + return DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, verset, UpgradeMode); } -bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, +bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, std::map &verset, int UpgradeMode) { // Enter the special broken fixing mode if the user specified arguments @@ -535,6 +543,20 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, verset = APT::VersionSet::GroupedFromCommandLine(Cache, CmdL.FileList + 1, mods, fallback, helper); + for (auto const &I: VolatileCmdL) + { + pkgCache::PkgIterator const P = Cache->FindPkg(I); + if (P.end()) + continue; + + // Set any version providing the .deb as the candidate. + for (auto Prv = P.ProvidesList(); Prv.end() == false; Prv++) + Cache.GetDepCache()->SetCandidateVersion(Prv.OwnerVer()); + + // via cacheset to have our usual virtual handling + APT::VersionContainerInterface::FromPackage(&(verset[MOD_INSTALL]), Cache, P, APT::CacheSetHelper::CANDIDATE, helper); + } + if (_error->PendingError() == true) { helper.showVirtualPackageErrors(Cache); @@ -656,33 +678,16 @@ struct PkgIsExtraInstalled { bool DoInstall(CommandLine &CmdL) { CacheFile Cache; - // first check for local pkgs and add them to the cache - for (const char **I = CmdL.FileList; *I != 0; I++) - { - if(FileExists(*I) && flExtension(*I) == "deb") - Cache.GetSourceList()->AddVolatileFile(new debDebPkgFileIndex(*I)); - } + std::vector VolatileCmdL; + Cache.GetSourceList()->AddVolatileFiles(CmdL, &VolatileCmdL); // then open the cache if (Cache.OpenForInstall() == false || Cache.CheckDeps(CmdL.FileSize() != 1) == false) return false; - - std::map verset; - - for (const char **I = CmdL.FileList; *I != 0; I++) { - // Check for local pkgs like in the loop above. - if(!FileExists(*I) || flExtension(*I) != "deb") - continue; - - pkgCache::PkgIterator pkg = Cache->FindPkg(*I); - // Set any version providing the .deb as the candidate. - for (auto Prv = pkg.ProvidesList(); Prv.end() == false; Prv++) - Cache.GetDepCache()->SetCandidateVersion(Prv.OwnerVer()); - } - - if(!DoCacheManipulationFromCommandLine(CmdL, Cache, verset, 0)) + std::map verset; + if(!DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, verset, 0)) return false; /* Print out a list of packages that are going to be installed extra