#include <apt-private/private-depends.h>
#include <apt-private/private-show.h>
#include <apt-private/private-search.h>
+#include <apt-private/private-unmet.h>
#include <apt-private/private-main.h>
#include <regex.h>
using namespace std;
-// UnMet - Show unmet dependencies /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important)
-{
- bool Header = false;
- for (pkgCache::DepIterator D = V.DependsList(); D.end() == false;)
- {
- // Collect or groups
- pkgCache::DepIterator Start;
- pkgCache::DepIterator End;
- D.GlobOr(Start,End);
-
- // Important deps only
- if (Important == true)
- if (End->Type != pkgCache::Dep::PreDepends &&
- End->Type != pkgCache::Dep::Depends)
- continue;
-
- // Skip conflicts and replaces
- if (End.IsNegative() == true || End->Type == pkgCache::Dep::Replaces)
- continue;
-
- // Verify the or group
- bool OK = false;
- pkgCache::DepIterator RealStart = Start;
- do
- {
- // See if this dep is Ok
- pkgCache::Version **VList = Start.AllTargets();
- if (*VList != 0)
- {
- OK = true;
- delete [] VList;
- break;
- }
- delete [] VList;
-
- if (Start == End)
- break;
- ++Start;
- }
- while (1);
-
- // The group is OK
- if (OK == true)
- continue;
-
- // Oops, it failed..
- if (Header == false)
- ioprintf(cout,_("Package %s version %s has an unmet dep:\n"),
- V.ParentPkg().FullName(true).c_str(),V.VerStr());
- Header = true;
-
- // Print out the dep type
- cout << " " << End.DepType() << ": ";
-
- // Show the group
- Start = RealStart;
- do
- {
- cout << Start.TargetPkg().FullName(true);
- if (Start.TargetVer() != 0)
- cout << " (" << Start.CompType() << " " << Start.TargetVer() <<
- ")";
- if (Start == End)
- break;
- cout << " | ";
- ++Start;
- }
- while (1);
-
- cout << endl;
- }
- return true;
-}
-static bool UnMet(CommandLine &CmdL)
-{
- bool const Important = _config->FindB("APT::Cache::Important",false);
-
- pkgCacheFile CacheFile;
- if (unlikely(CacheFile.GetPkgCache() == NULL))
- return false;
-
- if (CmdL.FileSize() <= 1)
- {
- for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; ++P)
- for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
- if (ShowUnMet(V, Important) == false)
- return false;
- }
- else
- {
- CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
- APT::VersionList verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1,
- APT::CacheSetHelper::CANDIDATE, helper);
- for (APT::VersionList::iterator V = verset.begin(); V != verset.end(); ++V)
- if (ShowUnMet(V, Important) == false)
- return false;
- }
- return true;
-}
- /*}}}*/
// DumpPackage - Show a dump of a package record /*{{{*/
// ---------------------------------------------------------------------
/* */
cout << "Total buckets in " << Type << ": " << NumBuckets << std::endl;
cout << " Unused: " << UnusedBuckets << std::endl;
cout << " Used: " << UsedBuckets << std::endl;
- cout << " Average entries: " << Entries/(double)NumBuckets << std::endl;
+ cout << " Utilization: " << 100.0 * UsedBuckets/NumBuckets << "%" << std::endl;
+ cout << " Average entries: " << Entries/(double)UsedBuckets << std::endl;
cout << " Longest: " << LongestBucket << std::endl;
cout << " Shortest: " << ShortestBucket << std::endl;
}
std::cout << " Size: " << F->Size << std::endl;
std::cout << " ID: " << F->ID << std::endl;
std::cout << " Flags: " << F->Flags << std::endl;
- std::cout << " Time: " << TimeRFC1123(F->mtime) << std::endl;
+ std::cout << " Time: " << TimeRFC1123(F->mtime, true) << std::endl;
std::cout << " Archive: " << DeNull(F.Archive()) << std::endl;
std::cout << " Component: " << DeNull(F.Component()) << std::endl;
std::cout << " Version: " << DeNull(F.Version()) << std::endl;
return CacheFile.BuildCaches(&Progress, true);
}
/*}}}*/
-bool ShowHelp(CommandLine &) /*{{{*/
+static bool ShowHelp(CommandLine &) /*{{{*/
{
std::cout <<
_("Usage: apt-cache [options] command\n"
" apt-cache [options] show pkg1 [pkg2 ...]\n"
"\n"
"apt-cache queries and displays available information about installed\n"
- "as well as installable packages. It works exclusively on the data\n"
- "acquired via the 'update' command of e.g. apt-get to the local cache.\n"
- "The displayed information can therefore be outdated if the last update\n"
- "is too long ago, but in exchange apt-cache works independently of the\n"
+ "and installable packages. It works exclusively on the data acquired\n"
+ "into the local cache via the 'update' command of e.g. apt-get. The\n"
+ "displayed information may therefore be outdated if the last update was\n"
+ "too long ago, but in exchange apt-cache works independently of the\n"
"availability of the configured sources (e.g. offline).\n");
return true;
}
/*}}}*/
-std::vector<aptDispatchWithHelp> GetCommands() /*{{{*/
+static std::vector<aptDispatchWithHelp> GetCommands() /*{{{*/
{
return {
{"gencaches",&GenCaches, nullptr},
/*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
- InitLocale();
-
// Parse the command line and initialize the package library
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CACHE, &_config, &_system, argc, argv);
+ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_CACHE, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
InitOutput();