]> git.saurik.com Git - apt.git/blame - apt-private/private-upgrade.cc
acquire: Use priority queues and a 3 stage pipeline design
[apt.git] / apt-private / private-upgrade.cc
CommitLineData
ee0167c4 1// Includes /*{{{*/
453b82a3
DK
2#include <config.h>
3
82e369c4 4#include <apt-pkg/upgrade.h>
453b82a3
DK
5#include <apt-pkg/configuration.h>
6#include <apt-pkg/error.h>
7
8#include <apt-private/private-install.h>
9#include <apt-private/private-cachefile.h>
10#include <apt-private/private-upgrade.h>
11#include <apt-private/private-output.h>
12
5ca0cf51 13#include <iostream>
453b82a3
DK
14
15#include <apti18n.h>
ee0167c4 16 /*}}}*/
b9179170 17
5ca0cf51
MV
18// this is actually performing the various upgrade operations
19static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags)
b9179170
MV
20{
21 CacheFile Cache;
92296fe4 22 std::vector<std::string> VolatileCmdL;
14341a7e
DK
23 Cache.GetSourceList()->AddVolatileFiles(CmdL, &VolatileCmdL);
24
b9179170
MV
25 if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
26 return false;
27
14341a7e 28 if(!DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, UpgradeFlags))
172947cd 29 return false;
d8a8f9d7 30
b9179170
MV
31 return InstallPackages(Cache,true);
32}
5ca0cf51
MV
33
34// DoDistUpgrade - Automatic smart upgrader /*{{{*/
35// ---------------------------------------------------------------------
36/* Intelligent upgrader that will install and remove packages at will */
37bool DoDistUpgrade(CommandLine &CmdL)
38{
67caa2e6 39 return UpgradeHelper(CmdL, APT::Upgrade::ALLOW_EVERYTHING);
5ca0cf51
MV
40}
41 /*}}}*/
59e81cec
MV
42bool DoUpgrade(CommandLine &CmdL) /*{{{*/
43{
44 if (_config->FindB("APT::Get::Upgrade-Allow-New", false) == true)
45 return DoUpgradeWithAllowNewPackages(CmdL);
46 else
47 return DoUpgradeNoNewPackages(CmdL);
48}
49 /*}}}*/
5ca0cf51
MV
50// DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
51// ---------------------------------------------------------------------
52/* Upgrade all packages without installing new packages or erasing old
53 packages */
54bool DoUpgradeNoNewPackages(CommandLine &CmdL)
55{
56 // Do the upgrade
57 return UpgradeHelper(CmdL,
58 APT::Upgrade::FORBID_REMOVE_PACKAGES|
3f506f68 59 APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES);
5ca0cf51 60}
b9179170 61 /*}}}*/
b9179170
MV
62// DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
63bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL)
64{
5ca0cf51 65 return UpgradeHelper(CmdL, APT::Upgrade::FORBID_REMOVE_PACKAGES);
b9179170
MV
66}
67 /*}}}*/