]>
git.saurik.com Git - apt.git/blob - apt-pkg/prettyprinters.cc
2 /* ######################################################################
4 Provide pretty printers for pkgCache structs like PkgIterator
6 ##################################################################### */
8 // Include Files /*{{{*/
11 #include <apt-pkg/depcache.h>
12 #include <apt-pkg/prettyprinters.h>
19 std::ostream
& operator<<(std::ostream
& os
, const APT::PrettyPkg
& pp
) /*{{{*/
21 if (pp
.Pkg
.end() == true)
22 return os
<< "invalid package";
24 auto state
= (*pp
.DepCache
)[pp
.Pkg
];
25 std::string
const current
= (pp
.Pkg
.CurVersion() == 0 ? "none" : pp
.Pkg
.CurVersion());
26 std::string candidate
= state
.CandVersion
;
27 if (candidate
.empty())
29 std::string install
= "none";
30 if (state
.InstallVer
!= nullptr)
31 install
= state
.InstVerIter(*pp
.DepCache
).VerStr();
33 os
<< pp
.Pkg
.FullName(false) << " < " << current
;
34 if (current
!= install
&& install
!= "none")
35 os
<< " -> " << install
;
36 if (install
!= candidate
&& current
!= candidate
)
37 os
<< " | " << candidate
;
39 switch (pp
.Pkg
->SelectedState
)
41 case pkgCache::State::Unknown
: os
<< 'u'; break;
42 case pkgCache::State::Install
: os
<< 'i'; break;
43 case pkgCache::State::Hold
: os
<< 'h'; break;
44 case pkgCache::State::DeInstall
: os
<< 'r'; break;
45 case pkgCache::State::Purge
: os
<< 'p'; break;
48 switch (pp
.Pkg
->InstState
)
50 case pkgCache::State::Ok
: break;
51 case pkgCache::State::ReInstReq
: os
<< 'R'; break;
52 case pkgCache::State::HoldInst
: os
<< 'H'; break;
53 case pkgCache::State::HoldReInstReq
: os
<< "HR"; break;
56 switch (pp
.Pkg
->CurrentState
)
58 case pkgCache::State::NotInstalled
: os
<< 'n'; break;
59 case pkgCache::State::ConfigFiles
: os
<< 'c'; break;
60 case pkgCache::State::HalfInstalled
: os
<< 'H'; break;
61 case pkgCache::State::UnPacked
: os
<< 'U'; break;
62 case pkgCache::State::HalfConfigured
: os
<< 'F'; break;
63 case pkgCache::State::TriggersAwaited
: os
<< 'W'; break;
64 case pkgCache::State::TriggersPending
: os
<< 'T'; break;
65 case pkgCache::State::Installed
: os
<< 'i'; break;
71 if (state
.ReInstall())
73 if (state
.Upgradable())
79 if (state
.NewInstall())
81 else if (state
.Upgrade())
83 else if (state
.Downgrade())
85 else if (state
.Install())
87 else if (state
.Purge())
89 else if (state
.Delete())
91 else if (state
.Held())
93 else if (state
.Keep())
95 if (state
.NowBroken())
97 else if (state
.NowPolicyBroken())
99 if (state
.InstBroken())
101 else if (state
.InstPolicyBroken())
107 std::ostream
& operator<<(std::ostream
& os
, const APT::PrettyDep
& pd
) /*{{{*/
109 if (unlikely(pd
.Dep
.end() == true))
110 return os
<< "invalid dependency";
112 pkgCache::PkgIterator P
= pd
.Dep
.ParentPkg();
113 pkgCache::PkgIterator T
= pd
.Dep
.TargetPkg();
115 os
<< (P
.end() ? "invalid pkg" : P
.FullName(false)) << " " << pd
.Dep
.DepType()
116 << " on " << APT::PrettyPkg(pd
.DepCache
, T
);
118 if (pd
.Dep
->Version
!= 0)
119 os
<< " (" << pd
.Dep
.CompType() << " " << pd
.Dep
.TargetVer() << ")";