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