]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-get.cc
depend on debhelper 7 to raise compat level
[apt.git] / cmdline / apt-get.cc
index 57065c528960fbee7bd8f4c9425625c38a7fe194..0a22fd42baa05d7acd3aae50237cb8930c50011a 100644 (file)
@@ -628,6 +628,8 @@ class CacheSetHelperAPTGet : public APT::CacheSetHelper {
        APT::PackageSet virtualPkgs;
 
 public:
+       std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease;
+
        CacheSetHelperAPTGet(std::ostream &out) : APT::CacheSetHelper(true), out(out) {
                explicitlyNamed = true;
        }
@@ -646,9 +648,9 @@ public:
        }
        virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver,
                                 string const &ver, bool const &verIsRel) {
-               if (ver != Ver.VerStr())
-                       ioprintf(out, _("Selected version '%s' (%s) for '%s'\n"),
-                                Ver.VerStr(), Ver.RelStr().c_str(), Pkg.FullName(true).c_str());
+               if (ver == Ver.VerStr())
+                       return;
+               selectedByRelease.push_back(make_pair(Ver, ver));
        }
 
        bool showVirtualPackageErrors(pkgCacheFile &Cache) {
@@ -829,6 +831,37 @@ struct TryToInstall {
       }
    }
 
+   bool propergateReleaseCandiateSwitching(std::list<std::pair<pkgCache::VerIterator, std::string> > start, std::ostream &out)
+   {
+      for (std::list<std::pair<pkgCache::VerIterator, std::string> >::const_iterator s = start.begin();
+               s != start.end(); ++s)
+        Cache->GetDepCache()->SetCandidateVersion(s->first);
+
+      bool Success = true;
+      std::list<std::pair<pkgCache::VerIterator, pkgCache::VerIterator> > Changed;
+      for (std::list<std::pair<pkgCache::VerIterator, std::string> >::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<std::pair<pkgCache::VerIterator, pkgCache::VerIterator> >::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 doAutoInstall() {
       for (APT::PackageSet::const_iterator P = doAutoInstallLater.begin();
           P != doAutoInstallLater.end(); ++P) {
@@ -1618,9 +1651,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
 
    bool purgePkgs = _config->FindB("APT::Get::Purge", false);
    bool smallList = (hideAutoRemove == false &&
-               strcasecmp(_config->Find("APT::Get::HideAutoRemove","").c_str(),"small") == 0) ||
-       // we don't want to autoremove and we don't want to see it, so don't generate lists
-       (doAutoRemove == false && hideAutoRemove == true);
+               strcasecmp(_config->Find("APT::Get::HideAutoRemove","").c_str(),"small") == 0);
 
    string autoremovelist, autoremoveversions;
    unsigned long autoRemoveCount = 0;
@@ -1648,7 +1679,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
            if (Cache[Pkg].Install() == true && Pkg.CurrentVer() == 0)
               Cache->MarkDelete(Pkg, false);
            // only show stuff in the list that is not yet marked for removal
-           else if(Cache[Pkg].Delete() == false) 
+           else if(hideAutoRemove == false && Cache[Pkg].Delete() == false) 
            {
               ++autoRemoveCount;
               // we don't need to fill the strings if we don't need them
@@ -1779,6 +1810,7 @@ bool DoInstall(CommandLine &CmdL)
       {
         if (order[i] == MOD_INSTALL) {
            InstallAction = std::for_each(verset[MOD_INSTALL].begin(), verset[MOD_INSTALL].end(), InstallAction);
+           InstallAction.propergateReleaseCandiateSwitching(helper.selectedByRelease, c0out);
            InstallAction.doAutoInstall();
         }
         else if (order[i] == MOD_REMOVE)
@@ -1843,16 +1875,15 @@ bool DoInstall(CommandLine &CmdL)
         pkgCache::PkgIterator I(Cache,Cache.List[J]);
         if ((*Cache)[I].Install() == false)
            continue;
+        pkgCache::VerIterator Cand = Cache[I].CandidateVerIter(Cache);
+        if (Cand.Pseudo() == true)
+           continue;
 
-        const char **J;
-        for (J = CmdL.FileList + 1; *J != 0; J++)
-           if (strcmp(*J,I.Name()) == 0)
-               break;
-        
-        if (*J == 0) {
-           List += I.FullName(true) + " ";
-           VersionsList += string(Cache[I].CandVersion) + "\n";
-        }
+        if (verset[MOD_INSTALL].find(Cand) != verset[MOD_INSTALL].end())
+           continue;
+
+        List += I.FullName(true) + " ";
+        VersionsList += string(Cache[I].CandVersion) + "\n";
       }
       
       ShowList(c1out,_("The following extra packages will be installed:"),List,VersionsList);