2 #include <apt-pkg/algorithms.h>
3 #include <apt-pkg/upgrade.h>
5 #include "private-install.h"
6 #include "private-cachefile.h"
7 #include "private-upgrade.h"
8 #include "private-output.h"
11 // this is actually performing the various upgrade operations
12 static bool UpgradeHelper(CommandLine
&CmdL
, int UpgradeFlags
)
15 if (Cache
.OpenForInstall() == false || Cache
.CheckDeps() == false)
18 c0out
<< _("Calculating upgrade... ") << std::flush
;
19 if (APT::Upgrade::Upgrade(Cache
, UpgradeFlags
) == false)
21 c0out
<< _("Failed") << std::endl
;
22 ShowBroken(c1out
,Cache
,false);
23 return _error
->Error(_("Internal error, Upgrade broke stuff"));
25 c0out
<< _("Done") << std::endl
;
27 // parse additional cmdline pkg manipulation switches
28 if(!DoCacheManipulationFromCommandLine(CmdL
, Cache
))
31 return InstallPackages(Cache
,true);
34 // DoDistUpgrade - Automatic smart upgrader /*{{{*/
35 // ---------------------------------------------------------------------
36 /* Intelligent upgrader that will install and remove packages at will */
37 bool DoDistUpgrade(CommandLine
&CmdL
)
39 return UpgradeHelper(CmdL
, 0);
42 // DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
43 // ---------------------------------------------------------------------
44 /* Upgrade all packages without installing new packages or erasing old
46 bool DoUpgradeNoNewPackages(CommandLine
&CmdL
)
49 return UpgradeHelper(CmdL
,
50 APT::Upgrade::FORBID_REMOVE_PACKAGES
|
51 APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES
);
54 // DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
55 bool DoUpgradeWithAllowNewPackages(CommandLine
&CmdL
)
57 return UpgradeHelper(CmdL
, APT::Upgrade::FORBID_REMOVE_PACKAGES
);