- introduced TranslatedText
[platform/upstream/libzypp.git] / zypp / Package.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/Package.cc
10  *
11 */
12 #include "zypp/Package.h"
13 #include "zypp/source/SourceImpl.h"
14 #include "zypp/base/Exception.h"
15
16 using namespace std;
17
18 ///////////////////////////////////////////////////////////////////
19 namespace zypp
20 { /////////////////////////////////////////////////////////////////
21
22   ///////////////////////////////////////////////////////////////////
23   //
24   //    METHOD NAME : Package::Package
25   //    METHOD TYPE : Ctor
26   //
27   Package::Package( const NVRAD & nvrad_r )
28   : ResObject( TraitsType::kind, nvrad_r )
29   {}
30
31   ///////////////////////////////////////////////////////////////////
32   //
33   //    METHOD NAME : Package::~Package
34   //    METHOD TYPE : Dtor
35   //
36   Package::~Package()
37   {}
38
39   ///////////////////////////////////////////////////////////////////
40   //
41   //    Package interface forwarded to implementation
42   //
43   ///////////////////////////////////////////////////////////////////
44
45   Changelog Package::changelog() const
46   { return pimpl().changelog(); }
47
48   /** Time of package installation */
49   Date Package::installtime() const
50   { return pimpl().installtime(); }
51
52   /** */
53   Date Package::buildtime() const
54   { return pimpl().buildtime(); }
55
56   /** */
57   std::string Package::buildhost() const
58   { return pimpl().buildhost(); }
59
60   /** */
61   std::string Package::distribution() const
62   { return pimpl().distribution(); }
63
64     /** */
65   Vendor Package::vendor() const
66   { return pimpl().vendor(); }
67
68   /** */
69   Label Package::license() const
70   { return pimpl().license(); }
71
72   /** */
73   std::string Package::packager() const
74   { return pimpl().packager(); }
75
76   /** */
77   PackageGroup Package::group() const
78   { return pimpl().group(); }
79
80
81   /** Don't ship it as class Url, because it might be
82    * in fact anything but a legal Url. */
83   std::string Package::url() const
84   { return pimpl().url(); }
85
86   /** */
87   std::string Package::os() const
88   { return pimpl().os(); }
89
90   /** */
91   Text Package::prein() const
92   { return pimpl().prein(); }
93
94   /** */
95   Text Package::postin() const
96   { return pimpl().postin(); }
97
98   /** */
99   Text Package::preun() const
100   { return pimpl().preun(); }
101
102   /** */
103   Text Package::postun() const
104   { return pimpl().postun(); }
105
106   /** */
107   ByteCount Package::sourcesize() const
108   { return pimpl().sourcesize(); }
109
110   /** */
111   ByteCount Package::archivesize() const
112   { return pimpl().archivesize(); }
113
114   /** */
115   std::list<std::string> Package::authors() const
116   { return pimpl().authors(); }
117
118   /** */
119   std::list<std::string> Package::filenames() const
120   { return pimpl().filenames(); }
121
122   /** */
123   License Package::licenseToConfirm() const
124   { return pimpl().licenseToConfirm(); }
125
126   /** */
127   Pathname Package::plainRpm() const
128   { return pimpl().location(); }
129
130   /** */
131   std::list<PatchRpm> Package::patchRpms() const
132   { return pimpl().patchRpms(); }
133
134   /** */
135   std::list<DeltaRpm> Package::deltaRpms() const
136   { return pimpl().deltaRpms(); }
137
138   /** */
139   Pathname Package::getPlainRpm() const
140   { return source().provideFile(plainRpm()); }
141
142   /** */
143   Pathname Package::getDeltaRpm(BaseVersion & base_r) const
144   {
145 #warning (2x): TODO: BaseVersion compare checks only Edition
146     std::list<DeltaRpm> deltas = deltaRpms();
147     for (std::list<DeltaRpm>::const_iterator it = deltas.begin();
148          it != deltas.end(); it++)
149     {
150       if (base_r == it->baseVersion())
151         return source().provideFile(it->filename());
152     }
153     ZYPP_THROW(Exception("No matching delta RPM found"));
154     return source().provideFile(plainRpm()); // never reached
155   }
156
157   /** */
158   Pathname Package::getPatchRpm(BaseVersion & base_r) const
159   {
160     std::list<PatchRpm> patches = patchRpms();
161     for (std::list<PatchRpm>::const_iterator it = patches.begin();
162          it != patches.end(); it++)
163     {
164       std::list<BaseVersion> bases = it->baseVersions();
165       for (std::list<BaseVersion>::const_iterator bvit = bases.begin();
166            bvit != bases.end(); bvit++)
167       {
168         if (base_r == *bvit)
169           return source().provideFile(it->filename());
170       }
171     }
172     ZYPP_THROW(Exception("No matching patch RPM found"));
173     return source().provideFile(plainRpm()); // never reached
174   }
175
176   bool Package::installOnly() const
177   { return pimpl().installOnly(); }
178
179   /////////////////////////////////////////////////////////////////
180 } // namespace zypp
181 ///////////////////////////////////////////////////////////////////