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 if ( ( vendorSupport() == VendorSupportUnknown ) ||
69 ( vendorSupport() == VendorSupportACC ) ||
70 ( vendorSupport() == VendorSupportUnsupported ) )
75 Changelog Package::changelog() const
77 Target_Ptr target( getZYpp()->getTarget() );
80 ERR << "Target not initialized. Changelog is not available." << std::endl;
84 if ( repository().isSystemRepo() )
86 target::rpm::RpmHeader::constPtr header;
87 target->rpmDb().getData(name(), header);
88 return header->tag_changelog();
90 WAR << "changelog is not available for uninstalled packages" << std::endl;
94 std::string Package::buildhost() const
95 { return lookupStrAttribute( sat::SolvAttr::buildhost ); }
97 std::string Package::distribution() const
98 { return lookupStrAttribute( sat::SolvAttr::distribution ); }
100 std::string Package::license() const
101 { return lookupStrAttribute( sat::SolvAttr::license ); }
103 std::string Package::packager() const
104 { return lookupStrAttribute( sat::SolvAttr::packager ); }
106 std::string Package::group() const
107 { return lookupStrAttribute( sat::SolvAttr::group ); }
109 Package::Keywords Package::keywords() const
110 { return Keywords( sat::SolvAttr::keywords, satSolvable() ); }
112 std::string Package::url() const
113 { return lookupStrAttribute( sat::SolvAttr::url ); }
115 ByteCount Package::sourcesize() const
116 { return lookupNumAttribute( sat::SolvAttr::sourcesize ); }
118 std::list<std::string> Package::authors() const
120 std::list<std::string> ret;
121 str::split( lookupStrAttribute( sat::SolvAttr::authors ), std::back_inserter(ret), "\n" );
125 Package::FileList Package::filelist() const
126 { return FileList( sat::SolvAttr::filelist, satSolvable() ); }
128 CheckSum Package::checksum() const
129 { return lookupCheckSumAttribute( sat::SolvAttr::checksum ); }
131 OnMediaLocation Package::location() const
132 { return lookupLocation(); }
134 std::string Package::sourcePkgName() const
136 // no id means same as package
137 sat::detail::IdType id( lookupIdAttribute( sat::SolvAttr::sourcename ) );
138 return id ? IdString( id ).asString() : name();
141 Edition Package::sourcePkgEdition() const
143 // no id means same as package
144 sat::detail::IdType id( lookupIdAttribute( sat::SolvAttr::sourceevr ) );
145 return id ? Edition( id ) : edition();
148 std::string Package::sourcePkgType() const
149 { return lookupStrAttribute( sat::SolvAttr::sourcearch ); }
151 std::string Package::sourcePkgLongName() const
152 { return str::form( "%s-%s.%s", sourcePkgName().c_str(), sourcePkgEdition().c_str(), sourcePkgType().c_str() ); }
155 /////////////////////////////////////////////////////////////////
157 ///////////////////////////////////////////////////////////////////