4 #include <apt-pkg/upgrade.h>
5 #include <apt-pkg/configuration.h>
6 #include <apt-pkg/error.h>
8 #include <apt-private/private-install.h>
9 #include <apt-private/private-cachefile.h>
10 #include <apt-private/private-upgrade.h>
11 #include <apt-private/private-output.h>
18 // this is actually performing the various upgrade operations
19 static bool UpgradeHelper(CommandLine
&CmdL
, int UpgradeFlags
)
22 if (Cache
.OpenForInstall() == false || Cache
.CheckDeps() == false)
25 c0out
<< _("Calculating upgrade... ") << std::flush
;
26 if (APT::Upgrade::Upgrade(Cache
, UpgradeFlags
) == false)
28 c0out
<< _("Failed") << std::endl
;
29 ShowBroken(c1out
,Cache
,false);
30 return _error
->Error(_("Internal error, Upgrade broke stuff"));
32 c0out
<< _("Done") << std::endl
;
34 // parse additional cmdline pkg manipulation switches
35 if(!DoCacheManipulationFromCommandLine(CmdL
, Cache
))
38 return InstallPackages(Cache
,true);
41 // DoDistUpgrade - Automatic smart upgrader /*{{{*/
42 // ---------------------------------------------------------------------
43 /* Intelligent upgrader that will install and remove packages at will */
44 bool DoDistUpgrade(CommandLine
&CmdL
)
46 return UpgradeHelper(CmdL
, 0);
49 bool DoUpgrade(CommandLine
&CmdL
) /*{{{*/
51 if (_config
->FindB("APT::Get::Upgrade-Allow-New", false) == true)
52 return DoUpgradeWithAllowNewPackages(CmdL
);
54 return DoUpgradeNoNewPackages(CmdL
);
57 // DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
58 // ---------------------------------------------------------------------
59 /* Upgrade all packages without installing new packages or erasing old
61 bool DoUpgradeNoNewPackages(CommandLine
&CmdL
)
64 return UpgradeHelper(CmdL
,
65 APT::Upgrade::FORBID_REMOVE_PACKAGES
|
66 APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES
);
69 // DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
70 bool DoUpgradeWithAllowNewPackages(CommandLine
&CmdL
)
72 return UpgradeHelper(CmdL
, APT::Upgrade::FORBID_REMOVE_PACKAGES
);