diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2023-04-11 16:37:51 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2023-05-02 15:16:54 +0200 |
commit | 3625351722e67903dc34993fe318e50863bd2d31 (patch) | |
tree | aea4848210f93530c23fae4c238d483f83acd108 /apt-private | |
parent | aa8c9aad81b57da96e8ac7345d0024ee526c7714 (diff) |
Add apt install,upgrade,... -U,--update options
This runs update before opening the cache and sources.list for
installing/upgrading.
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/private-cmndline.cc | 4 | ||||
-rw-r--r-- | apt-private/private-install.cc | 5 | ||||
-rw-r--r-- | apt-private/private-update.cc | 4 | ||||
-rw-r--r-- | apt-private/private-update.h | 1 | ||||
-rw-r--r-- | apt-private/private-upgrade.cc | 4 |
5 files changed, 17 insertions, 1 deletions
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index f607c4ccc..765378ea2 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -189,13 +189,15 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const addArg(0, "reinstall", "APT::Get::ReInstall", 0); addArg(0, "solver", "APT::Solver", CommandLine::HasArg); addArg(0, "planner", "APT::Planner", CommandLine::HasArg); + addArg('U', "update", "APT::Update", 0); if (CmdMatches("upgrade")) { addArg(0, "new-pkgs", "APT::Get::Upgrade-Allow-New", CommandLine::Boolean); } } - else if (CmdMatches("update")) + + else if (CmdMatches("update") || CmdMatches("install")) { addArg(0, "list-cleanup", "APT::Get::List-Cleanup", 0); addArg(0, "allow-insecure-repositories", "Acquire::AllowInsecureRepositories", 0); diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 08d58a53c..13ed35e2a 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -36,6 +36,7 @@ #include <apt-private/private-install.h> #include <apt-private/private-json-hooks.h> #include <apt-private/private-output.h> +#include <apt-private/private-update.h> #include <apti18n.h> /*}}}*/ @@ -852,6 +853,10 @@ struct PkgIsExtraInstalled { bool DoInstall(CommandLine &CmdL) { CacheFile Cache; + + if (_config->FindB("APT::Update") && not DoUpdate()) + return false; + Cache.InhibitActionGroups(true); if (Cache.BuildSourceList() == false) return false; diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc index f1734fea2..d6f7d62dd 100644 --- a/apt-private/private-update.cc +++ b/apt-private/private-update.cc @@ -51,7 +51,11 @@ bool DoUpdate(CommandLine &CmdL) { if (CmdL.FileSize() != 1) return _error->Error(_("The update command takes no arguments")); + return DoUpdate(); +} +bool DoUpdate() +{ CacheFile Cache; // Get the source list diff --git a/apt-private/private-update.h b/apt-private/private-update.h index e584f70cf..8ca706c55 100644 --- a/apt-private/private-update.h +++ b/apt-private/private-update.h @@ -6,5 +6,6 @@ class CommandLine; APT_PUBLIC bool DoUpdate(CommandLine &CmdL); +APT_PUBLIC bool DoUpdate(); #endif diff --git a/apt-private/private-upgrade.cc b/apt-private/private-upgrade.cc index 97603dc16..143879fe6 100644 --- a/apt-private/private-upgrade.cc +++ b/apt-private/private-upgrade.cc @@ -11,6 +11,7 @@ #include <apt-private/private-install.h> #include <apt-private/private-json-hooks.h> #include <apt-private/private-output.h> +#include <apt-private/private-update.h> #include <apt-private/private-upgrade.h> #include <iostream> @@ -21,6 +22,9 @@ // this is actually performing the various upgrade operations static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags) { + if (_config->FindB("APT::Update") && not DoUpdate()) + return false; + CacheFile Cache; auto VolatileCmdL = GetPseudoPackages(Cache.GetSourceList(), CmdL, AddVolatileBinaryFile, ""); |