Commit | Line | Data |
---|---|---|
ee0167c4 | 1 | // Includes /*{{{*/ |
b9179170 | 2 | #include <apt-pkg/algorithms.h> |
5ca0cf51 | 3 | #include <iostream> |
b9179170 MV |
4 | #include "private-install.h" |
5 | #include "private-cachefile.h" | |
6 | #include "private-upgrade.h" | |
7 | #include "private-output.h" | |
ee0167c4 | 8 | /*}}}*/ |
b9179170 | 9 | |
5ca0cf51 MV |
10 | // this is actually performing the various upgrade operations |
11 | static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags) | |
b9179170 MV |
12 | { |
13 | CacheFile Cache; | |
14 | if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) | |
15 | return false; | |
16 | ||
5ca0cf51 MV |
17 | //c0out << _("Calculating upgrade... ") << std::flush; |
18 | if (APT::Upgrade::Upgrade(Cache, UpgradeFlags) == false) | |
b9179170 | 19 | { |
5ca0cf51 | 20 | c0out << _("Failed") << std::endl; |
b9179170 | 21 | ShowBroken(c1out,Cache,false); |
5ca0cf51 | 22 | return _error->Error(_("Internal error, Upgrade broke stuff")); |
b9179170 | 23 | } |
d8a8f9d7 MV |
24 | |
25 | // parse additional cmdline pkg manipulation switches | |
26 | if(!DoCacheManipulationFromCommandLine(CmdL, Cache)) | |
27 | return false; | |
5ca0cf51 MV |
28 | |
29 | //c0out << _("Done") << std::endl; | |
b9179170 MV |
30 | |
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 */ | |
37 | bool DoDistUpgrade(CommandLine &CmdL) | |
38 | { | |
39 | return UpgradeHelper(CmdL, 0); | |
40 | } | |
41 | /*}}}*/ | |
42 | // DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/ | |
43 | // --------------------------------------------------------------------- | |
44 | /* Upgrade all packages without installing new packages or erasing old | |
45 | packages */ | |
46 | bool DoUpgradeNoNewPackages(CommandLine &CmdL) | |
47 | { | |
48 | // Do the upgrade | |
49 | return UpgradeHelper(CmdL, | |
50 | APT::Upgrade::FORBID_REMOVE_PACKAGES| | |
51 | APT::Upgrade::FORBID_NEW_INSTALL_PACKAGES); | |
52 | } | |
b9179170 | 53 | /*}}}*/ |
b9179170 MV |
54 | // DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/ |
55 | bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL) | |
56 | { | |
5ca0cf51 | 57 | return UpgradeHelper(CmdL, APT::Upgrade::FORBID_REMOVE_PACKAGES); |
b9179170 MV |
58 | } |
59 | /*}}}*/ |