summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-private/private-unmet.cc120
-rw-r--r--apt-private/private-unmet.h10
-rw-r--r--cmdline/apt-cache.cc104
3 files changed, 131 insertions, 103 deletions
diff --git a/apt-private/private-unmet.cc b/apt-private/private-unmet.cc
new file mode 100644
index 000000000..51ace3f47
--- /dev/null
+++ b/apt-private/private-unmet.cc
@@ -0,0 +1,120 @@
+// -*- mode: cpp; mode: fold -*-
+// Include Files /*{{{*/
+#include<config.h>
+
+#include <apt-pkg/cachefile.h>
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/strutl.h>
+
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-unmet.h>
+
+#include <stddef.h>
+
+#include <iostream>
+
+#include <apti18n.h>
+ /*}}}*/
+
+// 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(std::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
+ std::cout << " " << End.DepType() << ": ";
+
+ // Show the group
+ Start = RealStart;
+ do
+ {
+ std::cout << Start.TargetPkg().FullName(true);
+ if (Start.TargetVer() != 0)
+ std::cout << " (" << Start.CompType() << " " << Start.TargetVer() <<
+ ")";
+ if (Start == End)
+ break;
+ std::cout << " | ";
+ ++Start;
+ }
+ while (1);
+
+ std::cout << std::endl;
+ }
+ return true;
+}
+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;
+}
+ /*}}}*/
diff --git a/apt-private/private-unmet.h b/apt-private/private-unmet.h
new file mode 100644
index 000000000..31c2c17f3
--- /dev/null
+++ b/apt-private/private-unmet.h
@@ -0,0 +1,10 @@
+#ifndef APT_PRIVATE_UNMET_H
+#define APT_PRIVATE_UNMET_H
+
+#include <apt-pkg/macros.h>
+
+class CommandLine;
+
+APT_PUBLIC bool UnMet(CommandLine &CmdL);
+
+#endif
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 4a592da8f..f68e739b1 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -46,6 +46,7 @@
#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>
@@ -68,109 +69,6 @@
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 /*{{{*/
// ---------------------------------------------------------------------
/* */