]> git.saurik.com Git - apt.git/commitdiff
rename FORBID_NEW_INSTALL_PACKAGES to FORBID_INSTALL_NEW_PACKAGES
authorMichael Vogt <mvo@debian.org>
Sat, 5 Oct 2013 10:30:26 +0000 (12:30 +0200)
committerMichael Vogt <mvo@debian.org>
Sat, 5 Oct 2013 10:30:26 +0000 (12:30 +0200)
1  2 
apt-pkg/upgrade.cc
apt-pkg/upgrade.h
apt-private/private-upgrade.cc
cmdline/apt-get.cc

index 84c781c618120d14d798960f5d78ce3d3a2fafa9,0000000000000000000000000000000000000000..f06f6d40d60cb6b76475ffe6fedec9d42a449f7f
mode 100644,000000..100644
--- /dev/null
@@@ -1,263 -1,0 +1,263 @@@
-    else if ((mode & ~(FORBID_REMOVE_PACKAGES|FORBID_NEW_INSTALL_PACKAGES)) == 0)
 +
 +// Include Files                                                      /*{{{*/
 +#include <config.h>
 +
 +#include <apt-pkg/algorithms.h>
 +#include <apt-pkg/upgrade.h>
 +#include <apt-pkg/error.h>
 +#include <apt-pkg/configuration.h>
 +#include <apt-pkg/version.h>
 +#include <apt-pkg/sptr.h>
 +#include <apt-pkg/acquire-item.h>
 +#include <apt-pkg/edsp.h>
 +#include <apt-pkg/sourcelist.h>
 +#include <apt-pkg/fileutl.h>
 +#include <apt-pkg/progress.h>
 +
 +#include <sys/types.h>
 +#include <cstdlib>
 +#include <algorithm>
 +#include <iostream>
 +#include <stdio.h>
 +
 +#include <apti18n.h>
 +                                                                      /*}}}*/
 +
 +// DistUpgrade - Distribution upgrade                                 /*{{{*/
 +// ---------------------------------------------------------------------
 +/* This autoinstalls every package and then force installs every 
 +   pre-existing package. This creates the initial set of conditions which 
 +   most likely contain problems because too many things were installed.
 +   
 +   The problem resolver is used to resolve the problems.
 + */
 +bool pkgDistUpgrade(pkgDepCache &Cache)
 +{
 +   std::string const solver = _config->Find("APT::Solver", "internal");
 +   if (solver != "internal") {
 +      OpTextProgress Prog(*_config);
 +      return EDSP::ResolveExternal(solver.c_str(), Cache, false, true, false, &Prog);
 +   }
 +
 +   pkgDepCache::ActionGroup group(Cache);
 +
 +   /* Upgrade all installed packages first without autoinst to help the resolver
 +      in versioned or-groups to upgrade the old solver instead of installing
 +      a new one (if the old solver is not the first one [anymore]) */
 +   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +      if (I->CurrentVer != 0)
 +       Cache.MarkInstall(I, false, 0, false);
 +
 +   /* Auto upgrade all installed packages, this provides the basis 
 +      for the installation */
 +   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +      if (I->CurrentVer != 0)
 +       Cache.MarkInstall(I, true, 0, false);
 +
 +   /* Now, install each essential package which is not installed
 +      (and not provided by another package in the same name group) */
 +   std::string essential = _config->Find("pkgCacheGen::Essential", "all");
 +   if (essential == "all")
 +   {
 +      for (pkgCache::GrpIterator G = Cache.GrpBegin(); G.end() == false; ++G)
 +      {
 +       bool isEssential = false;
 +       bool instEssential = false;
 +       for (pkgCache::PkgIterator P = G.PackageList(); P.end() == false; P = G.NextPkg(P))
 +       {
 +          if ((P->Flags & pkgCache::Flag::Essential) != pkgCache::Flag::Essential)
 +             continue;
 +          isEssential = true;
 +          if (Cache[P].Install() == true)
 +          {
 +             instEssential = true;
 +             break;
 +          }
 +       }
 +       if (isEssential == false || instEssential == true)
 +          continue;
 +       pkgCache::PkgIterator P = G.FindPreferredPkg();
 +       Cache.MarkInstall(P, true, 0, false);
 +      }
 +   }
 +   else if (essential != "none")
 +      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +       if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
 +          Cache.MarkInstall(I, true, 0, false);
 +   
 +   /* We do it again over all previously installed packages to force 
 +      conflict resolution on them all. */
 +   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +      if (I->CurrentVer != 0)
 +       Cache.MarkInstall(I, false, 0, false);
 +
 +   pkgProblemResolver Fix(&Cache);
 +
 +   // Hold back held packages.
 +   if (_config->FindB("APT::Ignore-Hold",false) == false)
 +   {
 +      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +      {
 +       if (I->SelectedState == pkgCache::State::Hold)
 +       {
 +          Fix.Protect(I);
 +          Cache.MarkKeep(I, false, false);
 +       }
 +      }
 +   }
 +   
 +   return Fix.Resolve();
 +}
 +                                                                      /*}}}*/
 +// AllUpgradeNoNewPackages - Upgrade but no removals or new pkgs        /*{{{*/
 +static bool pkgAllUpgradeNoNewPackages(pkgDepCache &Cache)
 +{
 +   std::string const solver = _config->Find("APT::Solver", "internal");
 +   if (solver != "internal") {
 +      OpTextProgress Prog(*_config);
 +      return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
 +   }
 +
 +   pkgDepCache::ActionGroup group(Cache);
 +
 +   pkgProblemResolver Fix(&Cache);
 +
 +   if (Cache.BrokenCount() != 0)
 +      return false;
 +   
 +   // Upgrade all installed packages
 +   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +   {
 +      if (Cache[I].Install() == true)
 +       Fix.Protect(I);
 +        
 +      if (_config->FindB("APT::Ignore-Hold",false) == false)
 +       if (I->SelectedState == pkgCache::State::Hold)
 +          continue;
 +      
 +      if (I->CurrentVer != 0 && Cache[I].InstallVer != 0)
 +       Cache.MarkInstall(I, false, 0, false);
 +   }
 +      
 +   return Fix.ResolveByKeep();
 +}
 +                                                                      /*}}}*/
 +// AllUpgradeWithNewInstalls - Upgrade + install new packages as needed /*{{{*/
 +// ---------------------------------------------------------------------
 +/* Right now the system must be consistent before this can be called.
 + * Upgrade as much as possible without deleting anything (useful for
 + * stable systems)
 + */
 +static bool pkgAllUpgradeWithNewPackages(pkgDepCache &Cache)
 +{
 +   pkgDepCache::ActionGroup group(Cache);
 +
 +   pkgProblemResolver Fix(&Cache);
 +
 +   if (Cache.BrokenCount() != 0)
 +      return false;
 +
 +   // provide the initial set of stuff we want to upgrade by marking
 +   // all upgradable packages for upgrade
 +   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +   {
 +      if (I->CurrentVer != 0 && Cache[I].InstallVer != 0)
 +      {
 +         if (_config->FindB("APT::Ignore-Hold",false) == false)
 +            if (I->SelectedState == pkgCache::State::Hold)
 +               continue;
 +
 +       Cache.MarkInstall(I, false, 0, false);
 +      }
 +   }
 +
 +   // then let auto-install loose
 +   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +      if (Cache[I].Install())
 +       Cache.MarkInstall(I, true, 0, false);
 +
 +   // ... but it may remove stuff, we we need to clean up afterwards again
 +   for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +      if (Cache[I].Delete() == true)
 +       Cache.MarkKeep(I, false, false);
 +
 +   // resolve remaining issues via keep
 +   return Fix.ResolveByKeep();
 +}
 +                                                                      /*}}}*/
 +// AllUpgrade - Upgrade as many packages as possible                  /*{{{*/
 +// ---------------------------------------------------------------------
 +/* Right now the system must be consistent before this can be called.
 +   It also will not change packages marked for install, it only tries
 +   to install packages not marked for install */
 +bool pkgAllUpgrade(pkgDepCache &Cache)
 +{
 +   return pkgAllUpgradeNoNewPackages(Cache);
 +}
 +                                                                      /*}}}*/
 +// MinimizeUpgrade - Minimizes the set of packages to be upgraded     /*{{{*/
 +// ---------------------------------------------------------------------
 +/* This simply goes over the entire set of packages and tries to keep 
 +   each package marked for upgrade. If a conflict is generated then 
 +   the package is restored. */
 +bool pkgMinimizeUpgrade(pkgDepCache &Cache)
 +{   
 +   pkgDepCache::ActionGroup group(Cache);
 +
 +   if (Cache.BrokenCount() != 0)
 +      return false;
 +   
 +   // We loop for 10 tries to get the minimal set size.
 +   bool Change = false;
 +   unsigned int Count = 0;
 +   do
 +   {
 +      Change = false;
 +      for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
 +      {
 +       // Not interesting
 +       if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true)
 +          continue;
 +
 +       // Keep it and see if that is OK
 +       Cache.MarkKeep(I, false, false);
 +       if (Cache.BrokenCount() != 0)
 +          Cache.MarkInstall(I, false, 0, false);
 +       else
 +       {
 +          // If keep didnt actually do anything then there was no change..
 +          if (Cache[I].Upgrade() == false)
 +             Change = true;
 +       }       
 +      }      
 +      ++Count;
 +   }
 +   while (Change == true && Count < 10);
 +
 +   if (Cache.BrokenCount() != 0)
 +      return _error->Error("Internal Error in pkgMinimizeUpgrade");
 +   
 +   return true;
 +}
 +                                                                      /*}}}*/
 +// APT::Upgrade::Upgrade - Upgrade using a specific strategy          /*{{{*/
 +bool APT::Upgrade::Upgrade(pkgDepCache &Cache, int mode)
 +{
 +   if (mode == 0) 
 +   {
 +      return pkgDistUpgrade(Cache);
 +   }
 +   else if ((mode & ~FORBID_REMOVE_PACKAGES) == 0)
 +   {
 +      return pkgAllUpgradeWithNewPackages(Cache);
 +   } 
++   else if ((mode & ~(FORBID_REMOVE_PACKAGES|FORBID_INSTALL_NEW_PACKAGES)) == 0)
 +   {
 +      return pkgAllUpgradeNoNewPackages(Cache);
 +   }
 +   else
 +      _error->Error("pkgAllUpgrade called with unsupported mode %i", mode);
 +
 +   return false;
 +}
 +                                                                      /*}}}*/
