summaryrefslogtreecommitdiff
path: root/apt-private/private-list.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private/private-list.cc')
-rw-r--r--apt-private/private-list.cc71
1 files changed, 34 insertions, 37 deletions
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index be2e07f43..e85aaf64c 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -1,43 +1,28 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/cmndline.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/policy.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/algorithms.h>
-#include <apt-pkg/sptr.h>
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/metaindex.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-list.h>
+#include <apt-private/private-output.h>
+#include <iostream>
#include <sstream>
-#include <vector>
+#include <map>
+#include <string>
#include <utility>
-#include <cassert>
-#include <locale.h>
-#include <iostream>
-#include <unistd.h>
-#include <errno.h>
-#include <regex.h>
-#include <stdio.h>
-#include <algorithm>
-
-#include "private-cmndline.h"
-#include "private-list.h"
-#include "private-output.h"
-#include "private-cacheset.h"
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -52,9 +37,9 @@ struct PackageSortAlphabetic /*{{{*/
return (l_name < r_name);
}
};
-#ifdef PACKAGE_MATCHER_ABI_COMPAT
-#define PackageMatcher PackageNameMatchesFnmatch
-#endif
+
+class PackageNameMatcher : public Matcher
+{
public:
PackageNameMatcher(const char **patterns)
{
@@ -91,7 +76,7 @@ private:
#undef PackageMatcher
};
/*}}}*/
-void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
+static void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records,/*{{{*/
pkgCache::PkgIterator P,
std::ostream &outs,
bool include_summary=true)
@@ -106,14 +91,13 @@ void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
/*}}}*/
// list - list package based on criteria /*{{{*/
// ---------------------------------------------------------------------
-bool List(CommandLine &Cmd)
+bool DoList(CommandLine &Cmd)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
- pkgRecords records(CacheFile);
-
if (unlikely(Cache == NULL))
return false;
+ pkgRecords records(CacheFile);
const char **patterns;
const char *all_pattern[] = { "*", NULL};
@@ -138,10 +122,11 @@ bool List(CommandLine &Cmd)
Cache->Head().PackageCount,
_("Listing"));
GetLocalitySortedVersionSet(CacheFile, bag, matcher, progress);
+ bool ShowAllVersions = _config->FindB("APT::Cmd::All-Versions", false);
for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); ++V)
{
std::stringstream outs;
- if(_config->FindB("APT::Cmd::All-Versions", false) == true)
+ if(ShowAllVersions == true)
{
ListAllVersions(CacheFile, records, V.ParentPkg(), outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
@@ -159,6 +144,18 @@ bool List(CommandLine &Cmd)
std::cout << (*K).second << std::endl;
+ // be nice and tell the user if there is more to see
+ if (bag.size() == 1 && ShowAllVersions == false)
+ {
+ // start with -1 as we already displayed one version
+ int versions = -1;
+ pkgCache::VerIterator Ver = *bag.begin();
+ for ( ; Ver.end() == false; Ver++)
+ versions++;
+ if (versions > 0)
+ _error->Notice(P_("There is %i additional version. Please use the '-a' switch to see it", "There are %i additional versions. Please use the '-a' switch to see them.", versions), versions);
+ }
+
return true;
}