37 class RepoFileParser :
public IniDict
40 RepoFileParser(
const InputStream & is_r )
45 virtual void consume(
const std::string & section_r,
const std::string & key_r,
const std::string & value_r )
47 if ( key_r ==
"baseurl" )
49 setInBaseurls(
true );
50 _baseurls[section_r].push_back( Url(value_r) );
54 setInBaseurls(
false );
59 virtual void garbageLine(
const std::string & section_r,
const std::string & line_r )
62 _baseurls[section_r].push_back( Url(line_r) );
67 std::list<Url> & baseurls(
const std::string & section_r )
71 void setInBaseurls(
bool yesno_r )
89 RepoFileParser dict(is);
90 for_( its, dict.sectionsBegin(), dict.sectionsEnd() )
95 std::string proxyport;
97 for_( it, dict.entriesBegin(*its), dict.entriesEnd(*its) )
100 if (it->first ==
"name" )
102 else if ( it->first ==
"enabled" )
104 else if ( it->first ==
"priority" )
105 info.
setPriority( str::strtonum<unsigned>( it->second ) );
106 else if ( it->first ==
"path" )
107 info.
setPath( Pathname(it->second) );
108 else if ( it->first ==
"type" )
110 else if ( it->first ==
"autorefresh" )
112 else if ( it->first ==
"mirrorlist" && !it->second.empty())
114 else if ( it->first ==
"metalink" && !it->second.empty())
116 else if ( it->first ==
"gpgkey" && !it->second.empty())
118 std::vector<std::string> keys;
119 str::split( it->second, std::back_inserter(keys) );
120 if ( ! keys.empty() )
123 else if ( it->first ==
"gpgcheck" )
125 else if ( it->first ==
"repo_gpgcheck" )
127 else if ( it->first ==
"pkg_gpgcheck" )
129 else if ( it->first ==
"keeppackages" )
131 else if ( it->first ==
"service" )
133 else if ( it->first ==
"proxy" )
142 proxy = it->second.substr( 0, it->second.size() - what[0].
size() );
143 proxyport = what[0].substr( 1 );
151 ERR <<
"Unknown attribute in [" << *its <<
"]: " << it->first <<
"=" << it->second <<
" ignored" << endl;
154 for (
auto &
url : dict.baseurls( *its ) )
TriBool strToTriBool(const C_Str &str)
Parse str into a bool if it's a legal true or false string; else indterminate.
void setGpgKeyUrl(const Url &gpgkey)
Key to use for gpg checking of this repository.
void setQueryParam(const std::string ¶m, const std::string &value)
Set or add value for the specified query parameter.
function< bool(const RepoInfo &)> ProcessRepo
Callback definition.
void setAutorefresh(bool autorefresh)
enable or disable autorefresh
void setPriority(unsigned newval_r)
Set repository priority for solver.
virtual void consume(const std::string §ion)
Called when a section is found.
void setMirrorListUrl(const Url &url)
Set mirror list url.
void setEnabled(bool enabled)
enable or disable the repository
std::map< std::string, std::list< Url > > _baseurls
void setAlias(const std::string &alias)
set the repository alias
void setFilepath(const Pathname &filename)
set the path to the .repo file
What is known about a repository.
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
std::ostream & operator<<(std::ostream &str, const IniDict &obj)
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
RepoFileReader(const Pathname &repo_file, const ProcessRepo &callback, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
Constructor.
map< string, string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
const ProcessCredentials & _callback
static void repositories_in_stream(const InputStream &is, const RepoFileReader::ProcessRepo &callback, const ProgressData::ReceiverFnc &progress)
List of RepoInfo's from a file.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
void setPath(const Pathname &path)
set the product path.
void setService(const std::string &name)
sets service which added this repository
void setType(const repo::RepoType &t)
set the repository type
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Read repository data from a .repo file.
void addBaseUrl(const Url &url)
Add a base url.
std::string getQueryParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
virtual void garbageLine(const std::string §ion, const std::string &line)
Called whenever a garbage line is found.
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
bool strToTrue(const C_Str &str)
Parsing boolean from string.
Regular expression match result.
DefaultIntegral< bool, false > _inBaseurls
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
regex ZYPP_STR_REGEX regex ZYPP_STR_REGEX
void setName(const std::string &name)
set the repository name
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Repository type enumeration.