summaryrefslogtreecommitdiff
path: root/apt-private/private-search.cc
diff options
context:
space:
mode:
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;
}
/*}}}*/