apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

metaindex.cc
Go to the documentation of this file.
1 // Include Files /*{{{*/
2 #include <apt-pkg/indexfile.h>
3 #include <apt-pkg/metaindex.h>
4 #include <apt-pkg/pkgcachegen.h>
5 
6 #include <apt-pkg/debmetaindex.h>
7 
8 #include <string>
9 #include <vector>
10  /*}}}*/
11 
12 class metaIndexPrivate /*{{{*/
13 {
14 };
15  /*}}}*/
16 
17 std::string metaIndex::Describe() const
18 {
19  return "Release";
20 }
21 
23 {
24  return pkgCache::RlsFileIterator(Cache);
25 }
26 
28 {
29  return Gen.SelectReleaseFile("", "");
30 }
31 
32 metaIndex::metaIndex(std::string const &URI, std::string const &Dist,
33  char const * const Type)
34 : d(new metaIndexPrivate()), Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(TRI_UNSET),
35  Date(0), ValidUntil(0), SupportsAcquireByHash(false), LoadedSuccessfully(TRI_UNSET)
36 {
37  /* nothing */
38 }
39 
41 {
42  if (Indexes != 0)
43  {
44  for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();
45  I != (*Indexes).end(); ++I)
46  delete *I;
47  delete Indexes;
48  }
49  for (auto const &E: Entries)
50  delete E.second;
51  delete d;
52 }
53 
54 // one line Getters for public fields /*{{{*/
55 APT_PURE std::string metaIndex::GetURI() const { return URI; }
56 APT_PURE std::string metaIndex::GetDist() const { return Dist; }
57 APT_PURE const char* metaIndex::GetType() const { return Type; }
58 APT_PURE metaIndex::TriState metaIndex::GetTrusted() const { return Trusted; }
59 APT_PURE std::string metaIndex::GetSignedBy() const { return SignedBy; }
60 APT_PURE std::string metaIndex::GetOrigin() const { return Origin; }
61 APT_PURE std::string metaIndex::GetLabel() const { return Label; }
62 APT_PURE std::string metaIndex::GetVersion() const { return Version; }
63 APT_PURE std::string metaIndex::GetCodename() const { return Codename; }
64 APT_PURE std::string metaIndex::GetSuite() const { return Suite; }
65 APT_PURE std::string metaIndex::GetReleaseNotes() const { return ReleaseNotes; }
66 APT_PURE signed short metaIndex::GetDefaultPin() const { return DefaultPin; }
68 APT_PURE time_t metaIndex::GetValidUntil() const { return ValidUntil; }
69 APT_PURE time_t metaIndex::GetDate() const { return this->Date; }
70 APT_PURE metaIndex::TriState metaIndex::GetLoadedSuccessfully() const { return LoadedSuccessfully; }
71 APT_PURE std::string metaIndex::GetExpectedDist() const { return Dist; }
72  /*}}}*/
73 bool metaIndex::CheckDist(std::string const &MaybeDist) const /*{{{*/
74 {
75  if (MaybeDist.empty() || this->Codename == MaybeDist || this->Suite == MaybeDist)
76  return true;
77 
78  std::string Transformed = MaybeDist;
79  if (Transformed == "../project/experimental")
80  Transformed = "experimental";
81 
82  auto const pos = Transformed.rfind('/');
83  if (pos != std::string::npos)
84  Transformed = Transformed.substr(0, pos);
85 
86  if (Transformed == ".")
87  Transformed.clear();
88 
89  return Transformed.empty() || this->Codename == Transformed || this->Suite == Transformed;
90 }
91  /*}}}*/
92 APT_PURE metaIndex::checkSum *metaIndex::Lookup(std::string const &MetaKey) const /*{{{*/
93 {
94  std::map<std::string, metaIndex::checkSum* >::const_iterator sum = Entries.find(MetaKey);
95  if (sum == Entries.end())
96  return NULL;
97  return sum->second;
98 }
99  /*}}}*/
100 APT_PURE bool metaIndex::Exists(std::string const &MetaKey) const /*{{{*/
101 {
102  return Entries.find(MetaKey) != Entries.end();
103 }
104  /*}}}*/
105 std::vector<std::string> metaIndex::MetaKeys() const /*{{{*/
106 {
107  std::vector<std::string> keys;
108  std::map<std::string, checkSum *>::const_iterator I = Entries.begin();
109  while(I != Entries.end()) {
110  keys.push_back((*I).first);
111  ++I;
112  }
113  return keys;
114 }
115  /*}}}*/
116 void metaIndex::swapLoad(metaIndex * const OldMetaIndex) /*{{{*/
117 {
118  std::swap(SignedBy, OldMetaIndex->SignedBy);
119  std::swap(Suite, OldMetaIndex->Suite);
120  std::swap(Codename, OldMetaIndex->Codename);
121  std::swap(Date, OldMetaIndex->Date);
122  std::swap(ValidUntil, OldMetaIndex->ValidUntil);
123  std::swap(SupportsAcquireByHash, OldMetaIndex->SupportsAcquireByHash);
124  std::swap(Entries, OldMetaIndex->Entries);
125  std::swap(LoadedSuccessfully, OldMetaIndex->LoadedSuccessfully);
126 
127  OldMetaIndex->Origin = Origin;
128  OldMetaIndex->Label = Label;
129  OldMetaIndex->Version =Version;
130  OldMetaIndex->DefaultPin = DefaultPin;
131 }
132  /*}}}*/
133 
134 bool metaIndex::IsArchitectureSupported(std::string const &) const /*{{{*/
135 {
136  return true;
137 }
138  /*}}}*/
140 {
141  return true;
142 }
143  /*}}}*/
144 bool metaIndex::HasSupportForComponent(std::string const &) const/*{{{*/
145 {
146  return true;
147 }
148  /*}}}*/
static bool std::string const metaIndex const *const pkgAcqMetaClearSig *const pkgAcquire::Item *const I
return false
Information about an index file.
Definition: indexfile.h:39
Definition: strutl.h:193
time_t GetValidUntil() const
Definition: metaindex.cc:68
std::string GetVersion() const
Definition: metaindex.cc:62
std::string GetReleaseNotes() const
Definition: metaindex.cc:65
std::vector< std::string > MetaKeys() const
Definition: metaindex.cc:105
bool GetSupportsAcquireByHash() const
Definition: metaindex.cc:67
std::string ReleaseNotes
Definition: metaindex.h:51
std::string GetExpectedDist() const
Definition: metaindex.cc:71
std::string Suite
Definition: metaindex.h:45
signed short DefaultPin
Definition: metaindex.h:50
virtual bool IsArchitectureSupported(std::string const &arch) const
Definition: metaindex.cc:134
bool CheckDist(std::string const &MaybeDist) const
Definition: metaindex.cc:73
std::string Dist
Definition: metaindex.h:40
TriState Trusted
Definition: metaindex.h:41
std::string GetSuite() const
Definition: metaindex.cc:64
TriState GetTrusted() const
Definition: metaindex.cc:58
time_t GetDate() const
Definition: metaindex.cc:69
metaIndex(std::string const &URI, std::string const &Dist, char const *const Type)
Definition: metaindex.cc:32
std::string GetDist() const
Definition: metaindex.cc:56
signed short GetDefaultPin() const
Definition: metaindex.cc:66
void swapLoad(metaIndex *const OldMetaIndex)
Definition: metaindex.cc:116
std::string GetSignedBy() const
Definition: metaindex.cc:59
std::string GetLabel() const
Definition: metaindex.cc:61
checkSum * Lookup(std::string const &MetaKey) const
Definition: metaindex.cc:92
metaIndexPrivate *const d
Definition: metaindex.h:34
virtual bool IsArchitectureAllSupportedFor(IndexTarget const &target) const
Definition: metaindex.cc:139
std::string Codename
Definition: metaindex.h:46
TriState GetLoadedSuccessfully() const
Definition: metaindex.cc:70
std::string GetCodename() const
Definition: metaindex.cc:63
std::string Version
Definition: metaindex.h:49
virtual pkgCache::RlsFileIterator FindInCache(pkgCache &Cache, bool const ModifyCheck) const
Definition: metaindex.cc:22
std::string Origin
Definition: metaindex.h:47
std::string SignedBy
Definition: metaindex.h:42
time_t ValidUntil
Definition: metaindex.h:53
time_t Date
Definition: metaindex.h:52
std::string URI
Definition: metaindex.h:39
virtual std::string Describe() const
Definition: metaindex.cc:17
virtual bool HasSupportForComponent(std::string const &component) const
Definition: metaindex.cc:144
std::vector< pkgIndexFile * > * Indexes
Definition: metaindex.h:36
bool Exists(std::string const &MetaKey) const
tests if a checksum for this file is available
Definition: metaindex.cc:100
const char * GetType() const
Definition: metaindex.cc:57
virtual ~metaIndex()
Definition: metaindex.cc:40
std::string GetURI() const
Definition: metaindex.cc:55
TriState LoadedSuccessfully
Definition: metaindex.h:56
bool SupportsAcquireByHash
Definition: metaindex.h:54
std::map< std::string, checkSum * > Entries
Definition: metaindex.h:55
std::string Label
Definition: metaindex.h:48
const char * Type
Definition: metaindex.h:38
std::string GetOrigin() const
Definition: metaindex.cc:60
virtual bool Merge(pkgCacheGenerator &Gen, OpProgress *Prog) const
Definition: metaindex.cc:27
bool SelectReleaseFile(const std::string &File, const std::string &Site, unsigned long Flags=0)
#define APT_PURE
Definition: macros.h:56