13 #include <unordered_map> 19 #include <zypp-core/base/InputStream> 20 #include <zypp-core/base/DefaultIntegral> 25 #include <zypp-core/parser/ParseException> 32 #undef ZYPP_BASE_LOGGER_LOGGROUP 33 #define ZYPP_BASE_LOGGER_LOGGROUP "parser" 51 void setVar(
const std::string & key_r,
const std::string & val_r )
54 _vars[key_r] = replace( val_r );
58 std::string replace(
const std::string & val_r )
const 61 if ( vbeg == std::string::npos )
66 for( ; vbeg != std::string::npos; vbeg = val_r.find(
"%{", vbeg ) )
70 if ( nend == std::string::npos )
72 WAR <<
"Incomplete variable in '" << val_r <<
"'" << endl;
75 const auto & iter =
_vars.find( val_r.substr( nbeg, nend-nbeg ) );
76 if ( iter !=
_vars.end() )
79 ret << val_r.substr( cbeg, vbeg-cbeg );
84 WAR <<
"Undefined variable %{" << val_r.substr( nbeg, nend-nbeg ) <<
"} in '" << val_r <<
"'" << endl;
87 if ( cbeg < val_r.size() )
88 ret << val_r.substr( cbeg );
93 std::unordered_map<std::string,std::string>
_vars;
125 value_r =
_replacer.replace( s.asString() );
126 return !value_r.empty();
144 MIL <<
"Reading " << is.
path() << endl;
163 if ( reader_r->
nodeType() == XML_READER_TYPE_ELEMENT )
166 if ( reader_r->
name() ==
"repoindex" )
172 _replacer.setVar( name, value );
175 _ttl = str::strtonum<Date::Duration>(value);
181 if ( reader_r->
name() ==
"repo" )
193 std::string attrValue;
197 if ( getAttrValue(
"alias", reader_r, attrValue ) )
200 _replacer.setVar(
"alias", attrValue );
210 getAttrValue(
"url", reader_r, urlstr );
211 getAttrValue(
"path", reader_r, pathstr );
212 if ( urlstr.empty() )
214 if ( pathstr.empty() )
221 if ( pathstr.empty() )
233 if ( getAttrValue(
"name", reader_r, attrValue ) )
237 if ( getAttrValue(
"distro_target", reader_r, attrValue ) )
241 if ( getAttrValue(
"priority", reader_r, attrValue ) )
242 info.
setPriority( str::strtonum<unsigned>( attrValue ) );
245 if ( getAttrValue(
"enabled", reader_r, attrValue ) )
249 if ( getAttrValue(
"autorefresh", reader_r, attrValue ) )
253 if ( getAttrValue(
"gpgcheck", reader_r, attrValue ) )
255 if ( getAttrValue(
"repo_gpgcheck", reader_r, attrValue ) )
257 if ( getAttrValue(
"pkg_gpgcheck", reader_r, attrValue ) )
261 if ( getAttrValue(
"keeppackages", reader_r, attrValue ) )
265 if ( getAttrValue(
"gpgkey", reader_r, attrValue ) )
269 if ( getAttrValue(
"mirrorlist", reader_r, attrValue ) )
273 if ( getAttrValue(
"metalink", reader_r, attrValue ) )
300 : _pimpl(new
Impl( is,
std::move(callback) ))
void setBaseUrl(Url url)
Clears current base URL list and adds url.
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
ProcessResource _callback
Function for processing collected data.
void setAutorefresh(bool autorefresh)
enable or disable autorefresh
void setPriority(unsigned newval_r)
Set repository priority for solver.
function< bool(const RepoInfo &)> ProcessResource
Callback definition.
NodeType nodeType() const
Get the node type of the current node.
void setMirrorListUrl(const Url &url)
Set mirror list url.
XmlString value() const
Provides the text value of the node if present.
void setEnabled(bool enabled)
enable or disable the repository
RepoindexFileReader(Pathname repoindexFile, ProcessResource callback)
CTOR.
void setAlias(const std::string &alias)
set the repository alias
What is known about a repository.
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
std::unordered_map< std::string, std::string > _vars
Interface of repoindex.xml file reader.
TriBool strToTriBool(const C_Str &str)
Parse str into a bool if it's a legal true or false string; else indeterminate.
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
XmlString getAttribute(const char *name_r) const
Provides a copy of the attribute value with the specified qualified name.
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
~RepoindexFileReader()
DTOR.
void setPath(const Pathname &path)
set the product path.
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
DefaultIntegral< Date::Duration, 0 > _ttl
const ProcessCredentials & _callback
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Impl(const InputStream &is, ProcessResource &&callback)
CTOR.
bool foreachNode(const ProcessNode &fnc_r)
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
std::string asString() const
Explicit conversion to std::string.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
Date::Duration ttl() const
Metadata TTL (repoindex.xml:xpath:/repoindex or 0).
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
void setName(const std::string &name)
set the repository name
bool getAttrValue(const std::string &key_r, Reader &reader_r, std::string &value_r)
bool consumeNode(Reader &reader_r)
Callback provided to the XML parser.
Easy-to use interface to the ZYPP dependency resolver.
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
XmlString localName() const
The local name of the node.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
bool strToTrue(const C_Str &str)
Parsing boolean from string.
xmlTextReader based interface to iterate xml streams.