]>
git.saurik.com Git - apt.git/blob - apt-private/private-show.cc
1 #include <apt-pkg/error.h>
2 #include <apt-pkg/cachefile.h>
3 #include <apt-pkg/cachefilter.h>
4 #include <apt-pkg/cacheset.h>
5 #include <apt-pkg/init.h>
6 #include <apt-pkg/progress.h>
7 #include <apt-pkg/sourcelist.h>
8 #include <apt-pkg/cmndline.h>
9 #include <apt-pkg/strutl.h>
10 #include <apt-pkg/fileutl.h>
11 #include <apt-pkg/pkgrecords.h>
12 #include <apt-pkg/srcrecords.h>
13 #include <apt-pkg/version.h>
14 #include <apt-pkg/policy.h>
15 #include <apt-pkg/tagfile.h>
16 #include <apt-pkg/algorithms.h>
17 #include <apt-pkg/sptr.h>
18 #include <apt-pkg/pkgsystem.h>
19 #include <apt-pkg/indexfile.h>
20 #include <apt-pkg/metaindex.h>
24 #include "private-output.h"
25 #include "private-cacheset.h"
30 // DisplayRecord - Displays the complete record for the package /*{{{*/
31 // ---------------------------------------------------------------------
32 bool DisplayRecord(pkgCacheFile
&CacheFile
, pkgCache::VerIterator V
,
35 pkgCache
*Cache
= CacheFile
.GetPkgCache();
36 if (unlikely(Cache
== NULL
))
39 // Find an appropriate file
40 pkgCache::VerFileIterator Vf
= V
.FileList();
41 for (; Vf
.end() == false; ++Vf
)
42 if ((Vf
.File()->Flags
& pkgCache::Flag::NotSource
) == 0)
47 // Check and load the package list file
48 pkgCache::PkgFileIterator I
= Vf
.File();
49 if (I
.IsOk() == false)
50 return _error
->Error(_("Package file %s is out of sync."),I
.FileName());
54 if (PkgF
.Open(I
.FileName(), FileFd::ReadOnly
, FileFd::Extension
) == false)
57 pkgTagFile
TagF(&PkgF
);
59 TFRewriteData RW
[] = {
62 {"Description-md5",0},
66 if (TagF
.Jump(Tags
, V
.FileList()->Offset
) == false ||
67 TFRewrite(stdout
,Tags
,&Zero
,RW
) == false)
69 _error
->Error("Internal Error, Unable to parse a package record");
73 // write the description
74 pkgRecords
Recs(*Cache
);
75 pkgCache::DescIterator Desc
= V
.TranslatedDescription();
76 if (Desc
.end() == false)
78 pkgRecords::Parser
&P
= Recs
.Lookup(Desc
.FileList());
79 if (strcmp(Desc
.LanguageCode(),"") != 0)
80 out
<< "Description-lang: " << Desc
.LanguageCode() << std::endl
;
81 out
<< "Description" << P
.LongDesc();
84 // write a final newline (after the description)
85 out
<< std::endl
<< std::endl
;
91 bool ShowPackage(CommandLine
&CmdL
)
93 pkgCacheFile CacheFile
;
94 CacheSetHelperVirtuals
helper(true, GlobalError::NOTICE
);
95 APT::VersionList::Version
const select
= APT::VersionList::CANDIDATE
;
96 APT::VersionList
const verset
= APT::VersionList::FromCommandLine(CacheFile
, CmdL
.FileList
+ 1, select
, helper
);
97 for (APT::VersionList::const_iterator Ver
= verset
.begin(); Ver
!= verset
.end(); ++Ver
)
98 if (DisplayRecord(CacheFile
, Ver
, c1out
) == false)
101 for (APT::PackageSet::const_iterator Pkg
= helper
.virtualPkgs
.begin();
102 Pkg
!= helper
.virtualPkgs
.end(); ++Pkg
)
104 c1out
<< "Package: " << Pkg
.FullName(true) << std::endl
;
105 c1out
<< "State: " << _("not a real pacakge (virtual)") << std::endl
;
106 // FIXME: show providers, see private-cacheset.h
107 // CacheSetHelperAPTGet::showVirtualPackageErrors()
110 if (verset
.empty() == true)
112 if (helper
.virtualPkgs
.empty() == true)
113 return _error
->Error(_("No packages found"));
115 _error
->Notice(_("No packages found"));