index 9fdfac2fd6f5c00534e2a561c7d7d1afbe130bf6,0000000000000000000000000000000000000000..c4973472f054db15446321461039e5557e3b7270
mode 100644,000000..100644
--- /dev/null
@@@ -1,29 -1,0 +1,30 @@@
-          FORBID_NEW_INSTALL_PACKAGES = 2,
 +// -*- mode: cpp; mode: fold -*-
 +// Description                                                                /*{{{*/
 +/* ######################################################################
 +
 +   Upgrade - Upgrade/DistUpgrade releated code
 +   
 +   ##################################################################### */
 +                                                                      /*}}}*/
 +
 +#ifndef PKGLIB_UPGRADE_H
 +#define PKGLIB_UPGRADE_H
 +
 +namespace APT {
 +   namespace Upgrade {
 +      // FIXME: make this "enum class UpgradeMode {" once we enable c++11
 +      enum UpgradeMode {
 +         FORBID_REMOVE_PACKAGES = 1,
++         FORBID_INSTALL_NEW_PACKAGES = 2,
 +      };
 +      bool Upgrade(pkgDepCache &Cache, int UpgradeMode);
 +   }
 +}
 +
++// please use APT::Upgrade::Upgrade() instead
 +bool pkgDistUpgrade(pkgDepCache &Cache);
 +bool pkgAllUpgrade(pkgDepCache &Cache);
 +bool pkgMinimizeUpgrade(pkgDepCache &Cache);
 +
 +
 +#endif
