summaryrefslogtreecommitdiff
path: root/apt-private/private-search.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2018-04-15 19:39:31 +0000
committerJulian Andres Klode <jak@debian.org>2018-04-15 19:39:31 +0000
commit6b766aedf66b4f1394764adb5b5ba6d46ed8a200 (patch)
tree29e0c99ef9b5483a582a936e09dfdb82c078bcb0 /apt-private/private-search.cc
parent1cbb4c95f3fdd0872a7f1cb0f970f50a68c13959 (diff)
parente9796b9c21ee7d8e8f5d6e2a24db43fc4368b557 (diff)
Merge branch 'pu/heavy-hooks' into 'master'
json-based hooks for apt cli tools See merge request apt-team/apt!10
Diffstat (limited to 'apt-private/private-search.cc')
-rw-r--r--apt-private/private-search.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/apt-private/private-search.cc b/apt-private/private-search.cc
index eac7abd05..52a52e522 100644
--- a/apt-private/private-search.cc
+++ b/apt-private/private-search.cc
@@ -12,7 +12,9 @@
#include <apt-pkg/policy.h>
#include <apt-pkg/progress.h>
+#include <apt-private/private-cachefile.h>
#include <apt-private/private-cacheset.h>
+#include <apt-private/private-json-hooks.h>
#include <apt-private/private-output.h>
#include <apt-private/private-search.h>
#include <apt-private/private-show.h>
@@ -29,7 +31,9 @@
static bool FullTextSearch(CommandLine &CmdL) /*{{{*/
{
- pkgCacheFile CacheFile;
+
+ CacheFile CacheFile;
+ CacheFile.GetDepCache();
pkgCache *Cache = CacheFile.GetPkgCache();
pkgDepCache::Policy *Plcy = CacheFile.GetPolicy();
if (unlikely(Cache == NULL || Plcy == NULL))
@@ -40,6 +44,8 @@ static bool FullTextSearch(CommandLine &CmdL) /*{{{*/
if (NumPatterns < 1)
return _error->Error(_("You must give at least one search pattern"));
+ RunJsonHook("AptCli::Hooks::Search", "org.debian.apt.hooks.search.pre", CmdL.FileList, CacheFile);
+
#define APT_FREE_PATTERNS() for (std::vector<regex_t>::iterator P = Patterns.begin(); \
P != Patterns.end(); ++P) { regfree(&(*P)); }
@@ -127,6 +133,10 @@ static bool FullTextSearch(CommandLine &CmdL) /*{{{*/
for (K = output_map.begin(); K != output_map.end(); ++K)
std::cout << (*K).second << std::endl;
+ if (output_map.empty())
+ RunJsonHook("AptCli::Hooks::Search", "org.debian.apt.hooks.search.fail", CmdL.FileList, CacheFile);
+ else
+ RunJsonHook("AptCli::Hooks::Search", "org.debian.apt.hooks.search.post", CmdL.FileList, CacheFile);
return true;
}
/*}}}*/