14 #include <zypp/base/String.h> 15 #include <zypp/base/Logger.h> 16 #include <zypp/base/Regex.h> 18 #include <zypp/Pathname.h> 19 #include <zypp/Date.h> 21 #include <zypp/CheckSum.h> 26 #undef ZYPP_BASE_LOGGER_LOGGROUP 27 #define ZYPP_BASE_LOGGER_LOGGROUP "parser::yum" 49 : _callback( callback )
51 Reader reader( repomd_file );
52 MIL <<
"Reading " << repomd_file << endl;
53 reader.
foreachNode( bind( &RepomdFileReader::Impl::consumeNode,
this, _1 ) );
59 bool consumeNode(
Reader & reader_r );
101 bool RepomdFileReader::Impl::consumeNode(
Reader & reader_r )
103 if ( reader_r->
nodeType() == XML_READER_TYPE_ELEMENT )
106 if ( reader_r->
name() ==
"repomd" )
112 if ( reader_r->
name() ==
"data" )
119 if ( reader_r->
name() ==
"location" )
127 if ( reader_r->
name() ==
"checksum" )
129 _location.setChecksum( getChecksum( reader_r ) );
134 if ( reader_r->
name() ==
"header-checksum" )
136 _location.setHeaderChecksum( getChecksum( reader_r ) );
141 if ( reader_r->
name() ==
"timestamp" )
148 if ( reader_r->
name() ==
"size" )
150 _location.setDownloadSize( getSize( reader_r ) );
155 if ( reader_r->
name() ==
"header-size" )
157 _location.setHeaderSize( getSize( reader_r ) );
162 if ( reader_r->
name() ==
"content" )
164 const auto & tag = reader_r.
nodeText();
165 if ( tag.c_str() && *tag.c_str() )
166 _keywords.insert( tag.asString() );
171 else if ( reader_r->
nodeType() == XML_READER_TYPE_END_ELEMENT )
174 if ( reader_r->
name() ==
"data" )
177 _callback( std::move(_location), _typeStr );
196 : _pimpl( new
Impl(repomd_file, callback) )
207 {
return _pimpl->keywords(); }
211 std::vector<std::pair<std::string,std::string>> ret;
212 for (
const std::string & tag :
keywords() ) {
216 if ( tag.compare( 0,10,
"gpg-pubkey" ) != 0 )
219 static const str::regex rx(
"^(gpg-pubkey([^?]*))(\\?fpr=([[:xdigit:]]{8,}))?$" );
222 std::string keyfile { what[1] };
223 std::string keyident;
224 if ( what.
size(4) != std::string::npos ) {
228 static const str::regex rx(
"^-([[:xdigit:]]{8,})" );
233 DBG <<
"Tag " << tag <<
" does not contain a keyident. ignore it." << endl;
237 ret.push_back( std::make_pair( std::move(keyfile), std::move(keyident) ) );
RepomdFileReader(const Pathname &repomd_file, const ProcessResource &callback)
CTOR.
std::string _typeStr
The resource type string.
Store and operate with byte count.
NodeType nodeType() const
Get the node type of the current node.
function< bool(OnMediaLocation &&, const std::string &)> ProcessResource
Callback taking OnMediaLocation and the resource type string.
ByteCount getSize(Reader &reader_r)
Retrieve a size node.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
OnMediaLocation _location
Location of metadata file.
XmlString getAttribute(const char *name_r) const
Provides a copy of the attribute value with the specified qualified name.
std::vector< std::pair< std::string, std::string > > keyhints() const
gpg key hits shipped in keywords (bsc#1184326)
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
Impl(const Pathname &repomd_file, const ProcessResource &callback)
Ctro taking a ProcessResource callback.
const std::set< std::string > & keywords() const
repo keywords parsed on the fly
Regular expression match result.
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value...
CheckSum getChecksum(Reader &reader_r)
Retrieve a checksum node.
std::string asString() const
Explicit conversion to std::string.
bool foreachNode(ProcessNode fnc_r)
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
regex ZYPP_STR_REGEX regex ZYPP_STR_REGEX
std::set< std::string > _keywords
repo keywords parsed on the fly
Interface of repomd.xml file reader.
ProcessResource _callback
Function for processing collected data.
Easy-to use interface to the ZYPP dependency resolver.
const std::set< std::string > & keywords() const
repo keywords parsed on the fly
xmlTextReader based interface to iterate xml streams.