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" )
50 _baseurls[section_r].push_back( Url(value_r) );
52 else if ( key_r ==
"gpgkey" )
55 legacyStoreUrl(
_gpgkeys[section_r], value_r );
64 virtual void garbageLine(
const std::string & section_r,
const std::string & line_r )
68 case MultiLine::baseurl:
69 _baseurls[section_r].push_back( Url(line_r) );
72 case MultiLine::gpgkey:
73 legacyStoreUrl(
_gpgkeys[section_r], line_r );
82 std::list<Url> & baseurls(
const std::string & section_r )
85 std::list<Url> & gpgkeys(
const std::string & section_r )
89 void legacyStoreUrl( std::list<Url> & store_r,
const std::string & line_r )
96 std::vector<std::string> keys;
97 str::split( line_r, std::back_inserter(keys) );
98 for (
auto && str : keys )
99 store_r.push_back( Url(std::move(str)) );
102 enum class MultiLine { none, baseurl, gpgkey };
120 RepoFileParser dict(is);
121 for_( its, dict.sectionsBegin(), dict.sectionsEnd() )
126 std::string proxyport;
128 for_( it, dict.entriesBegin(*its), dict.entriesEnd(*its) )
131 if (it->first ==
"name" )
133 else if ( it->first ==
"enabled" )
135 else if ( it->first ==
"priority" )
136 info.
setPriority( str::strtonum<unsigned>( it->second ) );
137 else if ( it->first ==
"path" )
138 info.
setPath( Pathname(it->second) );
139 else if ( it->first ==
"type" )
141 else if ( it->first ==
"autorefresh" )
143 else if ( it->first ==
"mirrorlist" && !it->second.empty())
145 else if ( it->first ==
"metalink" && !it->second.empty())
147 else if ( it->first ==
"gpgcheck" )
149 else if ( it->first ==
"repo_gpgcheck" )
151 else if ( it->first ==
"pkg_gpgcheck" )
153 else if ( it->first ==
"keeppackages" )
155 else if ( it->first ==
"service" )
157 else if ( it->first ==
"proxy" )
166 proxy = it->second.substr( 0, it->second.size() - what[0].
size() );
167 proxyport = what[0].substr( 1 );
175 ERR <<
"Unknown attribute in [" << *its <<
"]: " << it->first <<
"=" << it->second <<
" ignored" << endl;
178 for (
auto &
url : dict.baseurls( *its ) )
180 if ( ! proxy.empty() &&
url.getQueryParam(
"proxy" ).empty() )
182 url.setQueryParam(
"proxy", proxy );
183 url.setQueryParam(
"proxyport", proxyport );
TriBool strToTriBool(const C_Str &str)
Parse str into a bool if it's a legal true or false string; else indterminate.
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.
std::map< std::string, std::list< Url > > _gpgkeys
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.
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.
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
bool strToTrue(const C_Str &str)
Parsing boolean from string.
Regular expression match result.
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.