3 #include <apt-pkg/algorithms.h>
4 #include <apt-pkg/upgrade.h>
6 #include "private-install.h"
7 #include "private-cachefile.h"
8 #include "private-upgrade.h"
9 #include "private-output.h"
12 // this is actually performing the various upgrade operations
13 static bool UpgradeHelper(CommandLine
&CmdL
, int UpgradeFlags
)
16 if (Cache
.OpenForInstall() == false || Cache
.CheckDeps() == false)
19 c0out
<< _("Calculating upgrade... ") << std::flush
;
20 if (APT::Upgrade::Upgrade(Cache
, UpgradeFlags
) == false)
22 c0out
<< _("Failed") << std::endl
;
23 ShowBroken(c1out
,Cache
,false);
24 return _error
->Error(_("Internal error, Upgrade broke stuff"));
26 c0out
<< _("Done") << std::endl
;
28 // parse additional cmdline pkg manipulation switches
29 if(!DoCacheManipulationFromCommandLine(CmdL
, Cache
))
32 return InstallPackages(Cache
,true);
35 // DoDistUpgrade - Automatic smart upgrader /*{{{*/
36 // ---------------------------------------------------------------------
37 /* Intelligent upgrader that will install and remove packages at will */
38 bool DoDistUpgrade(CommandLine
&CmdL
)
40 return UpgradeHelper(CmdL
, 0);
43 bool DoUpgrade(CommandLine
&CmdL
) /*{{{*/
45 if (_config
->FindB("APT::Get::Upgrade-Allow-New", false) == true)
46 return DoUpgradeWithAllowNewPackages(CmdL
);
48 return DoUpgradeNoNewPackages(CmdL
);
51 // DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
52 // ---------------------------------------------------------------------
53 /* Upgrade all packages without installing new packages or erasing old
55 bool DoUpgradeNoNewPackages(CommandLine
&CmdL
)
58 return UpgradeHelper(CmdL
,
59 APT::Upgrade::FORBID_REMOVE_PACKAGES
|
60 APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES
);
63 // DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
64 bool DoUpgradeWithAllowNewPackages(CommandLine
&CmdL
)
66 return UpgradeHelper(CmdL
, APT::Upgrade::FORBID_REMOVE_PACKAGES
);