]> git.saurik.com Git - apt.git/blob - apt-private/private-upgrade.cc
Merge remote-tracking branch 'donkult/debian/sid' into debian/sid
[apt.git] / apt-private / private-upgrade.cc
1
2 // Includes /*{{{*/
3 #include <apt-pkg/algorithms.h>
4 #include <apt-pkg/upgrade.h>
5 #include <iostream>
6 #include "private-install.h"
7 #include "private-cachefile.h"
8 #include "private-upgrade.h"
9 #include "private-output.h"
10 /*}}}*/
11
12 // this is actually performing the various upgrade operations
13 static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags)
14 {
15 CacheFile Cache;
16 if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
17 return false;
18
19 c0out << _("Calculating upgrade... ") << std::flush;
20 if (APT::Upgrade::Upgrade(Cache, UpgradeFlags) == false)
21 {
22 c0out << _("Failed") << std::endl;
23 ShowBroken(c1out,Cache,false);
24 return _error->Error(_("Internal error, Upgrade broke stuff"));
25 }
26 c0out << _("Done") << std::endl;
27
28 // parse additional cmdline pkg manipulation switches
29 if(!DoCacheManipulationFromCommandLine(CmdL, Cache))
30 return false;
31
32 return InstallPackages(Cache,true);
33 }
34
35 // DoDistUpgrade - Automatic smart upgrader /*{{{*/
36 // ---------------------------------------------------------------------
37 /* Intelligent upgrader that will install and remove packages at will */
38 bool DoDistUpgrade(CommandLine &CmdL)
39 {
40 return UpgradeHelper(CmdL, 0);
41 }
42 /*}}}*/
43 bool DoUpgrade(CommandLine &CmdL) /*{{{*/
44 {
45 if (_config->FindB("APT::Get::Upgrade-Allow-New", false) == true)
46 return DoUpgradeWithAllowNewPackages(CmdL);
47 else
48 return DoUpgradeNoNewPackages(CmdL);
49 }
50 /*}}}*/
51 // DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
52 // ---------------------------------------------------------------------
53 /* Upgrade all packages without installing new packages or erasing old
54 packages */
55 bool DoUpgradeNoNewPackages(CommandLine &CmdL)
56 {
57 // Do the upgrade
58 return UpgradeHelper(CmdL,
59 APT::Upgrade::FORBID_REMOVE_PACKAGES|
60 APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES);
61 }
62 /*}}}*/
63 // DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
64 bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL)
65 {
66 return UpgradeHelper(CmdL, APT::Upgrade::FORBID_REMOVE_PACKAGES);
67 }
68 /*}}}*/