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 std::vector
<char const *> VolatileCmdL
;
23 Cache
.GetSourceList()->AddVolatileFiles(CmdL
, &VolatileCmdL
);
25 if (Cache
.OpenForInstall() == false || Cache
.CheckDeps() == false)
28 if(!DoCacheManipulationFromCommandLine(CmdL
, VolatileCmdL
, Cache
, UpgradeFlags
))
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
, APT::Upgrade::ALLOW_EVERYTHING
);
42 bool DoUpgrade(CommandLine
&CmdL
) /*{{{*/
44 if (_config
->FindB("APT::Get::Upgrade-Allow-New", false) == true)
45 return DoUpgradeWithAllowNewPackages(CmdL
);
47 return DoUpgradeNoNewPackages(CmdL
);
50 // DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
51 // ---------------------------------------------------------------------
52 /* Upgrade all packages without installing new packages or erasing old
54 bool DoUpgradeNoNewPackages(CommandLine
&CmdL
)
57 return UpgradeHelper(CmdL
,
58 APT::Upgrade::FORBID_REMOVE_PACKAGES
|
59 APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES
);
62 // DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
63 bool DoUpgradeWithAllowNewPackages(CommandLine
&CmdL
)
65 return UpgradeHelper(CmdL
, APT::Upgrade::FORBID_REMOVE_PACKAGES
);