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 ///////////////////////////////////////////////////////////////////
47 // Package interface forwarded to implementation
49 ///////////////////////////////////////////////////////////////////
51 Changelog Package::changelog() const
56 target = getZYpp()->target();
58 catch ( const Exception &e )
60 ERR << "Target not initialized. Changelog is not available." << std::endl;
65 if ( repository().isSystemRepo() )
67 target::rpm::RpmHeader::constPtr header;
68 target->rpmDb().getData(name(), header);
69 return header->tag_changelog();
71 WAR << "changelog is not available for uninstalled packages" << std::endl;
76 std::string Package::buildhost() const
77 { return lookupStrAttribute( sat::SolvAttr::buildhost ); }
80 std::string Package::distribution() const
81 { return lookupStrAttribute( sat::SolvAttr::distribution ); }
84 std::string Package::license() const
85 { return lookupStrAttribute( sat::SolvAttr::license ); }
88 std::string Package::packager() const
89 { return lookupStrAttribute( sat::SolvAttr::packager ); }
92 std::string Package::group() const
93 { return lookupStrAttribute( sat::SolvAttr::group ); }
95 Package::Keywords Package::keywords() const
96 { return Keywords( sat::SolvAttr::keywords, satSolvable() ); }
98 /** Don't ship it as class Url, because it might be
99 * in fact anything but a legal Url. */
101 std::string Package::url() const
105 ByteCount Package::sourcesize() const
106 { return lookupNumAttribute( sat::SolvAttr::sourcesize ); }
108 std::list<std::string> Package::authors() const
110 std::list<std::string> ret;
111 str::split( lookupStrAttribute( sat::SolvAttr::authors ), std::back_inserter(ret), "\n" );
115 std::list<std::string> Package::filenames() const
117 std::list<std::string> files;
118 sat::LookupAttr q( sat::SolvAttr::filelist, *this );
119 for_( it, q.begin(), q.end() )
121 files.push_back(it.asString());
126 CheckSum Package::checksum() const
127 { return lookupCheckSumAttribute( sat::SolvAttr::checksum ); }
129 OnMediaLocation Package::location() const
130 { return lookupLocation(); }
132 std::string Package::sourcePkgName() const
134 // no id means same as package
135 sat::detail::IdType id( lookupIdAttribute( sat::SolvAttr::sourcename ) );
136 id = lookupIdAttribute(sat::SolvAttr::sourcearch);
137 return id ? IdString( id ).asString() : name();
140 Edition Package::sourcePkgEdition() const
142 // no id means same as package
143 sat::detail::IdType id( lookupIdAttribute( sat::SolvAttr::sourceevr ) );
144 return id ? Edition( id ) : edition();
147 /////////////////////////////////////////////////////////////////
149 ///////////////////////////////////////////////////////////////////