diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2021-04-22 12:53:54 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2021-04-23 12:26:46 +0200 |
commit | de86a4b076a37db2f70ee5fbfbb295cc71c344df (patch) | |
tree | fad919bc724a8f842ba0110f7f109e82ad61c253 /apt-private | |
parent | 4b5215e8e2e31637cb0998ecb80d3c3146760579 (diff) |
upgrade: Add JSON hook support (AptCli::Hooks::Upgrade)
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/private-upgrade.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/apt-private/private-upgrade.cc b/apt-private/private-upgrade.cc index aeaf5066b..a87ffbc46 100644 --- a/apt-private/private-upgrade.cc +++ b/apt-private/private-upgrade.cc @@ -1,12 +1,14 @@ // Includes /*{{{*/ #include <config.h> +#include <apt-pkg/cmndline.h> #include <apt-pkg/configuration.h> #include <apt-pkg/error.h> #include <apt-pkg/upgrade.h> #include <apt-private/private-cachefile.h> #include <apt-private/private-install.h> +#include <apt-private/private-json-hooks.h> #include <apt-private/private-output.h> #include <apt-private/private-upgrade.h> @@ -24,10 +26,18 @@ static bool UpgradeHelper(CommandLine &CmdL, int UpgradeFlags) if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) return false; - if(!DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, UpgradeFlags)) + std::map<unsigned short, APT::VersionSet> verset; + std::set<std::string> UnknownPackages; + if (!DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, verset, UpgradeFlags, UnknownPackages)) + { + RunJsonHook("AptCli::Hooks::Upgrade", "org.debian.apt.hooks.install.fail", CmdL.FileList, Cache, UnknownPackages); return false; - - return InstallPackages(Cache,true); + } + RunJsonHook("AptCli::Hooks::Upgrade", "org.debian.apt.hooks.install.pre-prompt", CmdL.FileList, Cache); + if (InstallPackages(Cache, true)) + return RunJsonHook("AptCli::Hooks::Upgrade", "org.debian.apt.hooks.install.post", CmdL.FileList, Cache); + else + return RunJsonHook("AptCli::Hooks::Upgrade", "org.debian.apt.hooks.install.fail", CmdL.FileList, Cache); } // DoDistUpgrade - Automatic smart upgrader /*{{{*/ |