libzypp: zypp/repo/PackageDelta.cc Source File

libzypp 17.38.14

PackageDelta.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13extern "C"
14{
15#include <solv/knownid.h>
16}
17
18#include <zypp-core/base/LogTools.h>
19
20#include <zypp/repo/PackageDelta.h>
21#include <zypp/sat/Pool.h>
22
23
24using std::endl;
25using std::string;
26
27
29namespace zypp
30{
32 namespace packagedelta
33 {
34
35 DeltaRpm::DeltaRpm( const sat::LookupAttr::iterator& deltaInfo_r )
36 {
37 if ( deltaInfo_r.inSolvAttr() != sat::SolvAttr::repositoryDeltaInfo )
38 {
39 INT << "Illegal non-repositoryDeltaInfo iterator: " << deltaInfo_r << endl;
40 return;
41 }
42 _repo = deltaInfo_r.inRepo();
43 _location.setOptional( true ); // bsc#1245672: delta rpms are optional resources.
44
45 IdString locdir;
46 IdString locname;
47 IdString locevr;
48 IdString locsuffix;
49
50 IdString seqname;
51 IdString seqevr;
52 std::string seqnum;
53
54 for_( it, deltaInfo_r.subBegin(), deltaInfo_r.subEnd() )
55 {
56 switch ( it.inSolvAttr().id() )
57 {
58 case DELTA_PACKAGE_NAME:
59 _name = it.asString();
60 break;
61
62 case DELTA_PACKAGE_EVR:
63 _edition = Edition( it.idStr() );
64 break;
65
66 case DELTA_PACKAGE_ARCH:
67 _arch = Arch( it.idStr() );
68 break;
69
70 case DELTA_LOCATION_DIR:
71 locdir = it.idStr();
72 break;
73
74 case DELTA_LOCATION_NAME:
75 locname = it.idStr();
76 break;
77
78 case DELTA_LOCATION_EVR:
79 locevr = it.idStr();
80 break;
81
82 case DELTA_LOCATION_SUFFIX:
83 locsuffix = it.idStr();
84 break;
85
86 case DELTA_DOWNLOADSIZE:
87 _location.setDownloadSize( ByteCount( it.asUnsignedLL() ) );
88 break;
89
90 case DELTA_CHECKSUM:
91 _location.setChecksum( it.asCheckSum() );
92 break;
93
94 case DELTA_BASE_EVR:
95 _baseversion.setEdition( Edition( it.idStr() ) );
96 break;
97
98 case DELTA_SEQ_NAME:
99 seqname = it.idStr();
100 break;
101
102 case DELTA_SEQ_EVR:
103 seqevr = it.idStr();
104 break;
105
106 case DELTA_SEQ_NUM:
107 seqnum = it.asString();
108 break;
109
110 default:
111 WAR << "Ignore unknown attribute: " << it << endl;
112 }
113 }
114
115 _location.setLocation( str::form( "%s/%s-%s.%s",
116 locdir.c_str(),
117 locname.c_str(),
118 locevr.c_str(),
119 locsuffix.c_str() ) );
120
121 _baseversion.setSequenceinfo( str::form( "%s-%s-%s",
122 seqname.c_str(),
123 seqevr.c_str(),
124 seqnum.c_str() ) );
125 }
126
127 std::ostream & operator<<( std::ostream & str, const DeltaRpm & obj )
128 {
129 return str
130 << "DeltaRpm[" << obj.name() << "-" << obj.edition() << "." << obj.arch()
131 << "](" << obj.location()
132 << '|' << obj.baseversion().edition()
133 << ')';
134 }
135
137 } // namespace packagedelta
138
140} // namespace zypp
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
LogTools.h
WAR
#define WAR
Definition Logger.h:104
INT
#define INT
Definition Logger.h:107
PackageDelta.h
Pool.h
zypp::Arch::Arch
Arch()
Default ctor Arc_noarch.
Definition Arch.cc:681
zypp::ByteCount::ByteCount
ByteCount()
Default ctor.
Definition ByteCount.h:71
zypp::Edition::Edition
Edition()
Default ctor: noedition.
Definition Edition.h:76
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:55
zypp::IdString::c_str
const char * c_str() const
Conversion to const char *.
Definition IdString.cc:51
zypp::IdString::asString
std::string asString() const
Conversion to std::string.
Definition IdString.h:110
zypp::OnMediaLocation::setDownloadSize
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
Definition onmedialocation.cc:120
zypp::OnMediaLocation::setChecksum
OnMediaLocation & setChecksum(CheckSum val_r)
Set the checksum.
Definition onmedialocation.cc:126
zypp::OnMediaLocation::setLocation
OnMediaLocation & setLocation(Pathname filename_r, unsigned medianr_r=1)
Set filename_r and medianr_r (defaults to 1).
Definition onmedialocation.cc:96
zypp::OnMediaLocation::setOptional
OnMediaLocation & setOptional(bool val)
Set whether the resource is optional.
Definition onmedialocation.cc:114
zypp::packagedelta::DeltaRpm::BaseVersion::edition
const Edition & edition() const
Definition PackageDelta.h:45
zypp::packagedelta::DeltaRpm::BaseVersion::setEdition
BaseVersion & setEdition(const Edition &val_r)
Definition PackageDelta.h:49
zypp::packagedelta::DeltaRpm::BaseVersion::setSequenceinfo
BaseVersion & setSequenceinfo(const std::string &val_r)
Definition PackageDelta.h:50
zypp::packagedelta::DeltaRpm
Definition PackageDelta.h:36
zypp::packagedelta::DeltaRpm::edition
const Edition & edition() const
Definition PackageDelta.h:65
zypp::packagedelta::DeltaRpm::_repo
Repository _repo
Definition PackageDelta.h:85
zypp::packagedelta::DeltaRpm::name
const std::string & name() const
Definition PackageDelta.h:64
zypp::packagedelta::DeltaRpm::location
const OnMediaLocation & location() const
Definition PackageDelta.h:68
zypp::packagedelta::DeltaRpm::_edition
Edition _edition
Definition PackageDelta.h:81
zypp::packagedelta::DeltaRpm::_location
OnMediaLocation _location
Definition PackageDelta.h:83
zypp::packagedelta::DeltaRpm::baseversion
const BaseVersion & baseversion() const
Definition PackageDelta.h:69
zypp::packagedelta::DeltaRpm::arch
const Arch & arch() const
Definition PackageDelta.h:66
zypp::packagedelta::DeltaRpm::_baseversion
BaseVersion _baseversion
Definition PackageDelta.h:84
zypp::packagedelta::DeltaRpm::_name
std::string _name
Definition PackageDelta.h:80
zypp::packagedelta::DeltaRpm::DeltaRpm
DeltaRpm()
Definition PackageDelta.h:58
zypp::packagedelta::DeltaRpm::_arch
Arch _arch
Definition PackageDelta.h:82
zypp::sat::LookupAttr::iterator
Result iterator.
Definition LookupAttr.h:364
zypp::sat::LookupAttr::iterator::subBegin
iterator subBegin() const
Iterator to the begin of a sub-structure.
Definition LookupAttr.cc:471
zypp::sat::LookupAttr::iterator::inSolvAttr
SolvAttr inSolvAttr() const
The current SolvAttr.
Definition LookupAttr.cc:358
zypp::sat::LookupAttr::iterator::subEnd
iterator subEnd() const
Iterator behind the end of a sub-structure.
Definition LookupAttr.cc:493
zypp::sat::LookupAttr::iterator::inRepo
Repository inRepo() const
The current Repository.
Definition LookupAttr.cc:352
zypp::sat::SolvAttr::repositoryDeltaInfo
static const SolvAttr repositoryDeltaInfo
Definition SolvAttr.h:181
str
String related utilities and Regular expression matching.
zypp::packagedelta
Definition PackageDelta.cc:33
zypp::packagedelta::operator<<
std::ostream & operator<<(std::ostream &str, const DeltaRpm &obj)
relates: DeltaRpm Stream output.
Definition PackageDelta.cc:127
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2