1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Package.cc
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"
18 #include "zypp/target/rpm/RpmHeader.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
26 IMPL_PTR_TYPE(Package);
28 ///////////////////////////////////////////////////////////////////
30 // METHOD NAME : Package::Package
33 Package::Package( const sat::Solvable & solvable_r )
34 : ResObject( solvable_r )
37 ///////////////////////////////////////////////////////////////////
39 // METHOD NAME : Package::~Package
45 VendorSupportOption Package::vendorSupport() const
47 Keywords kw(keywords());
49 for_( it, kw.begin(), kw.end() )
51 if ( *it == "support_unsupported")
52 return VendorSupportUnsupported;
53 if ( *it == "support_acc")
54 return VendorSupportACC;
56 if ( *it == "support_l1")
57 return VendorSupportLevel1;
58 if ( *it == "support_l2")
59 return VendorSupportLevel2;
60 if ( *it == "support_l3")
61 return VendorSupportLevel3;
63 return VendorSupportUnknown;
66 bool Package::maybeUnsupported() const
68 return ( vendorSupport() & ( VendorSupportACC | VendorSupportUnsupported | VendorSupportUnknown ) == ( VendorSupportACC | VendorSupportUnsupported | VendorSupportUnknown ) );
72 Changelog Package::changelog() const
77 target = getZYpp()->target();
79 catch ( const Exception &e )
81 ERR << "Target not initialized. Changelog is not available." << std::endl;
86 if ( repository().isSystemRepo() )
88 target::rpm::RpmHeader::constPtr header;
89 target->rpmDb().getData(name(), header);
90 return header->tag_changelog();
92 WAR << "changelog is not available for uninstalled packages" << std::endl;
96 std::string Package::buildhost() const
97 { return lookupStrAttribute( sat::SolvAttr::buildhost ); }
99 std::string Package::distribution() const
100 { return lookupStrAttribute( sat::SolvAttr::distribution ); }
102 std::string Package::license() const
103 { return lookupStrAttribute( sat::SolvAttr::license ); }
105 std::string Package::packager() const
106 { return lookupStrAttribute( sat::SolvAttr::packager ); }
108 std::string Package::group() const
109 { return lookupStrAttribute( sat::SolvAttr::group ); }
111 Package::Keywords Package::keywords() const
112 { return Keywords( sat::SolvAttr::keywords, satSolvable() ); }
114 std::string Package::url() const
115 { return lookupStrAttribute( sat::SolvAttr::url ); }
117 ByteCount Package::sourcesize() const
118 { return lookupNumAttribute( sat::SolvAttr::sourcesize ); }
120 std::list<std::string> Package::authors() const
122 std::list<std::string> ret;
123 str::split( lookupStrAttribute( sat::SolvAttr::authors ), std::back_inserter(ret), "\n" );
127 std::list<std::string> Package::filenames() const
129 std::list<std::string> files;
130 sat::LookupAttr q( sat::SolvAttr::filelist, *this );
131 for_( it, q.begin(), q.end() )
133 files.push_back(it.asString());
138 CheckSum Package::checksum() const
139 { return lookupCheckSumAttribute( sat::SolvAttr::checksum ); }
141 OnMediaLocation Package::location() const
142 { return lookupLocation(); }
144 std::string Package::sourcePkgName() const
146 // no id means same as package
147 sat::detail::IdType id( lookupIdAttribute( sat::SolvAttr::sourcename ) );
148 id = lookupIdAttribute(sat::SolvAttr::sourcearch);
149 return id ? IdString( id ).asString() : name();
152 Edition Package::sourcePkgEdition() const
154 // no id means same as package
155 sat::detail::IdType id( lookupIdAttribute( sat::SolvAttr::sourceevr ) );
156 return id ? Edition( id ) : edition();
159 /////////////////////////////////////////////////////////////////
161 ///////////////////////////////////////////////////////////////////