libzypp  13.10.6
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  << ',' << obj.baseversion().sequenceinfo()
133  << ')';
134  }
135 
137  } // namespace packagedelta
140 } // namespace zypp
const BaseVersion & baseversion() const
Definition: PackageDelta.h:69
static const SolvAttr repositoryDeltaInfo
Definition: SolvAttr.h:168
Architecture.
Definition: Arch.h:36
Store and operate with byte count.
Definition: ByteCount.h:30
#define INT
Definition: Logger.h:51
std::ostream & operator<<(std::ostream &str, const DeltaRpm &obj)
Access to the sat-pools string space.
Definition: IdString.h:39
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
std::string asString() const
Conversion to std::string
Definition: IdString.h:83
const Arch & arch() const
Definition: PackageDelta.h:66
iterator subBegin() const
Iterator to the begin of a sub-structure.
Definition: LookupAttr.cc:471
OnMediaLocation & setDownloadSize(const ByteCount &val_r)
Set the files size.
const Edition & edition() const
Definition: PackageDelta.h:65
#define WAR
Definition: Logger.h:48
SolvAttr inSolvAttr() const
The current SolvAttr.
Definition: LookupAttr.cc:357
OnMediaLocation & setChecksum(const CheckSum &val_r)
Set the files checksum.
BaseVersion & setSequenceinfo(const std::string &val_r)
Definition: PackageDelta.h:50
const OnMediaLocation & location() const
Definition: PackageDelta.h:68
const char * c_str() const
Conversion to const char *
Definition: IdString.cc:42
Repository inRepo() const
The current Repository.
Definition: LookupAttr.cc:351
std::string form(const char *format,...)
Printf style construction of std::string.
Definition: String.cc:34
const std::string & sequenceinfo() const
Definition: PackageDelta.h:46
BaseVersion & setEdition(const Edition &val_r)
Definition: PackageDelta.h:49
const std::string & name() const
Definition: PackageDelta.h:64
iterator subEnd() const
Iterator behind the end of a sub-structure.
Definition: LookupAttr.cc:493
OnMediaLocation & setLocation(const Pathname &val_r, unsigned mediaNumber_r=1)
Set filename and media number (defaults to 1).