summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/private-cmndline.cc5
-rw-r--r--apt-private/private-list.cc4
-rw-r--r--apt-private/private-search.cc121
-rw-r--r--apt-private/private-show.cc5
-rw-r--r--apt-private/private-source.cc2
-rw-r--r--apt-private/private-update.cc1
6 files changed, 105 insertions, 33 deletions
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 5944e530d..c5edae5d0 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -59,7 +59,7 @@ static bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char cons
addArg('n', "names-only", "APT::Cache::NamesOnly", 0);
addArg('f', "full", "APT::Cache::ShowFull", 0);
}
- else if (CmdMatches("show"))
+ else if (CmdMatches("show") | CmdMatches("info"))
{
addArg('a', "all-versions", "APT::Cache::AllVersions", 0);
}
@@ -344,7 +344,7 @@ static bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * c
addArg('v', "verbose", "APT::Cmd::List-Include-Summary", 0);
addArg('a', "all-versions", "APT::Cmd::All-Versions", 0);
}
- else if (CmdMatches("show"))
+ else if (CmdMatches("show") || CmdMatches("info"))
{
addArg('a', "all-versions", "APT::Cache::AllVersions", 0);
}
@@ -474,6 +474,7 @@ static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/
_config->CndSet("Binary::apt::DPkg::Progress-Fancy", true);
_config->CndSet("Binary::apt::APT::Keep-Downloaded-Packages", false);
_config->CndSet("Binary::apt::APT::Get::Update::InteractiveReleaseInfoChanges", true);
+ _config->CndSet("Binary::apt::APT::Cmd::Pattern-Only", true);
}
_config->Set("Binary", binary);
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index 6071129a7..f5c31bbcd 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -48,8 +48,8 @@ class PackageNameMatcher : public Matcher
{
std::string pattern = patterns[i];
APT::CacheFilter::Matcher *cachefilter = NULL;
- if (pattern.size() > 0 && pattern[0] == '?')
- cachefilter = APT::CacheFilter::ParsePattern(pattern, &cacheFile).release();
+ if (pattern.size() > 0 && (pattern[0] == '?' || pattern[0] == '~'))
+ cachefilter = APT::CacheFilter::ParsePattern(pattern, &cacheFile).release();
else if(_config->FindB("APT::Cmd::Use-Regexp", false) == true)
cachefilter = new APT::CacheFilter::PackageNameMatchesRegEx(pattern);
else
diff --git a/apt-private/private-search.cc b/apt-private/private-search.cc
index de1b19758..b3f9469ac 100644
--- a/apt-private/private-search.cc
+++ b/apt-private/private-search.cc
@@ -1,6 +1,7 @@
// Includes /*{{{*/
#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/cmndline.h>
@@ -24,11 +25,30 @@
#include <sstream>
#include <string>
#include <utility>
+#include <vector>
#include <string.h>
#include <apti18n.h>
/*}}}*/
+static std::vector<pkgCache::DescIterator> const TranslatedDescriptionsList(pkgCache::VerIterator const &V) /*{{{*/
+{
+ std::vector<pkgCache::DescIterator> Descriptions;
+
+ for (std::string const &lang: APT::Configuration::getLanguages())
+ {
+ pkgCache::DescIterator Desc = V.TranslatedDescriptionForLanguage(lang);
+ if (Desc.IsGood())
+ Descriptions.push_back(Desc);
+ }
+
+ if (Descriptions.empty())
+ Descriptions.push_back(V.TranslatedDescription());
+
+ return Descriptions;
+}
+
+ /*}}}*/
static bool FullTextSearch(CommandLine &CmdL) /*{{{*/
{
@@ -94,27 +114,49 @@ static bool FullTextSearch(CommandLine &CmdL) /*{{{*/
if (PkgsDone[P->ID] == true)
continue;
- char const * const PkgName = P.Name();
- pkgCache::DescIterator Desc = V.TranslatedDescription();
- std::string LongDesc = "";
- if (Desc.end() == false)
+ std::vector<std::string> PkgDescriptions;
+ if (not NamesOnly)
{
- pkgRecords::Parser &parser = records.Lookup(Desc.FileList());
- LongDesc = parser.LongDesc();
+ for (auto &Desc: TranslatedDescriptionsList(V))
+ {
+ pkgRecords::Parser &parser = records.Lookup(Desc.FileList());
+ PkgDescriptions.push_back(parser.LongDesc());
+ }
}
bool all_found = true;
+
+ char const * const PkgName = P.Name();
+ std::vector<bool> SkipDescription(PkgDescriptions.size(), false);
for (std::vector<regex_t>::const_iterator pattern = Patterns.begin();
- pattern != Patterns.end(); ++pattern)
+ pattern != Patterns.end(); ++pattern)
{
- if (regexec(&(*pattern), PkgName, 0, 0, 0) == 0)
- continue;
- else if (NamesOnly == false && regexec(&(*pattern), LongDesc.c_str(), 0, 0, 0) == 0)
- continue;
- // search patterns are AND, so one failing fails all
- all_found = false;
- break;
+ if (regexec(&(*pattern), PkgName, 0, 0, 0) == 0)
+ continue;
+ else if (not NamesOnly)
+ {
+ bool found = false;
+
+ for (std::vector<std::string>::size_type i = 0; i < PkgDescriptions.size(); ++i)
+ {
+ if (not SkipDescription[i])
+ {
+ if (regexec(&(*pattern), PkgDescriptions[i].c_str(), 0, 0, 0) == 0)
+ found = true;
+ else
+ SkipDescription[i] = true;
+ }
+ }
+
+ if (found)
+ continue;
+ }
+
+ // search patterns are AND, so one failing fails all
+ all_found = false;
+ break;
}
+
if (all_found == true)
{
PkgsDone[P->ID] = true;
@@ -290,19 +332,43 @@ static bool Search(CommandLine &CmdL)
// Iterate over all the version records and check them
for (ExDescFile *J = DFList; J->Df != 0; ++J)
{
- pkgRecords::Parser &P = Recs.Lookup(pkgCache::DescFileIterator(*Cache,J->Df));
size_t const PatternOffset = J->ID * NumPatterns;
-
- if (NamesOnly == false)
+ if (not NamesOnly)
{
- std::string const LongDesc = P.LongDesc();
- for (unsigned I = 0; I < NumPatterns; ++I)
- {
- if (PatternMatch[PatternOffset + I] == true)
- continue;
- else if (regexec(&Patterns[I],LongDesc.c_str(),0,0,0) == 0)
- PatternMatch[PatternOffset + I] = true;
- }
+ std::vector<std::string> PkgDescriptions;
+ for (auto &Desc: TranslatedDescriptionsList(J->V))
+ {
+ pkgRecords::Parser &parser = Recs.Lookup(Desc.FileList());
+ PkgDescriptions.push_back(parser.LongDesc());
+ }
+
+ std::vector<bool> SkipDescription(PkgDescriptions.size(), false);
+ for (unsigned I = 0; I < NumPatterns; ++I)
+ {
+ if (PatternMatch[PatternOffset + I])
+ continue;
+ else
+ {
+ bool found = false;
+
+ for (std::vector<std::string>::size_type k = 0; k < PkgDescriptions.size(); ++k)
+ {
+ if (not SkipDescription[k])
+ {
+ if (regexec(&Patterns[I], PkgDescriptions[k].c_str(), 0, 0, 0) == 0)
+ {
+ found = true;
+ PatternMatch[PatternOffset + I] = true;
+ }
+ else
+ SkipDescription[k] = true;
+ }
+ }
+
+ if (not found)
+ break;
+ }
+ }
}
bool matchedAll = true;
@@ -325,7 +391,10 @@ static bool Search(CommandLine &CmdL)
DisplayRecordV1(CacheFile, Recs, J->V, Vf, Start, Length, std::cout);
}
else
- printf("%s - %s\n",P.Name().c_str(),P.ShortDesc().c_str());
+ {
+ pkgRecords::Parser &P = Recs.Lookup(pkgCache::DescFileIterator(*Cache, J->Df));
+ printf("%s - %s\n", P.Name().c_str(), P.ShortDesc().c_str());
+ }
}
}
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index 9ebbe6ac0..103fa57e4 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -8,6 +8,7 @@
#include <apt-pkg/depcache.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/hashes.h>
#include <apt-pkg/indexfile.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/pkgcache.h>
@@ -415,9 +416,9 @@ bool ShowPackage(CommandLine &CmdL) /*{{{*/
static std::string Sha1FromString(std::string const &input) /*{{{*/
{
// XXX: move to hashes.h: HashString::FromString() ?
- SHA1Summation sha1;
+ Hashes sha1(Hashes::SHA1SUM);
sha1.Add(input.c_str(), input.length());
- return sha1.Result().Value();
+ return sha1.GetHashString(Hashes::SHA1SUM).HashValue();
}
/*}}}*/
bool ShowSrcPackage(CommandLine &CmdL) /*{{{*/
diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc
index 3964ca48e..9b47ce31f 100644
--- a/apt-private/private-source.cc
+++ b/apt-private/private-source.cc
@@ -693,7 +693,7 @@ bool DoBuildDep(CommandLine &CmdL)
// Reject '>' and '<' as operators, as they have strange meanings.
bool insideVersionRestriction = false;
- for (auto C = Start; C + 1 != Stop; C++)
+ for (auto C = Start; C + 1 < Stop; C++)
{
if (*C == '(')
insideVersionRestriction = true;
diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc
index 59d1d6d3f..248f1f36e 100644
--- a/apt-private/private-update.cc
+++ b/apt-private/private-update.cc
@@ -10,6 +10,7 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/metaindex.h>
#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/update.h>
#include <apt-private/acqprogress.h>