libzypp  11.13.5
Package.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include "zypp/base/Logger.h"
13 #include "zypp/base/String.h"
14 #include "zypp/Package.h"
15 #include "zypp/sat/LookupAttr.h"
16 #include "zypp/ZYppFactory.h"
17 #include "zypp/target/rpm/RpmDb.h"
19 
20 using namespace std;
21 
23 namespace zypp
24 {
25 
26  IMPL_PTR_TYPE(Package);
27 
29  //
30  // METHOD NAME : Package::Package
31  // METHOD TYPE : Ctor
32  //
33  Package::Package( const sat::Solvable & solvable_r )
34  : ResObject( solvable_r )
35  {}
36 
38  //
39  // METHOD NAME : Package::~Package
40  // METHOD TYPE : Dtor
41  //
43  {}
44 
46  {
47  static const IdString support_unsupported( "support_unsupported" );
48  static const IdString support_acc( "support_acc" );
49  static const IdString support_l1( "support_l1" );
50  static const IdString support_l2( "support_l2" );
51  static const IdString support_l3( "support_l3" );
52 
54  // max over all identical packages
55  for ( const auto & solv : sat::WhatProvides( (Capability(ident().id())) ) )
56  {
57  if ( solv.edition() == edition()
58  && solv.ident() == ident()
59  && identical( solv ) )
60  {
61  for ( PackageKeyword kw : Keywords( sat::SolvAttr::keywords, solv ) )
62  {
63  switch ( ret )
64  {
66  if ( kw == support_unsupported ) { ret = VendorSupportUnsupported; break; }
68  if ( kw == support_acc ) { ret = VendorSupportACC; break; }
69  case VendorSupportACC:
70  if ( kw == support_l1 ) { ret = VendorSupportLevel1; break; }
72  if ( kw == support_l2 ) { ret = VendorSupportLevel2; break; }
74  if ( kw == support_l3 ) { return VendorSupportLevel3; break; }
76  /* make gcc happy */ break;
77  }
78  }
79  }
80  }
81  return ret;
82  }
83 
85  {
86  static const VendorSupportOptions unsupportedOpts( VendorSupportUnknown
88  | VendorSupportACC );
89  return unsupportedOpts.testFlag( vendorSupport() );
90  }
91 
93  {
94  Target_Ptr target( getZYpp()->getTarget() );
95  if ( ! target )
96  {
97  ERR << "Target not initialized. Changelog is not available." << std::endl;
98  return Changelog();
99  }
100 
101  if ( repository().isSystemRepo() )
102  {
104  target->rpmDb().getData(name(), header);
105  return header ? header->tag_changelog() : Changelog(); // might be deleted behind our back (bnc #530595)
106  }
107  WAR << "changelog is not available for uninstalled packages" << std::endl;
108  return Changelog();
109  }
110 
111  std::string Package::buildhost() const
113 
114  std::string Package::distribution() const
116 
117  std::string Package::license() const
119 
120  std::string Package::packager() const
122 
123  std::string Package::group() const
125 
128 
129  std::string Package::url() const
131 
134 
135  std::list<std::string> Package::authors() const
136  {
137  std::list<std::string> ret;
138  str::split( lookupStrAttribute( sat::SolvAttr::authors ), std::back_inserter(ret), "\n" );
139  return ret;
140  }
141 
144 
147 
149  { return lookupLocation(); }
150 
151  std::string Package::sourcePkgName() const
152  {
153  // no id means same as package
155  return id ? IdString( id ).asString() : name();
156  }
157 
159  {
160  // no id means same as package
162  return id ? Edition( id ) : edition();
163  }
164 
165  std::string Package::sourcePkgType() const
167 
168  std::string Package::sourcePkgLongName() const
169  { return str::form( "%s-%s.%s", sourcePkgName().c_str(), sourcePkgEdition().c_str(), sourcePkgType().c_str() ); }
170 
171 
173 } // namespace zypp