]> git.saurik.com Git - apt.git/blob - apt-private/private-unmet.cc
eipp: properly handle arch-specific provides
[apt.git] / apt-private / private-unmet.cc
1 // -*- mode: cpp; mode: fold -*-
2 // Include Files /*{{{*/
3 #include<config.h>
4
5 #include <apt-pkg/cachefile.h>
6 #include <apt-pkg/cmndline.h>
7 #include <apt-pkg/configuration.h>
8 #include <apt-pkg/strutl.h>
9
10 #include <apt-private/private-cacheset.h>
11 #include <apt-private/private-unmet.h>
12
13 #include <stddef.h>
14
15 #include <iostream>
16
17 #include <apti18n.h>
18 /*}}}*/
19
20 // UnMet - Show unmet dependencies /*{{{*/
21 static bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important)
22 {
23 bool Header = false;
24 for (pkgCache::DepIterator D = V.DependsList(); D.end() == false;)
25 {
26 // Collect or groups
27 pkgCache::DepIterator Start;
28 pkgCache::DepIterator End;
29 D.GlobOr(Start,End);
30
31 // Important deps only
32 if (Important == true)
33 if (End->Type != pkgCache::Dep::PreDepends &&
34 End->Type != pkgCache::Dep::Depends)
35 continue;
36
37 // Skip conflicts and replaces
38 if (End.IsNegative() == true || End->Type == pkgCache::Dep::Replaces)
39 continue;
40
41 // Verify the or group
42 bool OK = false;
43 pkgCache::DepIterator RealStart = Start;
44 do
45 {
46 // See if this dep is Ok
47 pkgCache::Version **VList = Start.AllTargets();
48 if (*VList != 0)
49 {
50 OK = true;
51 delete [] VList;
52 break;
53 }
54 delete [] VList;
55
56 if (Start == End)
57 break;
58 ++Start;
59 }
60 while (1);
61
62 // The group is OK
63 if (OK == true)
64 continue;
65
66 // Oops, it failed..
67 if (Header == false)
68 ioprintf(std::cout,_("Package %s version %s has an unmet dep:\n"),
69 V.ParentPkg().FullName(true).c_str(),V.VerStr());
70 Header = true;
71
72 // Print out the dep type
73 std::cout << " " << End.DepType() << ": ";
74
75 // Show the group
76 Start = RealStart;
77 do
78 {
79 std::cout << Start.TargetPkg().FullName(true);
80 if (Start.TargetVer() != 0)
81 std::cout << " (" << Start.CompType() << " " << Start.TargetVer() <<
82 ")";
83 if (Start == End)
84 break;
85 std::cout << " | ";
86 ++Start;
87 }
88 while (1);
89
90 std::cout << std::endl;
91 }
92 return true;
93 }
94 bool UnMet(CommandLine &CmdL)
95 {
96 bool const Important = _config->FindB("APT::Cache::Important",false);
97
98 pkgCacheFile CacheFile;
99 if (unlikely(CacheFile.GetPkgCache() == NULL))
100 return false;
101
102 if (CmdL.FileSize() <= 1)
103 {
104 for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; ++P)
105 for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
106 if (ShowUnMet(V, Important) == false)
107 return false;
108 }
109 else
110 {
111 CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
112 APT::VersionList verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1,
113 APT::CacheSetHelper::CANDIDATE, helper);
114 for (APT::VersionList::iterator V = verset.begin(); V != verset.end(); ++V)
115 if (ShowUnMet(V, Important) == false)
116 return false;
117 }
118 return true;
119 }
120 /*}}}*/