index 456cbc0faa0eefc8ba213fc4d14606e253c19ab2,9a5286b57fc26e2b88678ed4a3492a7ae09ecbde..e76b5d7fc0efd6e29d255050db3db7108c51aa20
@@@ -30,26 -30,6 +30,26 @@@ static bool UpgradeHelper(CommandLine &
     
     return InstallPackages(Cache,true);
  }
-                         APT::Upgrade::FORBID_NEW_INSTALL_PACKAGES);
 +
 +// DoDistUpgrade - Automatic smart upgrader                           /*{{{*/
 +// ---------------------------------------------------------------------
 +/* Intelligent upgrader that will install and remove packages at will */
 +bool DoDistUpgrade(CommandLine &CmdL)
 +{
 +   return UpgradeHelper(CmdL, 0);
 +}
 +                                                                      /*}}}*/
 +// DoUpgradeNoNewPackages - Upgrade all packages                      /*{{{*/
 +// ---------------------------------------------------------------------
 +/* Upgrade all packages without installing new packages or erasing old
 +   packages */
 +bool DoUpgradeNoNewPackages(CommandLine &CmdL)
 +{
 +   // Do the upgrade
 +   return UpgradeHelper(CmdL, 
 +                        APT::Upgrade::FORBID_REMOVE_PACKAGES|
++                        APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES);
 +}
                                                                        /*}}}*/
  // DoSafeUpgrade - Upgrade all packages with install but not remove   /*{{{*/
  bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL)
index 1025005a22e7d40f7c1ad28e593e120f9914bb3d,630a9489b31c0351fba6b0952400ea9fe49794e4..b150cf5418a1b84326f9268f29c8126822b1abb8
@@@ -49,8 -49,8 +49,9 @@@
  #include <apt-pkg/pkgsystem.h>
  #include <apt-pkg/pkgrecords.h>
  #include <apt-pkg/indexfile.h>
 +#include <apt-pkg/upgrade.h>
  
+ #include <apt-private/private-download.h>
  #include <apt-private/private-install.h>
  #include <apt-private/private-upgrade.h>
  #include <apt-private/private-output.h>