release 1.0.4
[ntk/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;
22 if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
23 return false;
24
7cf45682 25 c0out << _("Calculating upgrade... ") << std::flush;
5ca0cf51 26 if (APT::Upgrade::Upgrade(Cache, UpgradeFlags) == false)
b9179170 27 {
5ca0cf51 28 c0out << _("Failed") << std::endl;
b9179170 29 ShowBroken(c1out,Cache,false);
5ca0cf51 30 return _error->Error(_("Internal error, Upgrade broke stuff"));
b9179170 31 }
7cf45682 32 c0out << _("Done") << std::endl;
d8a8f9d7
MV
33
34 // parse additional cmdline pkg manipulation switches
35 if(!DoCacheManipulationFromCommandLine(CmdL, Cache))
36 return false;
b9179170
MV
37
38 return InstallPackages(Cache,true);
39}
5ca0cf51
MV
40
41// DoDistUpgrade - Automatic smart upgrader /*{{{*/
42// ---------------------------------------------------------------------
43/* Intelligent upgrader that will install and remove packages at will */
44bool DoDistUpgrade(CommandLine &CmdL)
45{
46 return UpgradeHelper(CmdL, 0);
47}
48 /*}}}*/
59e81cec
MV
49bool DoUpgrade(CommandLine &CmdL) /*{{{*/
50{
51 if (_config->FindB("APT::Get::Upgrade-Allow-New", false) == true)
52 return DoUpgradeWithAllowNewPackages(CmdL);
53 else
54 return DoUpgradeNoNewPackages(CmdL);
55}
56 /*}}}*/
5ca0cf51
MV
57// DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
58// ---------------------------------------------------------------------
59/* Upgrade all packages without installing new packages or erasing old
60 packages */
61bool DoUpgradeNoNewPackages(CommandLine &CmdL)
62{
63 // Do the upgrade
64 return UpgradeHelper(CmdL,
65 APT::Upgrade::FORBID_REMOVE_PACKAGES|
3f506f68 66 APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES);
5ca0cf51 67}
b9179170 68 /*}}}*/
b9179170
MV
69// DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
70bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL)
71{
5ca0cf51 72 return UpgradeHelper(CmdL, APT::Upgrade::FORBID_REMOVE_PACKAGES);
b9179170
MV
73}
74 /*}}}*/