libzypp  17.37.10
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  _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 
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
140 } // namespace zypp
const BaseVersion & baseversion() const
Definition: PackageDelta.h:69
const Edition & edition() const
Definition: PackageDelta.h:65
iterator subEnd() const
Iterator behind the end of a sub-structure.
Definition: LookupAttr.cc:493
static const SolvAttr repositoryDeltaInfo
Definition: SolvAttr.h:181
Architecture.
Definition: Arch.h:36
Store and operate with byte count.
Definition: ByteCount.h:31
#define INT
Definition: Logger.h:104
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const DeltaRpm &obj)
OnMediaLocation & setChecksum(CheckSum val_r)
Set the checksum.
Access to the sat-pools string space.
Definition: IdString.h:43
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:39
SolvAttr inSolvAttr() const
The current SolvAttr.
Definition: LookupAttr.cc:358
const OnMediaLocation & location() const
Definition: PackageDelta.h:68
#define WAR
Definition: Logger.h:101
BaseVersion & setSequenceinfo(const std::string &val_r)
Definition: PackageDelta.h:50
OnMediaLocation & setLocation(Pathname filename_r, unsigned medianr_r=1)
Set filename_r and medianr_r (defaults to 1).
const char * c_str() const
Conversion to const char *
Definition: IdString.cc:50
const Arch & arch() const
Definition: PackageDelta.h:66
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
BaseVersion & setEdition(const Edition &val_r)
Definition: PackageDelta.h:49
const std::string & name() const
Definition: PackageDelta.h:64
std::string asString() const
Conversion to std::string
Definition: IdString.h:99
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
OnMediaLocation & setOptional(bool val)
Set whether the resource is optional.
iterator subBegin() const
Iterator to the begin of a sub-structure.
Definition: LookupAttr.cc:471
Repository inRepo() const
The current Repository.
Definition: LookupAttr.cc:352