]>
Commit | Line | Data |
---|---|---|
59e81cec | 1 | |
ee0167c4 | 2 | // Includes /*{{{*/ |
b9179170 | 3 | #include <apt-pkg/algorithms.h> |
82e369c4 | 4 | #include <apt-pkg/upgrade.h> |
5ca0cf51 | 5 | #include <iostream> |
b9179170 MV |
6 | #include "private-install.h" |
7 | #include "private-cachefile.h" | |
8 | #include "private-upgrade.h" | |
9 | #include "private-output.h" | |
ee0167c4 | 10 | /*}}}*/ |
b9179170 | 11 | |
5ca0cf51 MV |
12 | // this is actually performing the various upgrade operations |
13 | static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags) | |
b9179170 MV |
14 | { |
15 | CacheFile Cache; | |
16 | if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) | |
17 | return false; | |
18 | ||
7cf45682 | 19 | c0out << _("Calculating upgrade... ") << std::flush; |
5ca0cf51 | 20 | if (APT::Upgrade::Upgrade(Cache, UpgradeFlags) == false) |
b9179170 | 21 | { |
5ca0cf51 | 22 | c0out << _("Failed") << std::endl; |
b9179170 | 23 | ShowBroken(c1out,Cache,false); |
5ca0cf51 | 24 | return _error->Error(_("Internal error, Upgrade broke stuff")); |
b9179170 | 25 | } |
7cf45682 | 26 | c0out << _("Done") << std::endl; |
d8a8f9d7 MV |
27 | |
28 | // parse additional cmdline pkg manipulation switches | |
29 | if(!DoCacheManipulationFromCommandLine(CmdL, Cache)) | |
30 | return false; | |
b9179170 MV |
31 | |
32 | return InstallPackages(Cache,true); | |
33 | } | |
5ca0cf51 MV |
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 | /*}}}*/ | |
59e81cec MV |
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 | /*}}}*/ | |
5ca0cf51 MV |
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| | |
3f506f68 | 60 | APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES); |
5ca0cf51 | 61 | } |
b9179170 | 62 | /*}}}*/ |
b9179170 MV |
63 | // DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/ |
64 | bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL) | |
65 | { | |
5ca0cf51 | 66 | return UpgradeHelper(CmdL, APT::Upgrade::FORBID_REMOVE_PACKAGES); |
b9179170 MV |
67 | } |
68 | /*}}}*/ |